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
jjweimer
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
YHLien
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?
YHLien
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?
jjweimer
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