Scol standard library package
0.3.1
Common and usefull functions for all Scol applications
|
Functions | |
std_szAddEscape (str, lAsc) | |
Protect special character with a '\'. More... | |
std_szAddUnique (list, str) | |
Add a string element as unique. This function is case-sensitive. More... | |
std_szAddUniqueResult (list, tuple) | |
std_szCatSep (list, sep) | |
Concat a string list with a defined separator. More... | |
std_szCheckLastChar (str, c) | |
Check the last char of a string. More... | |
std_szCheckSubPos (str, sub, pos) | |
Compare if a sub string is in a string at a given position. This function is sensitive-case. More... | |
std_szCmp (s1, s2) | |
Check if the first string is found to be equal, less or greater than the second string. This function is case-sensitive. More... | |
std_szCutFromSep (str, sep) | |
Cut a string when the first seperator is found. More... | |
std_szCutFromSepAll (str, sep) | |
Cut a string with all seperator found. More... | |
std_szGetBoolean (str) | |
Get the boolean value of a string. This function is insensitive-case. More... | |
std_szGetPosInList (list, string) | |
Get the position of a string in a list. This function is case-sensitive. More... | |
std_szGreater (s1, s2) | |
Check if the first string is found to be greater than the second string. This function is case-sensitive. More... | |
std_sziAddUnique (list, str) | |
Add a string element as unique. This function is case-insensitive. More... | |
std_sziAddUniqueResult (list, tuple) | |
Add a string element as unique. This function is case-insensitive. More... | |
std_sziCheckSubPos (str, sub, pos) | |
Compare if a sub string is in a string at a given position. This function is insensitive-case. More... | |
std_sziCmp (s1, s2) | |
Check if the first string is found to be equal, less or greater than the second string. This function is case-insensitive. More... | |
std_sziGetPosInList (list, string) | |
Get the position of a string in a list. This function is case-insensitive. More... | |
std_sziGreater (s1, s2) | |
Check if the first string is found to be greater than the second string. This function is case-insensitive. More... | |
std_sziInList (list, string) | |
Test if a string exist in a list. This function is case-insensitive. More... | |
std_sziInListFromPos (list, string, pos, length) | |
Test if a string exist in a list from a given position. This function is case-insensitive. More... | |
std_sziIsEqual (s1, s2) | |
Check if two strings are equals. This function is case-insensitive. More... | |
std_sziLesser (s1, s2) | |
Check if the first string is found to be less than the second string. This function is case-insensitive. More... | |
std_szInList (list, string) | |
Test if a string exist in a list. This function is case-sensitive. More... | |
std_szInListFromPos (list, string, pos, length) | |
Test if a string exist in a list from a given position. This function is case-sensitive. More... | |
std_sziReplace (s, from, to) | |
Replace a string in an another string. Case insensitive. More... | |
std_szIsDigit (str) | |
Return if a string contains digits only (0123456789) More... | |
std_szIsEmpty (str) | |
Check if a string is empty (nil or "") More... | |
std_szIsEqual (s1, s2) | |
Check if two strings are equals. This function is case-sensitive. More... | |
std_szIsPattern (str, pattern) | |
Return if a string contains the characters pattern only. More... | |
std_sziStrfindR (str, substr) | |
Find the last position of a given substring. Function case-insensitive. More... | |
std_szIsUrl (url) | |
Check if a string is an url. More... | |
std_szLesser (s1, s2) | |
Check if the first string is found to be less than the second string. This function is case-sensitive. More... | |
std_szRemoveLastChar (str) | |
Remove the last char of any string. More... | |
std_szReplace (s, from, to) | |
Replace a string in an another string. Case sensitive. More... | |
std_szReplaceKeys (s, key, args) | |
replace key by value position in arg list ("my string is $1 with $2" "val1"::"val2"::nil) More... | |
std_szStrfindR (str, substr) | |
Find the last position of a given substring. Function case-sensitive. More... | |
std_szXor (szToDo, szKey) | |
Perform a xor operation between a string and a key. More... | |
Package to load : lib/std/string.pkg
std_szIsEmpty | ( | str | ) |
Check if a string is empty (nil or "")
Prototype: fun [S] I
S | : the string to test |
std_szLesser | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be less than the second string. This function is case-sensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_szGreater | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be greater than the second string. This function is case-sensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_sziLesser | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be less than the second string. This function is case-insensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_sziGreater | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be greater than the second string. This function is case-insensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_szCmp | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be equal, less or greater than the second string. This function is case-sensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_szIsEqual | ( | s1 | , |
s2 | |||
) |
Check if two strings are equals. This function is case-sensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_sziCmp | ( | s1 | , |
s2 | |||
) |
Check if the first string is found to be equal, less or greater than the second string. This function is case-insensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_sziIsEqual | ( | s1 | , |
s2 | |||
) |
Check if two strings are equals. This function is case-insensitive.
Prototype: fun [S S] I
S | : first string to test |
S | : second string to test |
std_szInList | ( | list | , |
string | |||
) |
Test if a string exist in a list. This function is case-sensitive.
Prototype: fun [[S r1] S] I
[S | r1] : list |
S | : string to search |
std_sziInList | ( | list | , |
string | |||
) |
Test if a string exist in a list. This function is case-insensitive.
Prototype: fun [[S r1] S] I
[S | r1] : list |
S | : string to search |
std_szInListFromPos | ( | list | , |
string | , | ||
pos | , | ||
length | |||
) |
Test if a string exist in a list from a given position. This function is case-sensitive.
Prototype: fun [[S r1] S I I] I
[S | r1] : list |
S | : string to search |
std_sziInListFromPos | ( | list | , |
string | , | ||
pos | , | ||
length | |||
) |
Test if a string exist in a list from a given position. This function is case-insensitive.
Prototype: fun [[S r1] S I I] I
[S | r1] : list |
S | : string to search |
std_szAddUnique | ( | list | , |
str | |||
) |
Add a string element as unique. This function is case-sensitive.
Prototype: fun [[S r1] S] [S r1]
[S | r1] : list |
S | : element to add |
std_szAddUniqueResult | ( | list | , |
tuple | |||
) |
Add a string element as unique. This function is case-sensitive.
Prototype: fun [[S r1] [S I]] [S r1]
[S | r1] : list |
[S | I] : string to add and the result : 1 is set if the string is added, else 0 |
(...) _showconsole; let "aa" :: "az" :: "12" :: "sdf" :: "aa" :: "ws" :: nil -> ls in let ["as" nil] -> tuple1 in let ["aa" nil] -> tuple2 in ( _fooSList std_szAddUniqueResult ls tuple1; // "as:"aa":"az":"12":"sdf":"aa":"ws";nil _fooS sprintf "s i" tuple1; // string added and result (1) _fooSList std_szAddUniqueResult ls tuple2; // "aa":"az":"12":"sdf":"aa":"ws";nil _fooS sprintf "s i" tuple2; // string added and result (0, "aa" is already in the list) (...)
std_sziAddUnique | ( | list | , |
str | |||
) |
Add a string element as unique. This function is case-insensitive.
Prototype: fun [[S r1] S] [S r1]
[S | r1] : list |
S | : element to add |
std_sziAddUniqueResult | ( | list | , |
tuple | |||
) |
Add a string element as unique. This function is case-insensitive.
Prototype: fun [[S r1] [S I]] [S r1]
[S | r1] : list |
[S | I] : string to add and the result : 1 is set if the string is added, else 0 |
std_szGetPosInList | ( | list | , |
string | |||
) |
Get the position of a string in a list. This function is case-sensitive.
Prototype: fun [[S r1] S] I
[S | r1] : list |
S | : a string to found |
std_sziGetPosInList | ( | list | , |
string | |||
) |
Get the position of a string in a list. This function is case-insensitive.
Prototype: fun [[S r1] S] I
[S | r1] : list |
S | : a string to found |
std_szRemoveLastChar | ( | str | ) |
Remove the last char of any string.
Prototype: fun [S] S
S | : a string |
std_szCheckLastChar | ( | str | , |
c | |||
) |
Check the last char of a string.
Prototype: fun [S S] I
S | : a string |
S | : a string (if more one char, the only first char is taken) |
std_szStrfindR | ( | str | , |
substr | |||
) |
Find the last position of a given substring. Function case-sensitive.
Prototype: fun [S S] I
S | : a string |
S | : a sub-string |
std_sziStrfindR | ( | str | , |
substr | |||
) |
Find the last position of a given substring. Function case-insensitive.
Prototype: fun [S S] I
S | : a string |
S | : a sub-string |
std_szIsDigit | ( | str | ) |
Return if a string contains digits only (0123456789)
Prototype: fun [S] I
S | : a string |
std_szIsPattern | ( | str | , |
pattern | |||
) |
Return if a string contains the characters pattern only.
_fooId std_szIsPattern "mississipi" "mpsie"; // 1 _fooId std_szIsPattern "michigan" "mpsie"; // 0
Prototype: fun [S] I
S | : a string |
S | : a pattern |
std_szCutFromSep | ( | str | , |
sep | |||
) |
Cut a string when the first seperator is found.
_fooS sprintf "%s %s" std_szCutFromSep "lib/std/string.pkg" "/"; // lib std/string.pkg
Prototype: fun [S S] [S S]
S | : a string |
S | : any separator (one or more chars) |
std_szCutFromSepAll | ( | str | , |
sep | |||
) |
Cut a string with all seperator found.
_fooSList std_szCutFromSepAll "lib/std/string.pkg" "/"; // lib :: std :: string.pkg :: nil
Prototype: fun [S S] [S r1]
S | : a string |
S | : any separator (one or more chars) |
std_szGetBoolean | ( | str | ) |
Get the boolean value of a string. This function is insensitive-case.
Prototype: fun [S] I
S | : the boolean value "enable" "1" "on" "true" "yes" |
std_szCheckSubPos | ( | str | , |
sub | , | ||
pos | |||
) |
Compare if a sub string is in a string at a given position. This function is sensitive-case.
Prototype: fun [S S I] I
S | : the full string |
S | : the substring to compare |
I | : a position (if nil, the position will be 0) |
std_sziCheckSubPos | ( | str | , |
sub | , | ||
pos | |||
) |
Compare if a sub string is in a string at a given position. This function is insensitive-case.
Prototype: fun [S S I] I
S | : the full string |
S | : the substring to compare |
I | : a position (if nil, the position will be 0) |
std_szReplace | ( | s | , |
from | , | ||
to | |||
) |
Replace a string in an another string. Case sensitive.
strreplace
(fun [S S S I] S) faster but the syspack library is required on the client.Prototype: fun [S S S] S
S | : the string to change |
S | : the string to find |
S | : the string to replace with |
std_sziReplace | ( | s | , |
from | , | ||
to | |||
) |
Replace a string in an another string. Case insensitive.
Prototype: fun [S S S] S
S | : the string to change |
S | : the string to find |
S | : the string to replace with |
std_szReplaceKeys | ( | s | , |
key | , | ||
args | |||
) |
replace key by value position in arg list ("my string is $1 with $2" "val1"::"val2"::nil)
sprintf
(fun [S u0] S) faster but the syspack library is required on the client.Prototype: fun [S S [S r1]] S
S | : string |
S | : the key "$" for example |
[S | r1] : list of arguments |
std_szCatSep | ( | list | , |
sep | |||
) |
Concat a string list with a defined separator.
Prototype: fun [[S r1] S] S
[S | r1] : the string list |
S | : the separator to use |
std_szAddEscape | ( | str | , |
lAsc | |||
) |
Protect special character with a '\'.
Prototype: fun [S [I r1]] S
S | : the string to protect |
S | : a list of ascii char to escape (% -> 37, & -> 38, ...) |
std_szIsUrl | ( | url | ) |
Check if a string is an url.
Prototype: fun [S] I
S | : the string to test |
std_szXor | ( | szToDo | , |
szKey | |||
) |
Perform a xor operation between a string and a key.
The string is splitted in word of key lenght. For each word, the xor operation is performed : the string becomes "ciphered". To "uncipher", call this same function with the same key to retrieve the initial string.
This is very easy to use : any string and the same key to cipher / uncipher. However, it is easy to uncipher the ciphered string. This function should not be used in a critical secure environment.
Prototype: fun [S S] S
S | : the string to cipher/uncipher |
S | : the key |