
Q: About "DoPrompt" with variable numbers of parameters

yaohualiu
For examples:
I have a string contains a list of wave names, like "wave0; wave1; wave2;". For each wave, I want an input from the user. The interface will be much simple if I can do DoPrompt for all the waves at a single window. I firstly tried to use Prompt in a "For, Endfor" Loop and pass a data point of one wave to each Prompt, however it does not work. I.e. I can not do thing like this // Prompt INPUTWAVE[index], "input a numer" //
I also tried to make a string variable, // STRING Localstring="input"+index // and want to claim a numerical variable with the name same as the string content (inside the loop). In this way , I can pass the numerical variable to PROMPT. However it do not allow me to do so.
Below is a FAILED example"
Function test(datawavelist)
String datawavelist
Variable waveindex
String CMD="DoPrompt \"Please Input \" "
For (waveindex=0; waveindex < itemsinlist(DataWaveList); waveindex +=1)
string Input = "input"+num2str(waveindex)
Variable $Input //ERROR
// Igor does not allow me to do this. A string can not be a variable name. Do not know how to do this.
String Promptcmd
Sprintf Promptcmd, "Prompt %s, \"Input for Data Wave %s\" ", Input, stringfromlist(waveindex, Datawavelist)
Execute Promptcmd //ERROR
// Here is the problem, the variable is not claimed"
String subcmd
sprintf subcmd, ", %s", Input
CMD += subcmd
Endfor
Execute CMD
End
August 3, 2009 at 01:53 pm - Permalink
This is nice, however has a very clear limitation. The maximum number of items is fixed. It may cause a trouble if the number of the waves varys from 1 to 100. :-)
I need someway to create variables in a LOOP and these variables have the memory of in which loop they are created, basing on their name. That is why I tried to pass a data point of a Wave to the PROMPT cmd.
August 3, 2009 at 02:21 pm - Permalink
True, but keep in mind that DoPrompt itself can only be used to prompt the user for up to 10 variables. So if you really have up to 100 waves what you want to do isn't possible using DoPrompt. I think you would need to make a panel (perhaps with a list box) instead.
August 3, 2009 at 03:00 pm - Permalink
How about prompting for a string list and then parsing ...
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
August 3, 2009 at 03:33 pm - Permalink