PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
5.58. REPEAT … UNTIL<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerSyntax :REPEAT ConditionInstructionsInstructionsUNTIL ConditionorREPEAT { Instructions : } UNTIL ConditionOverview :Execute a block of instructions until a condition is true.Example : Var = 1REPEATPRINT @Var , ” “INC VarUNTIL Var > 10orREPEAT HIGH LED : UNTIL PORTA.0 = 1‘ Wait for a Port changeNotes :REPEAT-UNTIL, repeatedly executes Instructions UNTIL Condition istrue. When the Condition is true, execution continues at the statementfollowing the UNTIL. Condition may be any comparison expression.The REPEAT-UNTIL loop differs from the WHILE-WEND type in that,the REPEAT loop will carry out the instructions within the loop at leastonce, then continuously until the condition is true, but the WHILE looponly carries out the instructions if the condition is true.The REPEAT-UNTIL loop is an ideal replacement to a FOR-NEXTloop, and actually takes less code space, thus performing the loopfaster.Two new commands have been added especially for a REPEAT loop,these are INC and DEC.INC. Increment a variable i.e. VAR = VAR + 1DEC. Decrement a variable i.e. VAR = VAR – 1The above example shows the equivalent to the FOR-NEXT loop: -FOR VAR = 1 TO 10 : NEXTSee also :IF-THEN, WHILE-WEND110Copyright Crownhill 2001