
Simple String Input for Panel

geologic
http://www.igorexchange.com/node/5588
and modified it a little, to have the below. It makes a simple panel with functional button and non-functional string input.
I'm not familiar with panel coding, and am not sure why the string gets erased after I type in the sample entry.
Menu "Analysis" "Open Calculate Panel",/Q, OpenCalculatePanel() End Function OpenCalculatePanel() DoWindow/K CalculatePanel Newpanel /W=(248,115,730,626)/N=CalculatePanel // apear the panel modifypanel cbRGB=(0,39168,39168),fixedsize=1 //color of panel showtools /A setdrawlayer/K userback Setdrawenv fsize=20,fstyle=1,textrgb=(65535,65535,65535) drawtext 115,32,"Load Files and Parameters" //drawpict 2,2,2,1,1 //no: 4 numbers and a picture name are needed here Button button1,pos={160,165},size={161,35},proc=buttonproc,title="Load Waves" SetVariable sample_name title="sample ",size={200,136},pos={136,100},proc=setvariableproc Endmacro Function ButtonProc(ctrlname) : ButtonControl string ctrlname Print "Button pressed" // Call your calculate routine here End Function setvariableproc(ctrlName) : setvariablecontrol String ctrlName Print "Button pressed" // Call your calculate routine here End
The error is "expected right parenthesis." I can't find a left parenthesis that is unaccounted for...
May 21, 2016 at 12:08 pm - Permalink
Learn to use the new structure forms of the controller functions. They are generated automatically when you press the New button on the edit dialog box for the control itself.
Your code was missing an assignment for the value for the setvariable.
Edit: Fixed to show string variable not number value
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 21, 2016 at 05:05 pm - Permalink
I've documented my understanding of some of the code. I've also simplified to get at what I would like my button to do: make a string in root and call another function. It works!
May 23, 2016 at 09:08 am - Permalink
Thanks a lot for the starter code and for pushing me to use STRUCT framework. The ability to pull values from the input is convenient!
May 23, 2016 at 09:41 am - Permalink
I recommend not to store switch values in globals when you can instead get their values as needed with ControlInfo.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 23, 2016 at 11:22 am - Permalink
This is the WaveMetrics internal structure for button actions. Its storage location is "pointed to" by the reference &ba.
A pointer &ba is an address to the location of the WMButtonAction structure. The structure has all the values (strings, numbers, titles, mouse states ...) in it. The function call looks up the address &ba, goes to it, and reads the values in the (well-defined) WMButtonAction structure.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 23, 2016 at 11:28 am - Permalink
Yeah, I've been learning about this today. I like this feature! I don't exactly understand the syntax, with the ampersand and stuff...but if I take it as a given, everything is going smoothly. And I've been able to extract other values as well.
May 23, 2016 at 03:44 pm - Permalink
I responded to this in a separate thread, because I think it's a separate topic: http://www.igorexchange.com/node/7118
Thanks for the advice...see what I did there and let me know if I'm headed towards a dead end with the way I use global strings and variables. I *think* I'm safe, but I'd like to hear what you guys think.
May 23, 2016 at 03:47 pm - Permalink