Scol standard library package
0.3.1
Common and usefull functions for all Scol applications
|
Functions | |
std_addFlag (flags, flag) | |
Add a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. | |
std_clamp (v, m, M) | |
Clamp a value between two values. | |
std_clampT (v, tuple, default) | |
Clamp a value to a tuple. | |
std_cmpI (a, b) | |
Returns if two integers are equals or not. | |
std_cmpS (s, t) | |
Returns if two float numbers are equals or not. | |
std_cmpSi (s, t) | |
Returns if two string are equals. Case-insensitive. | |
std_divide (a, b) | |
Perform an entire division. | |
std_enumClamp (v, tuple) | |
Clamp an integer like an enum. The tuple should be sorted : only the first and the last element are compared. | |
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. | |
std_getLoadedPackages (chn) | |
Returns the list of all loaded packages in a given channel. | |
std_isFlagPresent (flags, flag) | |
Check if a flag is in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. | |
std_memory () | |
Return some infos about the operating system. See 'memoryInfos' for more informations about the memory. | |
std_ncmpI (a, b) | |
Returns if two integers are not equals. | |
std_ncmpS (s, t) | |
Returns if two float numbers are not equals. | |
std_ncmpSi (s, t) | |
Returns if two string are not equals. Case-insensitive. | |
std_newUnChn (szScript) | |
Create a new unplugged channel with the minimal environment. | |
std_newUnCurChn (szScript) | |
Create a new unplugged channel with the current environment. | |
std_newUnCurChnEx (szScript, funCon, funClo) | |
Create a new unplugged channel with the current environment. | |
std_objIsEqual (obj1, obj2) | |
Returns if two Scol objects are equal. | |
std_objIsNil (obj) | |
Get if an Scol object is nil. | |
std_os () | |
Return some infos about the operating system. See 'osInfos'. | |
std_random (max) | |
Return a random integer. | |
std_removeFlag (flags, flag) | |
Remove a flag in a flags combination, like 'WN_MENU|WN_SIZEBOX|WN_MINBOX'. | |
std_sameType (o1, o2) | |
Check if two objects have the same type. | |
std_sleep (second) | |
Perform a pause. | |
std_starterScriptParse () | |
Parse the launcher script of the current application. | |
std_starterScriptParseP (pFile) | |
Parse a launcher script. | |
std_tupleCmp (tuple1, tuple2, fCmp) | |
Compare two tuples. | |
std_tupleHasNil (tuple) | |
Return if a tuple has an (or more) item at nil. | |
std_tupleIsFound (tuple, v) | |
Return if a value is found in a tuple. | |
std_tupleIsFoundS (tuple, s) | |
Return if a string is found in a tuple. Case sensitive. | |
std_tupleIsFoundSi (tuple, s) | |
Return if a string is found in a tuple. Case insensitive. | |
std_tupleIsNil (tuple) | |
Return if a tuple is nil or each item is nil. | |
std_tupleNew (size, values, tuple) | |
Create a tuple. | |
std_tupleSize (tuple) | |
Return the size of a tuple. | |
std_tupleSort (tuple) | |
Sort the values of an integer tuple. | |
std_tupleSortF (tuple) | |
Sort the values of a float tuple. | |
std_tupleSortFR (tuple) | |
Sort the values of a float tuple (reverse). | |
std_tupleSortR (tuple) | |
Sort the values of an integer tuple (reverse). | |
std_vectorAddF (fV1, fV2) | |
Add two vectors (float number) | |
std_vectorAddI (iV1, iV2) | |
Add two vectors (integer) | |
std_vectorAddS (szV1, szV2) | |
Add two vectors (string element) | |
std_vectorDivideF (fV1, fV2) | |
Divide two vectors (float number) | |
std_vectorDivideI (iV1, iV2) | |
Divide two vectors (integer) | |
std_vectorIsEqual (v1, v2) | |
Return if two integer vectors are equals. | |
std_vectorIsEqualAny (v1, v2) | |
Return if two vectors are equals. | |
std_vectorIsEqualS (v1, v2) | |
Return if two string vectors are equals. Case-sensitive. | |
std_vectorIsEqualSi (v1, v2) | |
Return if two string vectors are equals. Case-insensitive. | |
std_vectorIsNil (v) | |
Return if a vector is nil or not. | |
std_vectorIsNullF (v) | |
Return if a vector is null or not. | |
std_vectorIsNullI (v) | |
Return if a vector is null or not. | |
std_vectorIsNullS (v) | |
Return if a vector is "" or not. | |
std_vectorMultiplyF (fV1, fV2) | |
Multiply two vectors (float number) | |
std_vectorMultiplyI (iV1, iV2) | |
multiply two vectors (integer) | |
std_vectorSet (v) | |
Create a vector in duplicating a same given value. | |
std_vectorSubF (fV1, fV2) | |
Sub two vectors (float number) | |
std_vectorSubI (iV1, iV2) | |
Sub two vectors (integer) |
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:
- 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 | ( | a | , |
b | |||
) |
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 | ( | s | , |
t | |||
) |
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 | ( | s | , |
t | |||
) |
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 | ( | a | , |
b | |||
) |
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 | ( | s | , |
t | |||
) |
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 | ( | s | , |
t | |||
) |
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 | ( | a | , |
b | |||
) |
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 :
- S : a function name (called from the launcher), such as "main"
- [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 :
- S : a function name (called from the launcher), such as "main"
- [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 | ( | v | , |
m | , | ||
M | |||
) |
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 | ( | v | , |
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 | ( | v | , |
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 | ( | v | , |
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 | , |
v | |||
) |
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 | , |
s | |||
) |
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 | , |
s | |||
) |
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 +) [u0 r1] : 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 | ( | v | ) |
Return if a vector is null or not.
Prototype: fun [[I I I]] I
- Parameters
-
[I I I] : integer vector
- Returns
- I : 1 if equal at 0 else 0
std_vectorIsNullF | ( | v | ) |
Return if a vector is null or not.
Prototype: fun [[F F F]] I
- Parameters
-
[F F F] : float vector
- Returns
- I : 1 if equal at 0 else 0
std_vectorIsNullS | ( | v | ) |
Return if a vector is "" or not.
Prototype: fun [[S S S]] I
- Parameters
-
[S S S] : string vector
- Returns
- I : 1 yes 1 no 0
std_vectorIsNil | ( | v | ) |
Return if a vector is nil or not.
Prototype: fun [[u0 u1 u2]] I
- Parameters
-
[u0 u1 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
-
[I I I] : first integer vector [I I 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
-
[S S S] : first string vector [S S 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
-
[S S S] : first string vector [S S 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
-
[u0 u1 u2] : first vector [u0 u1 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
-
[I I I] : first integer vector [I I 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
-
[F F F] : first float vector [F F 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
-
[S S S] : first string vector [S S 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
-
[I I I] : first integer vector [I I 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
-
[F F F] : first float vector [F F 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
-
[I I I] : first integer vector [I I 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
-
[F F F] : first float vector [F F 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
-
[I I I] : first integer vector [I I 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
-
[F F F] : first float vector [F F F] : second float vector
- Returns
- [F F F] : vector result
std_vectorSet | ( | v | ) |
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
-
[S r1] : 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 !
Generated on Sat Jan 31 2015 19:15:44 for Scol standard library package by 1.8.1.2