Strange behavior in the flow of a script
Posted: Thu Mar 11, 2010 2:50 pm
Hi. I apologize for my English.
A question about a strange behavior in the writing of a script.
The script does not do anything useful, it is only to explain the problem.
Create a new stack. In the card create a field (for example call it "Dati") and create a check box (call it eg "Aim"). In the card script write this simple script:
Run the script. If you activate the check box (true) when you move the mouse the counter increases its value. If you deactivate the check box (false) the counter stops.
Ok. It works, even if it does anything useful…
But now consider the following script: it is the same as the first example, and only moved the statement "if" after the "add".
Replace in the card script the previous script with this new and run again.
But now the counter is incremented always be that check box is activated or not.
When writing a program I can logically put a test where deemed appropriate (for example, after running some code at least once).
Why in this case does not work? Is there anything I don't know programming?
Thank you for your attention.
A question about a strange behavior in the writing of a script.
The script does not do anything useful, it is only to explain the problem.
Create a new stack. In the card create a field (for example call it "Dati") and create a check box (call it eg "Aim"). In the card script write this simple script:
Code: Select all
on mouseMove
if the hilite of btn "aim" = false then exit mouseMove
add 1 to fld "Dati"
end mouseMove
Run the script. If you activate the check box (true) when you move the mouse the counter increases its value. If you deactivate the check box (false) the counter stops.
Ok. It works, even if it does anything useful…

But now consider the following script: it is the same as the first example, and only moved the statement "if" after the "add".
Code: Select all
on mouseMove
add 1 to fld "Dati"
if the hilite of btn "aim" = false then exit mouseMove
end mouseMove
Replace in the card script the previous script with this new and run again.
But now the counter is incremented always be that check box is activated or not.
When writing a program I can logically put a test where deemed appropriate (for example, after running some code at least once).
Why in this case does not work? Is there anything I don't know programming?
Thank you for your attention.