To script or not to script, that is the question. - old forum post


#1

Joshua

Joined on 06-09-2005
Posts 6
To Script or Not to Script (ioControl UIO question)

I’ve finished a chart. It’s my first one and it’s very simple. It checks a dozen bistate points, and reports an SNMP trap if It goes off for more than 5 seconds. What I’m wondering is if it would be more efficient to Create a script block for each bistate point instead of doing what i’m currently doing, which is charting out each step of the process. I guess my question is if your doing the same thing, is it more efficient to chart it, or to script block it?
Report
06-15-2005, 6:53 AM
JOSHC

Joined on 11-21-2003
Posts 14
Re: To Script or Not to Script (ioControl UIO question)

I think that if you are doing the same thing over and over again it is easier to script block it.
Report
06-15-2005, 8:08 AM
gmitchell

Joined on 12-01-2003
Optomation Systems, Madrid, Spain
Posts 153
Re: To Script or Not to Script (ioControl UIO question)

ioScripting may take slightly longer to process, but there is no appreciable difference. Anything that you can do in Flow Diagrams can be done in ioScripting, and visa versa. Generally experienced programmers prefer ioScripting, due to its similarity to structured language, but beginners will probably prefer flow chart logic. The great thing is that you can pick and mix using the two styles in the same chart. To quote the excellent documentation of ioControl Users Guide… …“You’ll want to use OptoScript for some common programming tasks that can be more difficult to do using standard ioControl commands than using a procedural language. Extensive math calculations or complex loops, for example, can be done with standard commands but take up a lot of space on a flowchart. OptoScripting can be useful to develop sections of your application involving • for math expressions • for string handling • for complex loops • for case statements • for conditions • for combining math expressions, loops, and conditions. • for complex loops • for Complex Loops • while loops, repeat loops and for loops When you use OptoScript, however, be aware that it is not self-documenting. Make sure you frequently use comments to explain what the code does, so that when you come back to it a year later—or when someone who is not as familiar with the code or the strategy must change it—it can be easily interpreted…” Some annoying features of ioScripting that should be of interest 1. If you change the name of a variable, this is corrected instantly with flowchart logic, but you have to manually correct its in every ioScripting block 2. The correct use of wend, endif, endswitch etc with correct indentation in ioScript can be quite tricky to get right first time round, and will need detailed debugging to make sure the code really is working as expected 3. Sometimes the compiler output explaining why a section of ioScripting will not compile are not exactly obvious to the average human. Some improvements to the ioScripting debugger environment would be to allow beakpoints to be introduced within a section of ioScript code and also allow the “jumping” to another codeline in the same block.
Report
06-16-2005, 6:12 AM
Joshua

Joined on 06-09-2005
Posts 6
Re: To Script or Not to Script (ioControl UIO question)