Navigation: Scripting Reference Manual > Functions & Subroutines > FindGlobalVar

 

FindGlobalVar

 

Contact Us: fredsupport@photonengr.com

 

Description

This function returns the ID number corresponding to the name of the global script variable.  If the variable name is not found, a value of -1 is returned.

 

 

Syntax

id = FindGlobalVar( varName )

 

 

Parameters

id ( Long )

ID number of the global script variable returned by the function.  A value of -1 indicates that there was no variable with the corresponding varName.

 

varName As String

Name of the global script variable whose ID number is being requested.

 

 

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

Global Script Variables

AddGlobalVar

DeleteGlobalVar

GetGlobalVar

GetGlobalVarCount

GetGlobalVarValue

SetGlobalVar

SetGlobalVarValue

 

 

 

 

 

Copyright © Photon Engineering, LLC