Reserved Word Warning


MrDeathStar

Recommended Posts

Posted

Today I was moving code from some old sequences into a single new sequence with a switch statement. The old sequences were being called by some variable value components and worked well.  I updated the components to call my new sequence and DAQFactory locked up.

 

Sequences that demonstrate this problem are attached.

TimeAsVarName.ctl

 

It is interesting that the old code works well but a lockup occurs if I use the case statement (with the variable declared outside the switch code).  The problem seems to stems from the use of 'time' as a variable name (since 'time' is likely a reserved word).  It might be a nice future feature to have the parser fail with a warning if a reserved word is declared.  Not sure why DF hangs.

 

Posted

You are correct, the issue is that "time" is a reserved word used for a deprecated form of scripting in place of wait().  The compiler is confusing your time with the Time statement, which, since its not used correctly causes a wait forever.  Since you are calling this from the primary thread of DAQFactory (the UI), the program hangs because the script gets stuck at that line and never returns.  DAQFactory is not actually hung.  Any other sequences, logging, data acquisition would still run.  Just the UI would freeze.

 

Why it works in one script and not the other I can't say.  Its some fluke of the script parser. 

  • 1 year later...
Posted

Hi, I worked the problem to see the problem which was being masked by other errors. Yes it does freeze but only for Switch/Case seen in version 2 attached. Also showed me where to look to see. [Notes within]

TimeAsVarName2.ctl

Archived

This topic is now archived and is closed to further replies.