krn.RunScript

Executes a VBScript or JavaScript on the server. The script text is determined in the following order: parameter Script, parameter ScriptFile, file list.

If the script is empty and only parameters are passed, only the server-side before/after events are triggered.

This is a generic job: any input parameters can be passed and the server can return any output parameters and files.

1. Input Parameters

Name Type Required Description

Flags

INT

Yes

Currently not supported — pass 0.

Script

STRING

Yes

Script text to execute. Can be empty if ScriptFile or the file list is used, or if only events should be triggered.

CtxName

STRING

Yes

Context name. Empty = default name is used.

GUI

BOOLEAN

Yes

true = MsgBox may be called from the script (depends on server environment). false = not allowed.

Eval

BOOLEAN

Yes

true = the script text is evaluated as an expression (Eval). false = the script text is executed as a function block (Exec).

[IsJS]

BOOLEAN

No

true = JavaScript execution. false or not specified = VBScript execution.

[Main]

STRING

No

Name of the entry point function. Default: Main.

[ScriptFile]

STRING

No

Name of a script file in the scripts subdirectory of the server configuration. Used when Script is empty.

[ScriptName]

STRING

No

Name of the script for debugging purposes.

[InspectorEnabled]

INT

No

V8 inspector control (JavaScript only). 0 = disabled, 1 = enabled, -1 = controlled by oxv8.metadata.cfg (default behavior when not specified).

any

any

No

All additional parameters are forwarded as input parameters to the job and the server-side events.

2. Input Files

Any files can be passed. The script or the server-side events can process them and return custom files in the response.

3. Output Parameters

Name Type Description

$ScriptResult$

variable

Return value of the script. The type depends on the script (INT, STRING, FLOAT, BOOLEAN, etc.). Not always present.

any

any

The script and the server-side events can set any additional output parameters.

4. Eval and Exec

Exec mode (Eval=false): The script is executed as a function block. The return value of the entry point function (default: Main) is returned as $ScriptResult$.

Function Main()
    Main = 42
End Function

Eval mode (Eval=true): The script text is evaluated as an expression. The result is returned as $ScriptResult$.

5. Return Value

(INT): 0 = Job successful, otherwise error code.

If all logic resides in server-side before/after events and no script text is needed, prefer using krn.EmptyJob instead.

6. See Also

krn.EmptyJob — Generic job without script execution, controlled only via events.