This is an old revision of the document!
incomingValue; must be added to the end of all scripts
Why?
To avoid a script running multiple times when there is an error in the script (especially at runtime) the script will not complete execution unless there is an incomingValue; (or any other output, such as a calculated value) as the very last line of a script.
For example if you do this:
if (incomingValue.getQuality()==0) {
//do something here
} else {
//do nothing
}
There is no final value calculated so this script will execute exactly one time after the application starts up
If you do this:
if (incomingValue.getQuality()==0) {
//do something here
} else {
//do nothing
}
incomingValue;
This is also OK (there is an output at the end)
if (incomingValue.getQuality()==0) {
status=2;
} else {
status=-1;
}
status;
this script will execute every time a new value is received by the script which is likely what you intend to happen.
This is a change which was implemented in early 2024 so if you have old projects without this final “incomingValue;” you can add this last line in the script manually to every script, or you can use the steps below (please make a copy of your project before doing this in case there is a corruption of the file after the process).
How to add incomingValue; to every script in a .tsx (TransSECS project file)
- Make a copy of your project tsx (as a backup) - Exit TransSECS (TransSECS should not be running) - On Windows use Notepad++ to load the project tsx. You can change the language to XML, but this is not necessary
First Pass: replace all existing "incomingValue;" so these are preserved
- Use Ctrl-H to bring up the panel for the Find and Replace
- Set up the Replace:
- Search Mode: Regular Expression
- Find what: (;)\s*</Script>
- Replace with:\1<!–OK–></Script>
- Execute the replace: Click Replace All
What this does is find any string(or just ;) with a “;” just before the end of the script (the </Script> tag) and replaces this with a place holder marking it as “OK”. You should see a count on the bottom bar of this panel of how many of these valid strings were found. In the second pass, below, we look for end of script tags (</Script>) which do not end with a ; and fix them:
Second Pass: add new incomingValue; where needed to end a script (and ignore the incomingValue; already in place)
- Set up the Replace:
- Search Mode: Regular Expression
- Find what: (?<!<!–OK–>)</Script>
- Replace with: incomingValue;</Script>
- Execute the replace: Click Replace All
On this last pass you can add a comment to the replacement line, such as incomingValue; <!–fixed today–>, and put today's date in place of “today”
Optional: you can replace the OK <!–OK–> and/or fixed <!–fixed today–> comments with blank strings to remove them
This procedure should help you modify projects using scripts in which there is no output at the end of the script. However, it is good to do a quick check of your project after these changes. Also there can be some casese where incomingValue; is not inserted before the end of the script because the last line in the script ended with a ; and there is no output on that line. For example, if your last line was DataSource.logMessage(“some message”); this will not get an incomingValue; added and logMessage does not return a value so this can still cause the script not to execute the next time it is triggered. If you had a method call on the last line which does return a value then this satisfies the output requirement.


