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

Functions

 std_addFlag (flags, flag)
 Add a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. More...
 
 std_clamp (v, m, M)
 Clamp a value between two values. More...
 
 std_clampT (v, tuple, default)
 Clamp a value to a tuple. More...
 
 std_cmpI (a, b)
 Returns if two integers are equals or not. More...
 
 std_cmpS (s, t)
 Returns if two float numbers are equals or not. More...
 
 std_cmpSi (s, t)
 Returns if two string are equals. Case-insensitive. More...
 
 std_divide (a, b)
 Perform an entire division. More...
 
 std_enumClamp (v, tuple)
 Clamp an integer like an enum. The tuple should be sorted : only the first and the last element are compared. More...
 
 std_enumClampF (v, tuple)
 Clamp a float number like an enum. The tuple should be sorted : only the first and the last element are compared. More...
 
 std_getLoadedPackages (chn)
 Returns the list of all loaded packages in a given channel. More...
 
 std_isFlagPresent (flags, flag)
 Check if a flag is in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. More...
 
 std_memory ()
 Return some infos about the operating system. See 'memoryInfos' for more informations about the memory. More...
 
 std_ncmpI (a, b)
 Returns if two integers are not equals. More...
 
 std_ncmpS (s, t)
 Returns if two float numbers are not equals. More...
 
 std_ncmpSi (s, t)
 Returns if two string are not equals. Case-insensitive. More...
 
 std_newUnChn (szScript)
 Create a new unplugged channel with the minimal environment. More...
 
 std_newUnCurChn (szScript)
 Create a new unplugged channel with the current environment. More...
 
 std_newUnCurChnEx (szScript, funCon, funClo)
 Create a new unplugged channel with the current environment. More...
 
 std_objIsEqual (obj1, obj2)
 Returns if two Scol objects are equal. More...
 
 std_objIsNil (obj)
 Get if an Scol object is nil. More...
 
 std_os ()
 Return some infos about the operating system. See 'osInfos'. More...
 
 std_random (max)
 Return a random integer. More...
 
 std_removeFlag (flags, flag)
 Remove a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. More...
 
 std_sameType (o1, o2)
 Check if two objects have the same type. More...
 
 std_sleep (second)
 Perform a pause. More...
 
 std_starterScriptParse ()
 Parse the launcher script of the current application. More...
 
 std_starterScriptParseP (pFile)
 Parse a launcher script. More...
 
 std_tupleCmp (tuple1, tuple2, fCmp)
 Compare two tuples. More...
 
 std_tupleHasNil (tuple)
 Return if a tuple has an (or more) item at nil. More...
 
 std_tupleIsFound (tuple, v)
 Return if a value is found in a tuple. More...
 
 std_tupleIsFoundS (tuple, s)
 Return if a string is found in a tuple. Case sensitive. More...
 
 std_tupleIsFoundSi (tuple, s)
 Return if a string is found in a tuple. Case insensitive. More...
 
 std_tupleIsNil (tuple)
 Return if a tuple is nil or each item is nil. More...
 
 std_tupleNew (size, values, tuple)
 Create a tuple. More...
 
 std_tupleSize (tuple)
 Return the size of a tuple. More...
 
 std_tupleSort (tuple)
 Sort the values of an integer tuple. More...
 
 std_tupleSortF (tuple)
 Sort the values of a float tuple. More...
 
 std_tupleSortFR (tuple)
 Sort the values of a float tuple (reverse). More...
 
 std_tupleSortR (tuple)
 Sort the values of an integer tuple (reverse). More...
 
 std_vectorAddF (fV1, fV2)
 Add two vectors (float number) More...
 
 std_vectorAddI (iV1, iV2)
 Add two vectors (integer) More...
 
 std_vectorAddS (szV1, szV2)
 Add two vectors (string element) More...
 
 std_vectorDivideF (fV1, fV2)
 Divide two vectors (float number) More...
 
 std_vectorDivideI (iV1, iV2)
 Divide two vectors (integer) More...
 
 std_vectorIsEqual (v1, v2)
 Return if two integer vectors are equals. More...
 
 std_vectorIsEqualAny (v1, v2)
 Return if two vectors are equals. More...
 
 std_vectorIsEqualS (v1, v2)
 Return if two string vectors are equals. Case-sensitive. More...
 
 std_vectorIsEqualSi (v1, v2)
 Return if two string vectors are equals. Case-insensitive. More...
 
 std_vectorIsNil (v)
 Return if a vector is nil or not. More...
 
 std_vectorIsNullF (v)
 Return if a vector is null or not. More...
 
 std_vectorIsNullI (v)
 Return if a vector is null or not. More...
 
 std_vectorIsNullS (v)
 Return if a vector is "" or not. More...
 
 std_vectorMultiplyF (fV1, fV2)
 Multiply two vectors (float number) More...
 
 std_vectorMultiplyI (iV1, iV2)
 multiply two vectors (integer) More...
 
 std_vectorSet (v)
 Create a vector in duplicating a same given value. More...
 
 std_vectorSubF (fV1, fV2)
 Sub two vectors (float number) More...
 
 std_vectorSubI (iV1, iV2)
 Sub two vectors (integer) More...
 

