Table of Content
HAL Forum
Part 1: Declarations, assignments and statements

Declarations and Statements
Here are examples of how declarations, assignments and statements are created in HAL.


  /********************************************************************************/
  /* Declarations of variables                                                    */
  /* All variable declarations in a procedure or function must be done before     */
  /* anything else.                                                               */
  /********************************************************************************/
  integer a,b,c;    /* declararion of integers                                    */
  string 60 str;    /* declararion of a string of lenght 60                       */
  val v;            /* declaration of a value, large decimal value                */
  longint d;        /* declaration of a long int, large value without decimals    */
  boolean f;        /* declaration of a boolean, can either be true or false      */
  date d;           /* declaration of a date                                      */
  
  

  /********************************************************************************/    
  /* Assignments                                                                  */
  /********************************************************************************/  
  a = 3;                    /* assign a value to a variable                       */
  b = 5;
  c = a + b;
  str = "Hello!";
  str = str & " Hello!";    /* concatenate two strings                            */
  v = 12323897.98834994;
  f = true;



  /*********************************************************************************************/      
  /* Statements                                                                                */
  /*********************************************************************************************/  
  /* Example of if statement                                                                   */
  /* The double equal sign means that we compare two values. In the if statement you can       */
  /* also use other operators as "<" smaller than, ">=" lager or equal to etc. Many conditions */
  /* can be put together separated by OR or AND. See the matematical operators for a complete  */
  /* list. The second section of the if statement after the first end key word is optional.    */
  /*********************************************************************************************/  
  if(a == 3) then begin
      /* Code to be executed if a is equal to 3 */
  end else begin
      /* Code to be executed if a is not equal to 3 */
  end;
  
  
  /*********************************************************************************************/  
  /* Example of switch statement                                                               */
  /* Can also handle stings.                                                                   */
  /*********************************************************************************************/  
  switch(a) begin
    case 2:
      /* Code to be executed if a is equal to 2 */
    case 3:
      /* Code to be executed if a is equal to 3 */
    otherwise
      /* Code to be executed if a is not equal to 2 or 3 */
  end;
  
  /*********************************************************************************************/  
  /* Example of for loop                                                                       */
  /*********************************************************************************************/    
  for(a = 0; a < 10; a = a + 1) begin
    /* Code to be repeated 10 times */
  end;

  /*********************************************************************************************/      
  /* Example of while loop                                                                     */
  /*********************************************************************************************/    
  a = 0;
  while(a < 5) begin
    /* Code to be repeated 5 times */
    a = a + 1;
  end;