script directive allows in the script to affect its usage in the PROMOTIC system and also eventually to modify the script content.
directive is processed while the script is being translated which is the main difference compared to the calling the methods on the script launch. In case of the Web application, the scripts are running on the client side, but the
directive processing is done on the server side and the client gets the processed script.
directive is then removed from the script. The original
directive can be replaced by a new code, that can be a result of processing the corresponding
script directive is always placed in the script comment, i.e. in
#pragma variable
It is used for the modification of current script, it means that a new code, the result of corresponding
#pragma directive evaluation, is inserted into the script.
This script directive inserts a code into the script, and in the script creates a local variable with corresponding name (by the statement
var for
JavaScript or
Dim for
VBScript) and then a code for variable initialization, that enters the desired value into the variable (the value can also be a reference to an object).
The inserted code created by evalueating the same
#pragma directive in the same script may differ, for example, a local panel script compared to a
Web panel script.
This type of
#pragma directive makes the scripts more transparent, allows to systematically manage the object references and also allows to manage some differences between local and
Web panels.
#pragma variable x = Macro("macro expression"):
It allows to evaluate the macro expression. It creates a local variable in the script and sets its original value to result of the macro expression evaluation. It is used especially for loading the localized text (
Macro expression $.text). In case of a Web application, the expression is evaluated on the server, therefore the
#pragma directive evaluation can access the data and files of the server.
For example
'#pragma variable sComment = Macro("$.text('sys','comment')")
Another way to obtain the localized text is to use
Macro expression $.text or
EvalMacro.
#pragma variable x = PmaObjectRef("path"):
It allows to get the
reference to an Pma object in the
Pma object tree or its implementation subobject. It creates a local variable in the script and sets its original value to a reference to desired object.
The reference to the object obtained this way is handy because it is known in the development environment
PROMOTIC, it means that the PROMOTIC system knows about this reference and the type of the referred object, that will one day allow to add intelligent help in the script editor, listing the object methods, properties, etc.
For obtaining the object on a dynamic path (unknown in advance), serves the
PmaObject.Pm method.
For example
'#pragma variable oTemperature1 = PmaObjectRef("/Block1/Data/#vars/Temperature1")
For example
'#pragma variable oTemperature1 = PmaObjectRef("../Data/#vars/Temperature1")
#pragma variable x = PmgObjectRef("path"):
It allows to get a
reference to a Pmg object or its implementation subobject in the panel. It creates a local variable in the script and sets its original value to a reference to desired
Pmg object or its implementation subobject This script directive is functional only in panel scripts (
Pmg object events).
The reference to the object obtained this way is handy because it is known in the development environment
PROMOTIC, it means that the PROMOTIC system knows about this reference and the type of the referred object, that will one day allow to add intelligent help in the script editor, listing the object methods, properties, etc.
For obtaining an
Pmg object on a dynamic path (unknown in advance), serves the
PmgObject.Items method.
For example
'#pragma variable oEdit0 = PmgObjectRef("../edit0")
For example
'#pragma variable oTemperature1 = PmgObjectRef("../edit0/#vars/Temperature1")
#pragma option
It is used for affecting the way the PROMOTIC system uses the script, it means that it sets some parameters of the PROMOTIC system. The script content is not modified (with the only exception of removing the
#pragma directive itself).
#pragma option OldGlobalMethodCall:
It allows to switch on the old way of global method calling, where the global methods are colled in the script directly by its name (the same way as functions of the
VBScript language). However this way is not compatible with Web applications. The new way requires to call the global methods by
Pm.Methods. This script directive is meaningful only for global methods of the application. If not set (or if the
0 value is used), then the new way of global method calling is used as default.
Syntax: '#pragma option OldGlobalMethodCall = 0/1
where 0 (default) is the ne way and 1 is the old way.
For example
'#pragma option OldGlobalMethodCall = 1
An example of calling the
Test global method with two parameters in the script directly by the
old way:
v = Test(5, 8)
An example of calling the
Test global method with two parameters in the script directly by the
new way:
v = Pm.Methods.Test(5, 8)