Detailed Description

Package to load : lib/std/stdlib.pkg

Dependancies :

Function Documentation

std_objIsNil ( obj  )

Get if an Scol object is nil.

Prototype : fun [u0] I

Parameters
u0: any Scol object
Returns
I : 1 if object is nil
Examples:
2d/grayscale.pkg_, and 3d_test/test_3d.pkg_.
std_objIsEqual ( obj1  ,
obj2   
)

Returns if two Scol objects are equal.

Prototype : fun [u0 u0] I

Parameters
u0: any Scol object
u0: another Scol object
Returns
I : 1 if objects are equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_cmpI ( ,
 
)

Returns if two integers are equals or not.

Prototype : fun [I I] I

Parameters
I: any integer
I: another integer
Returns
I : 1 if integers are equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_cmpS ( ,
 
)

Returns if two float numbers are equals or not.

Prototype : fun [F F] I

Parameters
F: any float number
F: another float number
Returns
I : 1 if float numbers are equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
Warning
This function has been removed. See std_fCmp in float.pkg

Returns if two string are equals or not- Case-sensitive.

Prototype : fun [S S] I

Parameters
S: any string
S: another string
Returns
I : 1 if string are equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_cmpSi ( ,
 
)

Returns if two string are equals. Case-insensitive.

Prototype : fun [S S] I

Parameters
S: any string
S: another string
Returns
I : 1 if strings are equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_ncmpI ( ,
 
)

Returns if two integers are not equals.

Prototype : fun [I I] I

Parameters
I: any integer
I: another integer
Returns
I : 1 if integers are not equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_ncmpS ( ,
 
)

Returns if two float numbers are not equals.

Prototype : fun [F F] I

Parameters
F: any float number
F: another float number
Returns
I : 1 if float numbers are not equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
Warning
This function has been removed. See std_fCmp in float.pkg

Returns if two string are not equals. Case-sensitive.

Prototype : fun [S S] I

Parameters
S: any string
S: another string
Returns
I : 1 if strings are not equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_ncmpSi ( ,
 
)

Returns if two string are not equals. Case-insensitive.

Prototype : fun [S S] I

Parameters
S: any string
S: another string
Returns
I : 1 if strings are not equals
Remarks
: It could be useful by calling from an other function, to compare two elements.
std_divide ( ,
 
)

Perform an entire division.

Prototype : fun [I I] I

Parameters
I: a
I: b (if is equal to 0, the result will be nil)
Returns
I : the integral quotient or nil if b = 0
std_os ( )

Return some infos about the operating system. See 'osInfos'.

Prototype : fun [] S

Returns
S : a formatted string
std_memory ( )

Return some infos about the operating system. See 'memoryInfos' for more informations about the memory.

Prototype : fun [] [I I I]

Returns
[I I I] :
  • the approximate percentage of physical memory that is in use
  • the amount of actual physical memory
  • the amount of physical memory currently available
std_sleep ( second  )

Perform a pause.

Prototype : fun [I] I

Parameters
I: the number of second
Returns
I : the "real" pause done, in milliseconds.
std_random ( max  )

Return a random integer.

Prototype : fun [I] I

Parameters
I: the maximum, the number will be between 0 and this maximum (it should not be greater than 32767).
Returns
I : a random integer
std_starterScriptParse ( )

