Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - logical boolean data type http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 logical             Boolean data type
------------------------------------------------------------------------------
 Syntax
   logical

 Arguments
   None.

 Features
   +----------------------------------------------------------------------+
   | Category             | boolean                                       |
   | Size                 | 2 bytes                                       |
   | Range                | .f. or .t.                                    |
   | Parameter: value     | yes                                           |
   | Parameter: reference | yes                                           |
   | Parameter: const     | yes                                           |
   | Return               | yes                                           |
   +----------------------------------------------------------------------+

 Description
   The logical data type stores only one of either of the two
   boolean values TRUE or FALSE. TRUE is represented by the constant
   identifier .t. and .T., while FALSE is represented as .f. and .F.
   Variables of the logical data type may be assigned to the respective
   values. Logical variables may also be assigned to the result of any
   logical expression, including compound expressions using thethree
   logical operators, .and., .or., and .not..

   Logical variables can also accept numeric values. In such cases the
   zero value is considered to be equal to .f., while any nonzero value
   (positive or negative) is considered to be .t..

 Example
   #define EXAMPLE_DATATYPE
   #include example.hdr

   proc Test_logical
   vardef
      logical lFinished
      logical lProcessing
      logical lReport
      logical lGenerateReport
      logical lSkipReport
      int     nCurrent
   enddef
   
   // assign logical constants
   lFinished := .t.
   lReport   := .t.
   
   // assign logical expressions
   lProcessing     := .not. lFinished
   lGenerateReport := lFinished .and. lReport
   lSkipReport     := lFinished .and. .not. lReport
   ? lFinished
   ? lProcessing
   ? lGenerateReport
   ? lSkipReport
   
   // assign numeric values to logical variable
   nCurrent := 5
   lProcessing := nCurrent
   do while nCurrent > -5
      ? nCurrent
      if lProcessing
         lProcessing := nCurrent
         if lProcessing
            ?? " processing in progress"
         else
            ?? " processing stopped"
         endif
      endif
      nCurrent--
   enddo
   endproc

   proc main
   Test_logical()
   endproc

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson