the Loops
bella
My question is about the execution of procedure. Please how can i execute the different loops like DO WHILE loop, FOR loop and the conditional statments like IF-ELSE-END in the procedure programm?
thank you for your answer.
bella.
First, you might be asking a general question "Does Igor Pro have loop and conditional statements"? This implies that you know about loop and conditional statements and you just want to know where they are in Igor Pro. The answer is ... Igor Pro has all of the loop and conditional statements that you mention and then some. Please see the discussions in the appropriate sections of the User Manual (start at the index).
Second, you might be asking a different question "What is the logical and syntactically sense for us to use loop or conditional statements in a program"? This implies that you have discovered the loop or conditional statements (in the Igor Pro manual) and have no clue what they are to do and how to differentiate them from one another. For this type of question, I am afraid that you may need to study a general programming guide. The answer is what is taught in such things as introductory-level computer programming courses at universities. No disrespect to the importance of it, just a statement that this type of question generally has needs a longer response than could be given adequately in short answer format on the forum here. However, in brief ...
do - while ... means that you want to do something while a certain condition is true
for - end ... means that you want to do something with some parameter until a certain condition is true
if-else-end ... means that you want to do one thing if a condition is true and do something else if it is false
Otherwise, could you explain what is confusing you a bit better.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
September 21, 2013 at 09:19 am - Permalink
You can find information on loops and conditionals by executing these commands:
DisplayHelpTopic "Conditional Statements In Functions"
To learn Igor programming you should read all of the programming documentation:
If you have not already done the Igor Pro guided tour then I recommend doing it. It is indispensable. Choose Help->Getting Started.
September 21, 2013 at 11:04 am - Permalink
I am happy that you want to help me.
i explain myself: i wrote a programm in Igor procedure, i compiled its and i would like to execute its (by some language we just click of "run" to see what the programm is doing.) and i don't know where i can do that with the loop.
for exemple when i write a simple function which permits to great people like "Hello world!" i type PRINT "hello world" on the conditional line and saw that in the history so i call that "execute or run a function".
when i write a loop or a conditional statement i don't know if i must excute each command in the loop as in my simple function of HELLO WORLD or there are another way to do that. I rote the manuel but i didn't find how can i execute the loop without to use each command in the loop and i think that there are another way to execute them otherwise how can i do when i write a programm with many lines.
bella
September 21, 2013 at 11:05 am - Permalink
DisplayHelpTopic "The Debugger"
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
September 21, 2013 at 12:50 pm - Permalink
variable vin
do
print "Hello World!\r"
vin -= 1 // avoid infinite loop - Jim Prouty
while(vin>0)
return 0
end
Function DoFor(vin)
variable vin
variable ic
for (ic=0;ic+=1;ic<vin)
print "Hello World!\r"
end
return 0
end
Function DoIf(vin)
variable vin
if (vin>0)
print "Hello World!\r"
else
print "Goodbye Cruel World\r"
endif
return 0
end
Now you can execute DoDoWhile, DoFor, or DoIf on the command line. The variable vin is a number, so try DoDoWhile(3) or DoIf(3) or DoFor(3).
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
September 22, 2013 at 09:12 am - Permalink
For example, you have an output wave and you want to fill it with V_avg from wavestats, operating on input waves. Assuming Igor already knows about ouput_wave and input_wave_x (where x is a range of numbers)
variable i = 0
string input = "input_wave_"
string input_final = ""
string input_final = "input_wave_" + num2str(i);wavestats/q $input_final;output_wave[i]=V_avg;i+=1
Now you can just move the cursur up manually and keep entering that same line in however many times you need.. obviously if you need to do this hundreds of times you just write the procedure, but if you are quickly putting a small amount of data together in a repetitive manner, this method works in a pinch.
September 23, 2013 at 03:11 am - Permalink
but i enable the Debugger following the instructions in Manuel and the Debugger window's don't appear. however i can marke a line code with a red dot. without the window of debugger i can't execute my procedure code step by step.
what can i do please?
bella
September 24, 2013 at 01:47 am - Permalink
One reasonable way to execute a function step-by-step is to put a "red dot" at the first line in the function. The debugger will open immediately. You can then step through your function.
Alternatively, you can put a PauseForUser command between each line of code.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
September 24, 2013 at 12:22 pm - Permalink
September 24, 2013 at 06:19 pm - Permalink
so i would like to execute the following procedure step by step. using the Debugger as in the manuel the Debugger window's doesn't appear. please how can i execute it? may be there is another way and i don't know.
#pragma rtGlobals=1 // Use modern global access method.
function initmodel(ctrlname) : ButtonControl
string ctrlname
nvar nx1, nx2, nx, dd, dd1, dd2, iixx //in cm
wave xLine, LineR
Make/D/O/N=(nx1+nx2+1) dx, xx // Erzeugen der Waves
nx=nx1+nx2
dx[0,nx1]=dd1/nx1 // Abständer dx1 und dx2
dx[nx1+1,nx]=dd2/nx2
iixx=0
for (iixx=0; iixx<=nx1; iixx+=1)
xx[iixx]=iixx*dx[iixx]
Endfor
for (iixx=(nx1+1); iixx<=nx; iixx+=1)
xx[iixx]=xx[nx1]+(iixx-(nx1))*dx[iixx]
Endfor
xLine=xx[nx1] // X-Position der vertikalen Trennlinie
LineR=xx[nx]
End
bella.
September 25, 2013 at 05:26 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 25, 2013 at 09:58 am - Permalink