Simple control panel/function example needed
daggaz
So basically instead of typing datasynthesis(param1,param2,param3,...) I would like to type GUI() --> set variables via controls --> push go button --> start datasynthesis()
Can anybody help me with that? Just a bare-bones simplified example showing proper syntax would be awesome.
On a side note, I read that you can avoid global variables (thats good, yeah?) by using the value=_NUM:<> or _STR:<> flags, instead of value=variable_name and calling that variable as global. If you do this, should the control name then be the variable name? It doesnt really give any examples here..
string CtrlName
controlinfo setvariable1 //Get parameters
variable param1 = v_value
controlinfo setvariable2
variable param2 = v_value
.
.
.
datasynthesis(param1, param2, param3,...) //call function
end
The structure of a function for a button is outlined in the manual, in addition to the controlinfo command which will retrieve the values of your setvariables. From the description of what you want, these two things should be all that you need.
August 14, 2012 at 09:54 am - Permalink
So I used the above in conjunction with this line
SetVariable/Z setvar_base_name win=controlWin, activate,bodyWidth=100,noproc, fsize = 16,size={230,100},pos={20,480}, title="Base File Name" ,value=_STR:"default"
and for some reason, I have to click on the field before I push the button, or the program fails due to a null string. This is even tho the string value is stored as "default". Is that normal behavior? It doesnt happen with the other setvariable fields containing numerical values instead of strings. In this case, I am not even using the string as of yet, it doesnt even get passed to the main program. I am using s_value not v_value, of course. Also, Im not sure what exactly "activate" does, I put that in there to see if it would fix the problem, no difference noted..
August 14, 2012 at 01:08 pm - Permalink
This (re)sets the SetVariable value on the control panel in the same function that is supposed to read the values. Why are you needing to do this? Unless I misunderstand something, you would be better to set all the setvariable values before the user hits the control button that is to activate the calculation function. Then, within that DoIt button procedure, you can just read the setvariable inputs with ControlInfo calls.
The "activate" call causes the field to be brought forward for direct input. That is one reason why you have to click on it.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 14, 2012 at 02:16 pm - Permalink
August 14, 2012 at 02:50 pm - Permalink
From your description of your desired result, this shouldn't be required in your code. Simply use the ControlInfo command to retrieve the value that was entered by the user. Also, I generally avoid using Active
August 14, 2012 at 03:29 pm - Permalink
But thanks again for the example. It works fine except for a little wierdness which I am sure is something I am doing..
August 15, 2012 at 02:59 am - Permalink