Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions
The boolean and logical standard API.

Functions

 _CBboolChanged (b, cbfun)
 Define the 'state changed' callback for a BOOL Scol object. It can be nil for no call (default). More...
 
 _CBboolFalse (b, cbfun)
 Define the 'state changed to false' callback for a BOOL Scol object. It can be nil for no call (default). More...
 
 _CBboolTrue (b, cbfun)
 Define the 'state changed to true' callback for a BOOL Scol object. It can be nil for no call (default). More...
 
 _CBboolUndefined (b, cbfun)
 Define the 'state changed to undefined' callback for a BOOL Scol object. It can be nil for no call (default). More...
 
 _CRbool ()
 Create a new BOOL Scol object. More...
 
 _GETbool (b)
 Return the current value for a BOOL Scol object. More...
 
 _ISboolUndefined (b)
 Return if the current value for a BOOL Scol object is an 'undefined' state. More...
 
 _RESETbool (b)
 Perform a reset to a BOOL Scol object. The value will be 'undefined'. More...
 
 _SETbool (b, state)
 Define a new value for a BOOL Scol object. More...
 
 AND (v1, v2)
 Return the logical AND operator between two integers (&&) More...
 
 BAND (v1, v2)
 Return the bit OR operator between two integers (&) More...
 
 BNOT (v)
 Return the bit NOT operator to an integer (~) More...
 
 BOR (v1, v2)
 Return the bit OR operator between two integers (|) More...
 
 BXOR (v1, v2)
 Return the bit XOR operator between two integers (^) More...
 
 EQ (v1, v2)
 Return the EQUALITY between two value (==) More...
 
 FALSE ()
 Define the FALSE value : always 0. More...
 
 IMP (v1, v2)
 Return the logical IMPLICATION. More...
 
 INH (v1, v2)
 Return the logical INHIBITION. More...
 
 LOWER (v1, v2)
 Return the LOWER operator between two integers (<) More...
 
 LOWEREQ (v1, v2)
 Return the LOWER OR EQUAL operator between two integers (<=) More...
 
 NEG (b)
 Return the NEGATION operator to an integer (-) More...
 
 NEQ (v1, v2)
 Return the NON-EQUALITY between two value (!=) More...
 
 NOT (b)
 Return the logical NOT operator to an integer (!) More...
 
 OR (v1, v2)
 Return the logical OR operator between two integers (||) More...
 
 SHLEFT (v1, v2)
 Return the bit SHIFT LEFT operator between two integers (<<) More...
 
 SHRIGHT (v1, v2)
 Return the bit SHIFT RIGHT operator between two integers (>>) More...
 
 TRUE ()
 Define the TRUE value : NOT FALSE (1) More...
 
 UPPER (v1, v2)
 Return the UPPER operator between two integers (>) More...
 
 UPPEREQ (v1, v2)
 Return the UPPER OR EQUAL operator between two integers (>=) More...
 

Detailed Description

Package to load : lib/std/bool.pkg

Dependancies :

Function Documentation

FALSE ( )

Define the FALSE value : always 0.

Prototype : fun [] I

Returns
I : always 0
TRUE ( )

Define the TRUE value : NOT FALSE (1)

Prototype : fun [] I

Returns
I : always 1
_CRbool ( )

Create a new BOOL Scol object.

The value will be 'undefined' (i.e neither FALSE nor TRUE) by defaut.

Prototype : fun [ ] BOOL

Returns
BOOL : a new BOOL Scol object
_RESETbool ( )

Perform a reset to a BOOL Scol object. The value will be 'undefined'.

See also
_CRbool

Prototype : fun [BOOL] BOOL

Parameters
BOOL: any BOOL Scol object
Returns
BOOL : the same BOOL Scol object resetted
_SETbool ( ,
state   
)

Define a new value for a BOOL Scol object.

