Scripts
|
Top |
· | Local variables are created with SetVar( ) function -- they do not exist in the current expression's execution space before that.
|
|
· | Local variables exist as long as you're within the same Expression execution cycle where they're created, or at any level of CallScript, Macro, Eval, etc. executed within that same Expression. They are unique to that Expression -- e.g. a local variable created in a Query's Data expression will not exist for any other expression executed separately such as the Query's Filter expression (and thus will also not conflict with local variables by the same name in other Expression spaces).
|
|
· | Any local variable that exists before the Script is invoked with CallScript is copied into the Script, and its value is also copied back out (it can be changed inside the Script).
|
|
· | Any local variable that does not exist before the CallScript but is created within the Script is destroyed before CallScript returns. It will exist for the life of the Script, since each Expression line is parsed and executed within the same execution space.
|
|
· | These rules apply for any depth level of script calling -- e.g. every CallScript creates a new level of variable scope, with any existing variables copied into it and back out of it.
|
SetVar( "nResv", NumTran( ThisResv() ) )
|
SetVar( "bFound", .F. )
|
SetVar( "r", 1)
|
; Verify that this reservation contains this transaction
|
WHILE r <= nResv AND !bFound
|
IF ResvTran(r) = ThisTran()
|
SetVar( "bFound", .T.)
|
ENDIF
|
SetVar( "r", r+1)
|
ENDWHILE
|
|
.......
|
|
IF CCNum != ""
|
REM always need at least 2 lines
|
SetVar("nLines", 2)
|
|
IF C(Macro("TranCCAuth", "ThisTran()")) = "Y"
|
SetVar("nLines", nLines+1)
|
ENDIF
|
|
// Need more lines if a signature is shown
|
IF SettingLocalBool("Print", "PrintShowCCSigLine")
|
SetVar("nLines", nLines+7)
|
ELSE
|
SetVar("nLines", nLines+2)
|
ENDIF
|
ENDIF
|