newObjects-logo.gif (1024 bytes) ScriptAggregate reference
AddTextEx method

Adds script code to a loaded engine. AddEngine must be called before any successful calls can be made to this method.

variable = object.AddTextEx(language, code[, lineNumber [, context [, contextItem]]])

variable Boolean true if the operation was successful and false if not. Inspect lastError property for the error description - typically this will be a compilation error.
object ScriptAggregate Previously created ScriptAggregate object
language string Script language name of the added source code. AddEngine must be previously called with the same language.
code string Script text being added
lineNumber long integer default is 0 (matches the behavior of AddText). If specified the added script will be assumed to start at the line number specified. This will correspond to the line number reported in any script error caused by this chunk of script text.
context long number default is 0 (matches the behavior of AddText). Specifies a context cookie number (see remarks).
contextItem String The name of an item that gives the context in which the source will be evaluated (recommended only for advanced tricks). Default is empty string - global context (as like in the AddText method)

Remarks:

lineNumber and context parameters are a technique to keep track of the code added to the script engine. The engines separate the script code in context blocks and context parameter specifies the ID of the context block. Line numbers in each block are independent thus you may have several scripts with independent line numbering added under different context IDs. This will allow better identification of the error source.

For example if you want to add script code from several text files you are able to keep the names of the files in array and pass as context ID the index of the file in the array. Then script errors reported will contain the context ID which will help you to identify the correct file containing the line of the script that actually caused the error.

Code must contain full "closed" script blocks. In other words you can not add the first half of a function and then the second with later call to this method. You can call this method many times. Thus realization of the includes or another needed features can be realized

See also:

newObjects Copyright newObjects 2001-2005