A new value can be :

  • TRUE
  • FALSE
  • or any other value. In this last case, the value will be 'undefined' (it can be 'nil' but this can be changed in the future, so don't take account and keep the 'undefined' idea only.)

Depending the given new value, one of these callbacks will be also called :

  • 'state changed to true'
  • 'state changed to false'
  • 'state changed to undefined'

The other callback 'state changed' will be always called after.

See also
_CBboolChanged
_CBboolTrue
_CBboolFalse
_CBboolUndefined

Prototype : fun [BOOL I] BOOL

Parameters
BOOL: any BOOL Scol object
I: a new value to set
Returns
BOOL : the same BOOL Scol object
_GETbool ( )

Return the current value for a BOOL Scol object.

The current value can be :

  • TRUE
  • FALSE
  • nil
See also
_SETbool

Prototype : fun [BOOL] I

Parameters
BOOL: any BOOL Scol object
Returns
I : the current value or 2 if the object is nil itself
_ISboolUndefined ( )

Return if the current value for a BOOL Scol object is an 'undefined' state.

See also
_SETbool

Prototype : fun [BOOL] I

Parameters
BOOL: any BOOL Scol object
Returns
I : TRUE if undefined else FALSE. If the object is nil itself, nil is returned.
_CBboolChanged ( ,
cbfun   
)

Define the 'state changed' callback for a BOOL Scol object. It can be nil for no call (default).

It will be called when the value changes.

See also
_CBboolTrue
_CBboolFalse
_CBboolUndefined
_SETbool

Prototype : fun [BOOL fun [BOOL I] I] BOOL

Parameters
BOOL: any BOOL Scol object
fun[BOOL I] I : the callback. Its arguments are :
  • BOOL : the BOOL Scol object
  • the new value (TRUE, FALSE or nil if 'undefined')
Returns
BOOL : the same BOOL Scol object
_CBboolTrue ( ,
cbfun   
)

Define the 'state changed to true' callback for a BOOL Scol object. It can be nil for no call (default).

It will be called when the value becomes TRUE.

See also
_CBboolChanged
_CBboolFalse
_CBboolUndefined
_SETbool

Prototype : fun [BOOL fun [BOOL] I] BOOL

Parameters
BOOL: any BOOL Scol object
fun[BOOL] I : the callback. Its arguments is :
Returns
BOOL : the same BOOL Scol object
_CBboolFalse ( ,
cbfun   
)

Define the 'state changed to false' callback for a BOOL Scol object. It can be nil for no call (default).

It will be called when the value becomes FALSE.

See also
_CBboolChanged
_CBboolTrue
_CBboolUndefined
_SETbool

Prototype : fun [BOOL fun [BOOL] I] BOOL

Parameters
BOOL: any BOOL Scol object
fun[BOOL] I : the callback. Its arguments is :
Returns
BOOL : the same BOOL Scol object
_CBboolUndefined ( ,
cbfun   
)

Define the 'state changed to undefined' callback for a BOOL Scol object. It can be nil for no call (default).

It will be called when the value becomes 'undefined'.

See also
_CBboolChanged
_CBboolTrue
_CBboolFalse
_SETbool

Prototype : fun [BOOL fun [BOOL] I] BOOL

Parameters
BOOL: any BOOL Scol object
fun[BOOL] I : the callback. Its arguments is :
Returns
BOOL : the same BOOL Scol object
AND ( v1  ,
v2   
)

Return the logical AND operator between two integers (&&)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result (TRUE or FALSE) or nil if one of the values is nil
OR ( v1  ,
v2   
)

Return the logical OR operator between two integers (||)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result (TRUE or FALSE) or nil if one of the values is nil
NOT ( )

Return the logical NOT operator to an integer (!)

Prototype : fun [I] I

Parameters
I: an integer
Returns
I : the result or nil if the value is nil
IMP ( v1  ,
v2   
)

Return the logical IMPLICATION.

Example : If i live in French then i live in Europe. So if i don't live in Europe then i don't live in French but if i live in Europe i can not tell i live in French.

  • 0 0 -> 1
  • 0 1 -> 1
  • 1 0 -> 0
  • 1 1 -> 1

Prototype : fun [I I] I

Parameters
I: an integer
I: an integer
Returns
I : the result or nil if the values are nil
INH ( v1  ,
v2   
)

Return the logical INHIBITION.

If the first item is true then the expression is true except if the second item is also true.

  • 0 0 -> 0
  • 0 1 -> 0
  • 1 0 -> 1
  • 1 1 -> 0

Prototype : fun [I I] I

Parameters
I: an integer
I: an integer
Returns
I : the result or nil if the values are nil
BAND ( v1  ,
v2   
)

Return the bit OR operator between two integers (&)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
BOR ( v1  ,
v2   
)

Return the bit OR operator between two integers (|)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
BXOR ( v1  ,
v2   
)

Return the bit XOR operator between two integers (^)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
BNOT ( )

Return the bit NOT operator to an integer (~)

Prototype : fun [I] I

Parameters
I: an integer
Returns
I : the result or nil if the value is nil
SHLEFT ( v1  ,
v2   
)

Return the bit SHIFT LEFT operator between two integers (<<)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
SHRIGHT ( v1  ,
v2   
)

Return the bit SHIFT RIGHT operator between two integers (>>)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
EQ ( v1  ,
v2   
)

Return the EQUALITY between two value (==)

Prototype : fun [u0 u0] I

Parameters
u0: an integer
u0: another integer
Returns
I : the result
NEQ ( v1  ,
v2   
)

Return the NON-EQUALITY between two value (!=)

Prototype : fun [u0 u0] I

Parameters
u0: an integer
u0: another integer
Returns
I : the result
LOWER ( v1  ,
v2   
)

Return the LOWER operator between two integers (<)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
UPPER ( v1  ,
v2   
)

Return the UPPER operator between two integers (>)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
LOWEREQ ( v1  ,
v2   
)

Return the LOWER OR EQUAL operator between two integers (<=)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
UPPEREQ ( v1  ,
v2   
)

Return the UPPER OR EQUAL operator between two integers (>=)

Prototype : fun [I I] I

Parameters
I: an integer
I: another integer
Returns
I : the result or nil if one of the values is nil
NEG ( )

Return the NEGATION operator to an integer (-)

Prototype : fun [I] I

Parameters
I: an integer
Returns
I : the result or nil if one of the values is nil