Posts

Showing posts with the label Repetitive Statements

FOR Loop

FOR Loop or FOR Statement In Microsoft Dynamics NAV Definition FOR loop is a repetitive statement or loop, is used when we need to execute the code a predetermined number of times.  FOR Loop in Microsoft Dynamics NAV, C/AL having mainly 2 types FOR .. TO Loop FOR .. DOWNTO Loop FOR .. TO Loop In the case of FOR .. TO Loop the value checking is incresed format and when the value reach the condition wrong then exit loop. Syntax of FOR .. TO Loop: -------------------------------------------------------------- FOR Control Variable :=   Start Value TO End Value DO Statement -------------------------------------------------------------- Here Control Variable must be a variable type of Boolean, Date, time or any numeric type. The Start value and End Value must be either expressions of same data type. For Example: =========================================== FOR i :=1 TO 5 DO     Result := Result + 5; =========================================== In this programming codes works in a manner that...

REPEAT - UNTIL Loop

REPEAT - UNTIL Loop or Statement In Microsoft Dynamics NAV C/AL Definition REPEAT - UNTIL Loop is a repetative loop, is used for programmes having one or more statements to be executed until some condition. Syntax OF REPEAT - UNTIL Loop --------------------------------------------------- REPEAT Satements UNTIL Boolean Expression --------------------------------------------------- This works in a manner like that it will work the statements until the Boolean Expression is true. The difference Between WHILE-DO loop is that the REPEAT - UNTIL Loop will execute atleast one time and then only it will check the Boolean expression true or false. But in the case of WHILE-DO loop only execute the code when a particular condition is true. For Example: ======================================= REPEAT i :=  i + 1; Total Sales := Total Sales + Sales[i]; UNTIL Sales[i]=0; ======================================= The abow example works in a manner like that it will execute the statement once after tha...

WHILE .. DO Loop

WHILE .. DO Loop or Statement In Microsoft Dynamics NAV C/AL Definition The WHILE .. DO Loop is a repetitive statement or loop, is used in the program where a certain code is to be executed as long as some condition is true. Syntax Of WHILE .. DO Loop ----------------------------------------------------- WHILE Boolean Expression DO Statement ----------------------------------------------------- This is simpler than the IF loop. In the case of  WHILE .. DO Loop the system check continously the boolean expression become true then the statement between BEGIN and END execute otherwise move to next statement. For Example: ================================================== WHILE Sales[i+1] 0 DO BEGIN      i := i + 1;      Total Sales :=  Total Sales + Sales[i]; END; ================================================== This is work in a manner like that check every time the Sales[i+1] 0 and if the condition is true then execute the statement between BEGIN and END other wise execute after t...

Repetitive Statements or Loop

Repetitive Statements or Loop Repetitive Statements or Loops are using when we want to execute one statement or more than one statement multiple times. In the case of IF loop it will work only for one time execution only. So if the user need to execute a statement more than one times based upon some condition.  All the repetitive statements are works in a manner like that it will work repetedly until one condition satisfy and if that condition appear then it moves the control to next programming satement after the repetitive statements. And in the case of repetitive statements always having initialize variable and increment values will appear.  Some of the Repetitive statements are IF Statement, WHILE .. DO, REPEAT .. UNTIL etc.