Is it possible to access the global string variable in button triggered function?
YHLien
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
The null showing in the debugger indicates the SVAR lookup failed, not that the contents are null.
November 20, 2009 at 02:01 pm - Permalink
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.
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
November 20, 2009 at 02:05 pm - Permalink
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?
November 20, 2009 at 02:31 pm - Permalink
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?
November 20, 2009 at 03:07 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
November 20, 2009 at 03:45 pm - Permalink
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
November 20, 2009 at 03:18 pm - Permalink
Thanks! That is exactly what I am thinking.
November 20, 2009 at 03:53 pm - Permalink