Hi,
I seem to have found a problem when a Delay component is used and when the delay is a variable and the variable value is 0. The Delay either lasts too long or an enless loop is created (I'm not sure which).
The quick fix is a check to make sure the variable is not zero, however, as the delay is a user input variable and no delay is a realistic option to choose it would make for cleaner coding if a variable holding a value of 0 could be used?
Or is there a likely bug in my code?
Thanks,
Mark
Delay component when variable used and variable value is 0
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Mark
You could have the delay in a desicion branch and only call the delay if the variable is greater then 0
Eg
if var1 > 0
Yes delay for var1
No carry on with program.
I think if you pass a value of 0 it will instantly rollover and give the maximum possible delay eg. 65536 seconds or milliseconds.
You could have the delay in a desicion branch and only call the delay if the variable is greater then 0
Eg
if var1 > 0
Yes delay for var1
No carry on with program.
I think if you pass a value of 0 it will instantly rollover and give the maximum possible delay eg. 65536 seconds or milliseconds.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Steve
- Matrix Staff
- Posts: 3422
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
If you are concerned about this, there is a permanent fix you can apply. The FCD files define how these delays work - have a look at the DelayCmdS and DelayCmdMs entries in the "Code" section.
At the moment these are as follows:
Altering them to this would fix this issue:
Do you think I should make this change in all FCD files in the next release?
At the moment these are as follows:
Code: Select all
DelayCmdS="delay_s(%o);\n"
DelayCmdMs="delay_ms(%o);\n"
Code: Select all
DelayCmdS="if (%o > 0) delay_s(%o);\n"
DelayCmdMs="if (%o > 0) delay_ms(%o);\n"