Navigation: Scripting Reference Manual > Functions & Subroutines > GetGlobalVarValue

 

GetGlobalVarValue

 

Contact Us: fredsupport@photonengr.com

 

Description

This function retrieves the current value of a global variable.

 

Syntax

varVal = GetGlobalVarValue( id )

 

 

Parameters

varVal ( Variant )

Variable value returned by the function.

 

id As Long

ID number of the global script variable whose value is being queried.  If the ID number is invalid, the script is halted with an error message.

 

 

Example

The following example checks to see if a specific variable exists in the document and it is either added or retrieved from the document depending on the check.  The variable value is then modified and set back to the variable.

 

          Dim ii As Long

          Dim varVal As Double

          Dim varName As String, varComment As String

 

          ClearOutputWindow

 

          varVal = 5

          varName = "g_myGlobalVar"

          varComment = "Variable added from a script."

 

          'check if the variable already exists and either add or retrieve it

          ii = FindGlobalVar( varName )

          If ii < 0 Then

                    ii = AddGlobalVar( varName, varVal, varComment )

                    Print "Initial variable value is " & varVal & "."

          Else

                    varVal = GetGlobalVarValue( ii )

                    Print "Initial variable value is " & varVal & "."

          End If

 

          'now modify and set the variable value

          varVal = varVal + 10

          SetGlobalVarValue ii, varVal

          Print "Modified variable value is " & varVal & "."

 

 

See Also

Global Script Variables

AddGlobalVar

DeleteGlobalVar

FindGlobalVar

GetGlobalVar

GetGlobalVarCount

SetGlobalVar

SetGlobalVarValue

 

 

 

 

 

Copyright © Photon Engineering, LLC