Description This subroutine retrieves the name, value and comment for the requested global script variable.
Syntax GetGlobalVar id, varName, varVal, varComment
Parameters id As Long ID number of the global script variable being queried. Global script variable IDs are zero-based such that the first variable has ID = 0. If an invalid id is used, the script will be halted with an error.
varName ( String ) String name of the global script variable returned by the subroutine.
varVal ( Variant ) Value of the global script variable returned by the subroutine.
varComment ( String ) Comment of the global script variable returned by the subroutine.
Example The following example prints out information for all global script variables, checks a specific variable for existence in the document and either deletes it or prints it's status to the output window.
Dim ii As Long Dim varName As String, varComment As String Dim varVal As Variant
ClearOutputWindow
'get the starting number of variables, loop over each and print its information Print "There are " & GetGlobalVarCount() & " global script variables in the document at start." Print "Current variables are: " For ii = GetGlobalVarCount()-1 To 0 Step -1 GetGlobalVar ii, varName, varVal, varComment Print Chr(9) & varName & " = " & varVal & " ( " & varComment & " ) " Next ii
'check if a variable exists in the document and delete or print status ii = FindGlobalVar( "g_temp" ) If ii > 0 Then DeleteGlobalVar ii Print "There are " & GetGlobalVarCount() & " global script variables in the document after deletion of g_temp." Else Print "g_temp not found, document was not modified." End If
See Also
|