Up |
SYSPACK - String Dictionnary
Create, delete, save, update a string/string associative array, similar to a Python dictionary, a Java hashMap or a Perl hash.
By alphabetic order
- SDict
the Scol string dictionnary object type - SDictAdd
fun [SDict S S] I - SDictDestroy
fun [SDict] I - SDictFind
fun [SDict S] I - SDictGet
fun [SDict S] S - SDictList
fun [SDict] [[S S] r1] - SDictNew
fun [Chn] SDict - SDictRemove
fun [SDict S] I - SDictSave
fun [SDict W] I - SDictSaveOptions
fun [SDict W S S I] I
See also
Example
typeof dict = SDict;; // creation of a SDict variable fun displayList (list)= if list == nil then "" else let hd list -> [key value] in sprintf "%s : %s ; %s" [key value displayList tl list];; fun main ()= _showconsole; set dict = SDictNew _channel; _fooId SDictAdd dict "keyOne" "valueOne"; // 0 _fooId SDictAdd dict "keyTwo" itoa 2; // 0 _fooId SDictAdd dict strcat "key" itoa 3 ftoa 25.63; // 0 _fooId SDictAdd dict "Bob" "Alice"; // 0 _fooId SDictRemove dict "Bob"; // 0 _fooS SDictGet dict "keyOne"; // valueOne _fooId atoi SDictGet dict "keyTwo"; // 2 _fooS SDictGet dict "keyNth"; // nil _fooS displayList SDictList dict; // key3 : 25.629997 ; keyOne : valueOne ; keyTwo : 2 ; SDictSave dict _getmodifypack "tests/syspack/dict.txt"; SDictDestroy dict; 0;;
The saved file content :
key3 : 25.629997 keyOne : valueOne keyTwo : 2