the Loops

Hello ,
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.
I understand your question on two levels.

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
bella wrote:
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?


You can find information on loops and conditionals by executing these commands:

DisplayHelpTopic "Loops"
DisplayHelpTopic "Conditional Statements In Functions"


To learn Igor programming you should read all of the programming documentation:
DisplayHelpTopic "Igor Pro Programming"


If you have not already done the Igor Pro guided tour then I recommend doing it. It is indispensable. Choose Help->Getting Started.

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
To execute the statements in a function or macro one at a time, use the Debugger.

DisplayHelpTopic "The Debugger"

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Open the Procedure window. Put the following functions inside and recompile.

Function DoDoWhile(vin)
   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
Another way to 'program' in the command line using loop logic is to stack your loop commands on one line using the ";" symbol, after first initializing the needed variables also in the command line.

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.
Thanks for your Help,
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
bella wrote:

... without the window of debugger i can't execute my procedure code step by step.
what can i do please?


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
After setting the breakpoint you have to run the function (e.g., from the command line). The debugger window will appear when Igor hits the breakpoint. Then you can single-step.

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.
It appears your function is the action procedure for a button in a control panel. Assuming you have the control panel displayed, after you place the breakpoint in the code, you should click the button. That will cause the code to run, and the debugger window will pop up at the appropriate moment.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com