Is it possible to access the global string variable in button triggered function?

I wrote a very simple function to pass the name of the button to main program. The following is the function

Function Panel_Dismiss(name) : ButtonControl

String name

SVAR temp = root:GUI:G_name_control

temp = name
DoWindow /K control

End

But only null string was passed back. I tried to used the debugger to check and found the content of "name" was correct but "temp" was always null string.

Any suggestion for my problem? Thanks in advance.

Yu-Hung Lien
Sounds to me like your global variable does not exist.

The null showing in the debugger indicates the SVAR lookup failed, not that the contents are null.

YHLien wrote:
I wrote a very simple function to pass the name of the button to main program. ....


Also, following up to Larry's post, the preferred way to do what (I think) you want is to use Structures in the button function.

Function MyButton(bc) : ButtonControl
    STRUCT WMButtonAction $bc

    print "The name of this button is ", bc.ctrlName
    print "It is in the window ", bc.win
 
   return 0

end


Do a SEARCH using the Igor Help Browser for the topic "ButtonControl AND WMButtonAction" within 2 paragraphs of each other for further details.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
Thanks for your suggestions

It is somewhat strange. It behaves right after I restarted the Igor program.

However, I still don't have a correct value in Data Browser.

Any further suggestions?
Dear jjweimer,

Thanks for your suggestion. I tried to follow your post but I am still confused by the usage of WMButtonAction structure. It seems that the structure variable "bc" can be only used within the scope of the function "MyButton". How should I do to access "bc" outside the function besides by global variable?
Are you trying to store the name of the control into a global string so that you can get access to it from somewhere else? Try

Variable/G root:ActivatedButton = bc.ctrlname


John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
YHLien wrote:
Dear jjweimer,

Thanks for your suggestion. ... How should I do to access "bc" outside the function besides by global variable?


The parameters within the button control structure are only defined within the function. To know of their value "outside" of the button control function requires either that you store them in globals or store them in a file. In either case, they are then available outside the scope of the function. This holds true for all types of controls (buttons, checkboxes, listboxes, popups ...).

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH