Use SetVariable in panel and in button
jmas340
Macro Fit (a,b)
String a,b
//Do stuff to $a,$b
Execute"PanelTest()")
End
Function ButtonProc(ba) : Button Control
STRUCT WMBButtonAction &ba
//do stuff involving setvar0
print setvar0
End
Window PanelTest : Panel
PauseUpdate; Silent 1
NewPanel /W=(200,100,1140,800) as "Data"
ShowTools/A
SetVariable setvar0, pos={100,200},size={150,20},title = "StartFreq"
//Display some graphs, all generated by IGOR
EndMacro
String a,b
//Do stuff to $a,$b
Execute"PanelTest()")
End
Function ButtonProc(ba) : Button Control
STRUCT WMBButtonAction &ba
//do stuff involving setvar0
print setvar0
End
Window PanelTest : Panel
PauseUpdate; Silent 1
NewPanel /W=(200,100,1140,800) as "Data"
ShowTools/A
SetVariable setvar0, pos={100,200},size={150,20},title = "StartFreq"
//Display some graphs, all generated by IGOR
EndMacro
When I compile the macro, the button procedure tells me there is an unknown name or symbol. So how can I pass the variables from the panel through to the function?
String a,b
//Do stuff to $a,$b
PanelTest()
End
The Execute is not needed.
Here:
STRUCT WMBButtonAction &ba
//do stuff involving setvar0
print setvar0
End
It is not clear what you intend: you can't just print a setvar by using its name.
Also, what do you want to print, the value of setvar0?
If so, use
STRUCT WMBButtonAction &ba
//do stuff involving setvar0
ControlInfo/W=$ba.win setvar0
print V_Value
End
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
July 20, 2016 at 11:16 am - Permalink
There is an if/endif section in the button proc to limit the proc to respond to a button click only. There are several other events involving the button that could call the proc... such as the mouse moving over the button.
I made some changes to the code to do this. Hope this helps.
String a,b
//Do stuff to $a,$b
PanelTest(a,b)
End
Function ButtonProc(ba)
STRUCT WMButtonAction &ba
//only respond to mouse click
if( ba.eventCode != 2 )
return 0
endif
//do stuff involving setvar0
ControlInfo/W=$ba.win setvar0
print V_Value
End
Window PanelTest(a,b) : Panel
String a, b
PauseUpdate; Silent 1
NewPanel /W=(200,100,1140,800) as "Data"
ShowTools/A
SetVariable setvar0, pos={100,200},size={150,20},value=_NUM:42,title = "StartFreq"
Button MyButton proc=ButtonProc, title="Do It!"
//Display some graphs, all generated by IGOR
EndMacro
July 20, 2016 at 01:33 pm - Permalink