windowglobalvalue(
WINDOW
,
VARIABLE
)

The windowglobalvalue( function accesses a windowglobal variable from other windows.


Parameters

This function has two parameters:

window – is the name of the window that contains the windowglobal variable, or if numeric, the window ID number (see Window ID Numbers). If this parameter is missing or empty (""), the current window will be used. Note: This window must currently be open!

variable – is the name of the variable you want to access. In general, this variable name must be enclosed in quotes (unless you are using a formula to calculate the name).


Description

This function makes it possible to access a windowglobal variable from other windows. (Usually these variables can only be accessed from the window in which they were created.)

This example below assumes that there is a series of windows with names that end with (1), (2), (3) etc. It scans through the windows until it finds a window where the Company variable is Apple. If it finds such a window it makes it the top window.

local wX, wName
wX=1
loop
    wName=info("databasename")+":"+info("formname")+" ("+str(wX)+")"
    stoploopif info("windows") notcontains wName
    if catcherror("",windowglobalvalue(wName,"Company"))="Apple"
        window wName
        return
    endif
    wX=wX+1
endloop

As of Panorama X 10.2, the windowglobalvalue( function now allows the window to be specified by ID number or name. Here is a rewritten version of this example using this capability.

looparray info("windownumbers"),cr(),wNumber
    let windowNumber = val(wNumber)
    if windowinfo(windowNumber,"name") regexmatch "\([0-9]+\)$"
        if catcherror("",windowglobalvalue(windowNumber,"Company"))="Apple"
            window windowNumber
            return
        endif
    endif
endloop

This second example is not tied to a particular database or form (though it could be revised to include such a tie if you wanted it to).

Note: In older versions of Panorama (version 6.0 and earlier), this function was called grabwindowvariable(. For compatibility with legacy databases, this name still works.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now allows the window parameter to be omitted (defaults to current window). Also, this function has a new name, it was formerly the grabwindowvariable( function (which still works for compatibility with legacy databases).