Parse the launcher script of the current application.

Prototype : fun [] [[S r1] [[S [S r1]] r1]]

Returns
[[S r1] [[S [S r1]] r1]] : a tuple :
  • [S r1] : the list of packages
  • [[S [S r1]] r1] : a list of tuples. For each tuple :
    1. S : a function name (called from the launcher), such as "main"
    2. [S r1] : a list of its arguments
std_starterScriptParseP ( pFile  )

Parse a launcher script.

Prototype : fun [P] [[S r1] [[S [S r1]] r1]]

Parameters
P: a script read reference file
Returns
[[S r1] [[S [S r1]] r1]] : a tuple (or nil if error) :
  • [S r1] : the list of packages
  • [[S [S r1]] r1] : a list of tuples. For each tuple :
    1. S : a function name (called from the launcher), such as "main"
    2. [S r1] : a list of its arguments
std_getLoadedPackages ( chn  )

Returns the list of all loaded packages in a given channel.

Prototype : fun [Chn] [S r1]

Parameters
Chn: a channel, like _channel
Returns
[S r1] : a list of all loaded packages in the channel or nil if an error occurs
std_tupleSort ( tuple  )

Sort the values of an integer tuple.

Warning
If the values are not integers, the result can be undefined.

Prototype: fun [u0] u0

Parameters
u0: a tuple of integers
Returns
u0 : the sorted tuple
std_tupleSortR ( tuple  )

Sort the values of an integer tuple (reverse).

Warning
If the values are not integers, the result can be undefined.

Prototype: fun [u0] u0

Parameters
u0: a tuple of integers
Returns
u0 : the sorted tuple
std_tupleSortF ( tuple  )

Sort the values of a float tuple.

Warning
If the values are not float, the result can be undefined.

Prototype: fun [u0] u0

Parameters
u0: a tuple of float numbers
Returns
u0 : the sorted tuple
std_tupleSortFR ( tuple  )

Sort the values of a float tuple (reverse).

Warning
If the values are not float, the result can be undefined.

Prototype: fun [u0] u0

Parameters
u0: a tuple of float numbers
Returns
u0 : the sorted tuple
std_clamp ( ,
,
 
)

Clamp a value between two values.

Prototype: fun [I I I] I

Parameters
I: an integer to clamp
I: the minimum
I: the maximum (if it is lesser than the minimum, the function will return nil)
Returns
I : the clamped value or nil if error
See also
std_fClamp
std_clampT ( ,
tuple  ,
default   
)

Clamp a value to a tuple.

Prototype: fun [I u0 I] I

Parameters
I: an integer to clamp
u0: a tuple
I: a default value to set if not found in the tuple
Returns
I : the clamped value or nil if error
Remarks
this function works too with the float numbers (value, tuple and default)
std_enumClamp ( ,
tuple   
)

Clamp an integer like an enum. The tuple should be sorted : only the first and the last element are compared.

Prototype: fun [I u0] I

Parameters
I: an integer to clamp
u0: any integer tuple
Returns
I : the clamped value or nil if error
std_enumClampF ( ,
tuple   
)

Clamp a float number like an enum. The tuple should be sorted : only the first and the last element are compared.

Prototype: fun [F u0] F

Parameters
F: a float to clamp
u0: any float tuple
Returns
F : the clamped value or nil if error
std_tupleSize ( tuple  )

Return the size of a tuple.

Prototype: fun [u0] I

Parameters
u0: any tuple
Returns
I : the size or nil if error
std_tupleCmp ( tuple1  ,
tuple2  ,
fCmp   
)

Compare two tuples.

Prototype: fun [u0 u0 fun [u0 u0] I] I

Parameters
u0: any tuple
u0: another tuple
fun[u0 u0] I : function called to compare two elements. It should return 1 if these two elements are equals.
Returns
I : 1 if equals, else 0
Remarks
the two tuples must have the same type, otherwise an error will occur during the compilation.
std_tupleIsFound ( tuple  ,
 
)

Return if a value is found in a tuple.

Prototype: fun [u0 u1] I

Parameters
u0: any tuple
u1: a value
Returns
I : 1 if found, 0 if not found or nil if error
See also
std_tupleIsFoundS
std_tupleIsFoundSi
std_tupleIsFoundS ( tuple  ,
 
)

