Why the z
(ok, can't compound styles)
I (again) don't know if it is good/bad or indifferent that I did that.
When messing around with Arduino code and you call a function I get that external variables are visible in there, but it is ...... good practice (?) to call a function with variables and then in the function have them as locals.
Ok, another angle:
fd(x,y)
The most basic.
That is the definition of the function - yes?
It is actually called with:
fd(new_value,current_value);
Earlier in the code.
So, taking what you say - and this is just talking - to the next level:
Why wouldn't (couldn't?) I just fd()
?
Then in the fd
part it would be:
current_value -= 1;
// node.warn("new value - x " + x);
// node.warn("exiting value - y " + y);
msg.payload = current_value;
node.send(msg);
if(new_value < current_value){
setTimeout( fd, z, new_value, current_value );
}
(Ok, I did mess it up a bit.....) But can you see where/how I am confused?
That function (fd
in this case) has a world of its own variables and so I thought to be in keeping with how things are done, that the time_delay should be done in the same way.
I do get that time_delay
could be used as you showed. I guess I am in a bit of a rut and may be sticking to detaching variables from themselves in routines/functions.
Good, bad? I don't know and would like to learn. But I don't have any .... mentors at hand.
So I just go with what is at the particular time of writing, and hope that one way prevails, or gets established as the better way.
Again: Thanks. I did what you said and it does work. (Like it wouldn't). (Sorry. Toung in cheek there. Just to clarify.)
I think I have attacked this long enough for today (well: now speaking it is yesterday) and may need to get some down time.
In closing: So I do need to add the extra 1000
in the original block of code at the end of the setTimeout
line?