Passing variables between functions in a gui
kathreen
I have tried using setvariable svBolo_ShotNumber variable=plasmashot but have been unsuccessful
Below is a snippet of the code.
function BoloGui() //Creates the gui
variable/G PlasmaShot
variable/G VACShot
SetDrawEnv fillbgc=(65000,65000,65000)
NewPanel/N=BolometerProcessorPanel /K=1 /W=(389,58,1360,596) as "Bolometer Processor"
SetVariable svBolo_ShotNumber,pos={70,9},size={136,21},proc=BoloSetVarProc, title=" Plasma Shot"
SetVariable svBolo_ShotNumber,fSize=14
SetVariable svBolo_ShotNumber,limits={-inf,inf,0},value= ShotList,bodyWidth= 100
SetVariable svBolo_ShotNumber proc=BoloSetVarProc,value=_NUM:0
SetDrawEnv fsize=10
button disp_intensity, pos={400,10}, size={130,30}, proc=BoloDispIntensity, title="Display Intensity"
end
function BoloSetVarProc(sva) : SetVariableControl //Executes upon entering the information in a fill box
STRUCT WMSetVariableAction &sva
variable plasmashot
switch( sva.eventCode )
case 1: // mouse up
case 2: // Enter key
case 3: // Live update
Variable dval = sva.dval
String sval = sva.sval
plasmashot=str2num(sval)
break
endswitch
return 0
end
function BoloDispIntensity(ba) : ButtonControl //Executes upon the push of a button
STRUCT WMButtonAction &ba
variable plasmashot
print plasmashot
switch( ba.eventCode )
case 2: // mouse up
// click code here
// print num2str(plasmashot)
// print num2str(vacshot)
// boloDiffs(PlasmaShot,VACShot)
break
endswitch
return 0
//print num2str(plasmashot)
//print num2str(vacshot)
end
(BTW, use <igor> to embed code in an IgorExchange window. Use </igor> at the end to stop embedding.)
As you have written it, this:
variable/G VACShot
creates globals in the current data folder. You probably want to always create the globals in the root data folder, so do this:
variable/G root:VACShot
(For more on storing package globals, execute DisplayHelpTopic "Managing Package Data")
This next line should either be removed or placed after NewPanel:
You set the SetVariable to be connected to the ShotList global with this command:
but you override that and set it to use internal storage with this command:
The latter technique is generally better. If you use the internal storage you can read the value later using ControlInfo.
In your second and third procedures, you write this:
That creates a local variable in the function that has nothing to do with the plasmaShot global you created in the first function. Instead you need to write this:
However, if you use the internal storage method for SetVariable, you won't need either global. This is why internal storage is a better technique.
June 19, 2010 at 05:04 pm - Permalink
June 23, 2010 at 07:37 am - Permalink