checkScript()

Checks the syntax of a script.

Synopsis

bool checkScript(string scriptstr[, int &errorPos | mapping &errorData]));

Parameters

Parameter Meaning
scriptstr Script to be checked
errorPos The position of the error - see below.
errorData You can pass a mapping which will be filled with extended info about script errors.

Return Value

TRUE if script is OK, FALSE means that the script contains errors.

Errors

Missing arguments in the function. Errors can be retrieved with getLastError(). This is also possible for a syntactically correct request (returns TRUE), but when using a variable twice.

Description

Checks a Control script that is transferred as a string variable for syntax errors. checkScript() returns "TRUE", if the script is syntactically correct, otherwise "FALSE".

Example

If the script does not contain any errors "Correct syntax" will be output, otherwise a warning is issued in a text field.

main()
{
  string script = "main(){DebugN(123)}";
  if(checkScript(script)==TRUE)
     DebugN("correct syntax");
  else
     setValue("TEXT_FIELD1", "text", "Syntax error!");
}

Assignment

Simple configuration

Availability

CTRL