-------------------------------------------------------------------------------- -- Name: Boolean.e - Library for boolean types -- Author: D. Newhall -- Created: July 22, 2005 -- Updated: July 27, 2005 -- License: Public Domain -- Intro: -- boolean.e contains a type definition for boolean variables. Boolean -- variables can have only two values, TRUE or FALSE. In Euphoria (like most -- other languages without builtin support for booleans) the numeric value of -- 1 is used to represent TRUE and the numeric value of 0 is used to represent -- FALSE. -------------------------------------------------------------------------------- -- Global constants -------------------------------------------------------------------------------- -- Constant: TRUE -- Syntax: include boolean.e -- TRUE -- Description: TRUE is defined as 1 which is what Euphoria uses to determine -- that an expression is 'true' in a truth statement -- (if, while, etc.). -- Example: -- while TRUE do -- -- Code in loop goes on forever -- end while -- See Also: FALSE -------------------------------------------------------------------------------- global constant TRUE = (1 = 1) -- Should be equal to 1 -------------------------------------------------------------------------------- -- Constant: FALSE -- Syntax: include boolean.e -- FALSE -- Description: FALSE is defined as 0 which is what Euphoria uses to determine -- that an expression is 'false' in a truth statement -- (if, while, etc.). -- Example: -- running = TRUE -- -- while running do -- -- Code goes here -- -- Continues running until... -- running = FALSE -- end while -- -- See Also: TRUE -------------------------------------------------------------------------------- global constant FALSE = not TRUE -- Should be equal to 0 -------------------------------------------------------------------------------- -- Type: boolean -- Author: D. Newhall -- Created: July 22, 2005 -- -- Syntax: -- include boolean.e -- i = boolean(x) -- -- Description: -- Returns 1 if x is equal to either 1 (TRUE) or 0 (FALSE) otherwise it will -- return 0. -- -- Comments: -- This serves to define the boolean type. You can also call it like an -- ordinary function to determine if an object is a boolean. -- -- Example: -- boolean running -- -- running = TRUE -- -- while running do -- -- Code goes here -- -- Set running to FALSE to stop. -- end while -- -- See Also: TRUE, FALSE -------------------------------------------------------------------------------- global type boolean (integer i) if i = TRUE or i = FALSE then return TRUE else return FALSE end if end type -- boolean