Skip to content

Debugging and errors

On the operator screen, show values in a message. JSON.stringify prints a whole object:

HMI.ShowMessage(JSON.stringify({
level: Tags("Tank1.Level").Value,
quality: Tags("Tank1.Level").Quality,
fill: Item.Actual("Fill"),
}, null, 2));

To see how an element is built and which fields you can change:

HMI.ShowMessage(JSON.stringify(Item.Properties(), null, 2)); // properties panel values
HMI.ShowMessage(JSON.stringify(Item.Config, null, 2)); // full configuration

On the server, write to the log. Entries appear on the runtime window’s log tab and in the files under %ProgramData%\Scadora\logs:

Log.Info("Task " + Trigger.Task + ": " + Trigger.Tag + " = " + Trigger.Value);

Before running, check the Project check panel in the editor: it shows script syntax errors, unknown tags in functions and empty events.

The program shows error messages in the interface language. The tables below give their meaning in English, and the wording on screen may differ slightly.

Message Cause What to do
Tag … not found The project has no tag with this name Check the name; names assembled from parts do not follow tag renames
…: cannot write an empty value null or undefined passed to Write Make sure the value was computed, for example that a tag did not return null
…: not enough rights to change The user’s role cannot write this tag Grant the permission or change the tag’s protection
Enter 1 or 0 The string does not suit a Bool tag Pass true / false
Enter an integer The string is not an integer for an integer tag Pass a number, not text with units
Allowed from … to … The number does not fit the tag type Limit the value in the script
System function … not found A typo in an HMI.SysFct name Names are English: SetValue, ActivateScreen
Script function … not found RunScript calls a function not in the modules Check the name and that the module loaded without errors
The screen has no object … Screen.Items found no element with this name Check the Name property; inside genies, use Children
Object … has no property … A typo, or this type has no such property See the property reference and check Has
…: colours are written as #RRGGBB The colour is a word or in another format "#D32F2F", not "red"
…: value … does not fit The value does not convert to the property type For a choice, pass the option’s name
…Apply: no field … An unknown field was passed to Apply Look at Item.Config: field names start lowercase
No event … A typo in Raise Names: Click, DoubleClick, LeftDown and so on
Object … has no tag .Value on an element without a Tag property Read the tag through Tags(…)
Screen … not found ActivateScreen with a wrong name Use the screen name, not its title
Not enough rights to operate RunServerScript without the Operate permission Grant the permission
The script ran longer than 2 s and was stopped A long loop or heavy calculation Simplify it, or move heavy work to the server
The script performed too many operations Most likely an endless loop Check the loop’s exit condition
Recursion too deep A function calls itself too deeply Replace recursion with a loop
line N: … A syntax error Lines are counted from the start of the event script
Log message Cause What to do
Server script …: … An error while loading a module Fix the module’s top-level code
Server script function … not found A wrong name in a task or RunServerScript Check the name and that the module loaded
Function … works only on the operator screen A task or Server.SysFct called a window function The server supports tags, calculations, acknowledgement and RunScript
Database … not found in the project The name in Db.Query does not match the Databases node Check the database name
Database …: … A connection or SQL error The text after the colon comes from the database driver
File …: … Missing file, no permission or file in use Check the path; relative paths start at the project folder
Tag … has no value A function reads a tag with no reliable value Wait for communication or check .Quality
Task … skipped: server script queue is full Tasks start more often than they finish Run them less often or simplify them

Reading after writing. Writes happen after the script, so a value just passed to Write cannot be read back in the same script. Keep it in a variable.

Comparing with null. Until there is a value, .Value is null, and null > 5 is false in JavaScript. Check .Quality === "Good" before deciding anything.

Numbers from RunScript. The argument arrives as a string, so "2" + 1 gives "21". Use Number(arg).

Script versus animation. If an animation controls a colour or visibility, it overrides the script’s value at each tag update. Compare Item.Get("Fill") with Item.Actual("Fill").

Questions in a browser. After HMI.Confirm, a browser runs the script again from the start. Do not increment counters before the question.

Names assembled from parts. Tags("Pump" + n + ".Run") works, but such names are not updated automatically when tags are renamed.

Safety functions. Scripts depend on the client, the server and the network. Emergency protection belongs in the PLC.