Return if a string is found in a tuple. Case sensitive.

Prototype: fun [u0 S] I

Parameters
u0: any string tuple
u1: a value
Returns
I : 1 if found, 0 if not found or nil if error
See also
std_tupleIsFound
std_tupleIsFoundSi
std_tupleIsFoundSi ( tuple  ,
 
)

Return if a string is found in a tuple. Case insensitive.

Prototype: fun [u0 S] I

Parameters
u0: any tuple
u1: a value
Returns
I : 1 if found, 0 if not found or nil if error
See also
std_tupleIsFound
std_tupleIsFoundS
std_tupleNew ( size  ,
values  ,
tuple   
)

Create a tuple.

Prototype: fun [I [u0 r1] u1] u1

Parameters
I: the size of the new tuple (1 or +)
[u0r1] : a list to set the tuple elements. Initially, each element is set to nil, this list is a convenience to set another values. If the list is bigger than the size, its last elements will be ignored. If it is smaller than the size, another elements will keep at nil.
u1: should be always nil.
Returns
u1 : the new tuple or nil if error
std_tupleIsNil ( tuple  )

Return if a tuple is nil or each item is nil.

Prototype: fun [u0] I

Parameters
u0: any tuple
Returns
I : 1 if nil else 0
std_tupleHasNil ( tuple  )

Return if a tuple has an (or more) item at nil.

Prototype: fun [u0] I

Parameters
u0: any tuple
Returns
I : 1 if yes else 0
std_vectorIsNullI ( )

Return if a vector is null or not.

Prototype: fun [[I I I]] I

Parameters
[II I] : integer vector
Returns
I : 1 if equal at 0 else 0
std_vectorIsNullF ( )

Return if a vector is null or not.

Prototype: fun [[F F F]] I

Parameters
[FF F] : float vector
Returns
I : 1 if equal at 0 else 0
std_vectorIsNullS ( )

Return if a vector is "" or not.

Prototype: fun [[S S S]] I

Parameters
[SS S] : string vector
Returns
I : 1 yes 1 no 0
std_vectorIsNil ( )

Return if a vector is nil or not.

Prototype: fun [[u0 u1 u2]] I

Parameters
[u0u1 u2] : a vector
Returns
I : 1 if equal at nil else 0
std_vectorIsEqual ( v1  ,
v2   
)

Return if two integer vectors are equals.

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

Parameters
[II I] : first integer vector
[II I] : second integer vector
Returns
I : 1 if are equuals else 0
See also
std_vectorIsEqualF in lib/std/float.pkg with floating number.
std_vectorIsEqualS ( v1  ,
v2   
)

Return if two string vectors are equals. Case-sensitive.

Prototype: fun [[S S S] [S S S]] I

Parameters
[SS S] : first string vector
[SS S] : second string vector
Returns
I : 1 if are equuals else 0
std_vectorIsEqualSi ( v1  ,
v2   
)

Return if two string vectors are equals. Case-insensitive.

Prototype: fun [[S S S] [S S S]] I

Parameters
[SS S] : first string vector
[SS S] : second string vector
Returns
I : 1 if are equuals else 0
std_vectorIsEqualAny ( v1  ,
v2   
)

Return if two vectors are equals.

Prototype: fun [[u0 u1 u2] [u0 u1 u2]] I

Parameters
[u0u1 u2] : first vector
[u0u1 u2] : second vector
Returns
I : 1 if are equuals else 0
Remarks
You should use the specific comparaison vectors function if the elements are I, F or S.
std_vectorAddI ( iV1  ,
iV2   
)

Add two vectors (integer)

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

Parameters
[II I] : first integer vector
[II I] : second integer vector
Returns
[I I I] : vector result
std_vectorAddF ( fV1  ,
fV2   
)

Add two vectors (float number)

Prototype: fun [[F F F] [F F F]] [F F F]

Parameters
[FF F] : first float vector
[FF F] : second float vector
Returns
[F F F] : vector result
std_vectorAddS ( szV1  ,
szV2   
)

Add two vectors (string element)

Prototype: fun [[S S S] [S S S]] [S S S]

Parameters
[SS S] : first string vector
[SS S] : second string vector
Returns
[S S S] : vector result
std_vectorSubI ( iV1  ,
iV2   
)

