Up |
Create, delete, save, update a string/string associative array, similar to a Python dictionary, a Java hashMap or a Perl hash.
By alphabetic order
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