![]() |
![]() |
![]() |
DelphiWebScriptExternal Variables |
|
![]() |
Homepage DWS ![]() |
Global Variables and ConstantsGlobal variables and constants are valid in all scripts you compile. Assumed you're using color constants in all of your scripts: const red = $FF0000; In this case it's advisable to use global constants instead of adding the constant declarations to each script. Add the following lines to the initialization section of your Delphi form: script1.setGlobalConst ('red',
$FF0000); Global Variables can be used to transfer data from one script to another. Finding Variables and ConstantsYou can find variables and constants by specifying their name or by a numerical index. The following functions all return a TDataItem object in success. GetGlobal (nam :
string) : TDataItem; GetGlobalIndex (i :
Integer) : TDataItem; Globals[i : Integer]
: TDataItem; GetVar (nam : string)
: TDataItem; GetVarIndex (i :
Integer) : TDataItem; Vars[i : Integer] :
TDataItem; Deleting Global Variables and ConstantsDeleteGlobal (nam :
string); DeleteGlobals; The Method SetVarTo change variables in OnEval events use the method SetVar of the TDelphiWebScript component. It only makes sense to use this method if a script is running and the variable appears in the script code. |