executeScript

executeScript(methodName:        String;
              schemaType:        Type;
              schema:            Schema;
              sourceCode:        String;
              isWorkspaceMethod: Boolean;
              returnType:        Type;
              errorCode:         Integer output;
              errorPosition:     Integer output;
              errorLength:       Integer output;
              receiver:          Any;
              params:            ParamListType): Any;

The executeScript method of the Process class executes a Jade script and provides a wrapper method for calling the createTransientMethod, executeTransientMethod, and deleteTransientMethod methods to compile and execute Jade method source code.

This method returns the result value returned by the executed method.

The method is executed as part of the current Jade process and any references to system variables (for example, app) reference those for the application that is currently running.

The executeScript method parameters are listed in the following table.

Parameter Description
methodName The name of the method to be created. For non‑Workspace methods, this parameter must match the method name specified in the signature in the source code.
schemaType The owner type, or owner root type, of the method (that is, the type of the method receiver) and it is the type of the self system variable.
schema The schema against which the method is to be compiled and which is searched when resolving the names of classes referenced in the method.
sourceCode The method source code to be compiled.
isWorkspaceMethod Specifies whether the source code is in Jade Workspace format (that is, it has no method signature). Jade Workspace format transient methods cannot update the receiver directly.
returnType Specifies the type of the result value returned by Workspace methods. For non-Workspace methods, this parameter is not used and the return type is specified in the method signature in the source code.
errorCode The error code returned by the compiler. A value of zero (0) indicates that the method was compiled successfully.
errorPosition The position of the error in the source code. Note that the first character of the source code has a position of zero (0).
errorLength The length in characters of the error in the source code.
receiver The receiving object or primitive type.
params Maps to a variable list of zero or more parameters of any type that are to be passed to the method that is executed. (The ParamListType pseudo type can be used only as a formal parameter in a method signature. You cannot define a local variable with a type of ParamListType.)

For details about the ParamListType pseudo type specified in the last formal parameter (params), see "ParamListType" under "Pseudo Types", in Chapter 1 of the Developer's Reference. See also "Passing Variable Parameters to Methods" under "Jade Language Syntax", in Chapter 1 of the Developer's Reference.

If the source code does not compile successfully, the error parameters return compiler information that indicates the cause of the error. The following example shows the use of the executeScript method to perform a calculation entered by the user. (For example, an input of '2*3+1' would display the value '7'.)

vars
    input, str    : String;
    err, pos, len : Integer;
    result        : Any;
begin
    read input;
    str    := "return " & input & ";";
    result := process.executeScript("calc", self.class, currentSchema,
                                    str, true, Any, err, pos, len, self);
    if err = 0 then
        write result;
    else
        write "Compiler error " & err.String & " - " &
               process.getErrorText(err);
    endif;
end;