Posts

Showing posts with the label Loops

CASE

CASE Loop or Statements CASE Loop or statements is a conditional statement.  Like IF loop or statement these also works in the manner that once the statement is true then some statements are executed other wise the else part will be executed. But in the case of CASE we can consolidate muliple levels of IFloops in one CASE. Some programming languages like C its called as SWITCH - CASE loop but in Navision or Microsoft Dynamics NAV we called this as CASE only. Syntax of CASE  -----------------------------------------------------------         CASE Expression OF                Value Set 1 : Statement 1;                Value Set 2 : Statement 2;                  ...                Value Set n : Statement n;               ELSE Statement n+1;          END   ----------------------------------------------------------- A sample program for the CASE is as follows ==============================================================      CASE Color OF            Color :: Orange:                        ...

WITH Loop / Statement

WITH Loop / Statement WITH Statement or loop is used to make record variables easier.  Record variable is a complex datatype with one variable we can store multiple values like arrays. Each record having different fields and each of these fields can able to store different data types also. These fields are separated by the ' . ' or dot sign. If a customer record having field named Name then it can be specified like customer.Name Syntax Of WITH Loop Suppose we having three fields names name, address and City then it can be specified in the recod named customer as folows      customer.Name := Txt[1];      customer.Address := Txt[2];      customer.City := Txt[3]; We can sort these kind of representation in the system different way so that we can minimise the number of codings that syntax of WITH Loop is as follows ----------------------------------------------------------------------------            WITH Record Variable DO Statement ---------------------------------------------...

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.