Sub two vectors (integer)

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

Parameters
[II I] : first integer vector
[II I] : second integer vector
Returns
[I I I] : vector result
std_vectorSubF ( fV1  ,
fV2   
)

Sub two vectors (float number)

Prototype: fun [[F F F] [F F F]] [F F F]

Parameters
[FF F] : first float vector
[FF F] : second float vector
Returns
[F F F] : vector result
std_vectorMultiplyI ( iV1  ,
iV2   
)

multiply two vectors (integer)

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

Parameters
[II I] : first integer vector
[II I] : second integer vector
Returns
[I I I] : vector result
std_vectorMultiplyF ( fV1  ,
fV2   
)

Multiply two vectors (float number)

Prototype: fun [[F F F] [F F F]] [F F F]

Parameters
[FF F] : first float vector
[FF F] : second float vector
Returns
[F F F] : vector result
std_vectorDivideI ( iV1  ,
iV2   
)

Divide two vectors (integer)

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

Parameters
[II I] : first integer vector
[II I] : second integer vector
Returns
[I I I] : vector result
std_vectorDivideF ( fV1  ,
fV2   
)

Divide two vectors (float number)

Prototype: fun [[F F F] [F F F]] [F F F]

Parameters
[FF F] : first float vector
[FF F] : second float vector
Returns
[F F F] : vector result
std_vectorSet ( )

Create a vector in duplicating a same given value.

Prototype: fun [u0] [u0 u0 u0]

Parameters
u0: any value
Returns
[u0 u0 u0] : vector result
std_isFlagPresent ( flags  ,
flag   
)

Check if a flag is in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'.

Prototype : fun [I I] I

Parameters
I: a flags combination
I: a flag to check
Returns
I : 1 if present else 0
std_removeFlag ( flags  ,
flag   
)

Remove a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'.

Prototype : fun [I I] I

Parameters
I: a flags combination
I: a flag to remove
Returns
I : a new combination
std_addFlag ( flags  ,
flag   
)

Add a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'.

Prototype : fun [I I] I

Parameters
I: a flags combination
I: a flag to add
Returns
I : a new combination
std_sameType ( o1  ,
o2   
)

Check if two objects have the same type.

This function should be NEVER used in production !

In development or debug mode, this function causes a runtime error if the two objects have a different type.

Prototype : fun [u0 u0] I

Parameters
u0: any object
u0: any object
Returns
I : always 0
std_newUnChn ( szScript  )

Create a new unplugged channel with the minimal environment.

Prototype : fun [S] Chn

Parameters
S: a script to execute immediately in the new channel.
Returns
Chn : the new channel or nil if error (unable to create the new channel)
Remarks
Don't use this function at this time !
std_newUnCurChn ( szScript  )

Create a new unplugged channel with the current environment.

Prototype : fun [S] Chn

Parameters
S: a script to execute immediately in the new channel.
Returns
Chn : the new channel or nil if error (unable to create the new channel)
Remarks
Don't use this function at this time !
std_newUnCurChnEx ( szScript  ,
funCon  ,
funClo   
)

Create a new unplugged channel with the current environment.

Prototype : fun [S S S] Chn

Parameters
S: a script to execute immediately in the new channel.
S: the function name to call when a connection is received.
S: the function name to call when a connection is closed.
Returns
Chn : the new channel or nil if error (unable to create the new channel)
Remarks
These two functions must be known in the new channel environnement.
Don't use this function at this time !

Create a new unplugged channel with the minimal environment.

Prototype : fun [S S S] Chn

Parameters
S: a script to execute immediately in the new channel.
S: the function name to call when a connection is received.
S: the function name to call when a connection is closed.
Returns
Chn : the new channel or nil if error (unable to create the new channel)
Remarks
These two functions must be known in the new channel environnement.
Don't use this function at this time !
See also
std_newUnChnExP

Create a new unplugged channel with the minimal environment.

Prototype : fun [[S r1] S S] Chn

Parameters
[Sr1] : a list of files to load immediately in the new channel.
S: the function name to call when a connection is received.
S: the function name to call when a connection is closed.
Returns
Chn : the new channel or nil if error (unable to create the new channel)
Remarks
These two functions must be known in the new channel environnement.
Don't use this function at this time !