- Dynamic & static strings \r
- ------------------------\r
-\r
-Fifth supports both static and dynamic strings.\r
-Static strings must have predefined space reserved,\r
-and string mustn't exceed this length. They manipulation is\r
-faster. But they use more memory. Static string memory address is used\r
-to refer to the string.\r
-\r
-Dynamic strings can have at any time length form 0 to 0FFh,\r
-They take up only memory they currently need. They are held\r
-in dynamic memory blocks, so dynamic block handle is used to refer\r
-to this string.\r
-\r
-Both types of strings are stored in the way, where first (0th)\r
-byte holds current string length, following bytes are string itself.\r
-\r
-Dynamic:\r
-\r
-Dstral ( -- handle )\r
- Allocate new string.\r
-\r
-Dstrlen ( handle -- length )\r
- Return string length.\r
-\r
-c+Dstr ( chr handle -- )\r
- Add one byte to end of the string.\r
-\r
-c+lDstr ( chr handle -- )\r
- Add one byte to left side (beginning) of the string.\r
-\r
-Dstr. ( handle -- )\r
- Write contec of string into screen.\r
-\r
-Dstrsure ( size Dstr -- )\r
- Makes sure that at least rquested\r
- "size" (amount of characters) is allocated for given\r
- dynamic string.\r
-\r
-Dstr2str ( handle address -- )\r
- Copy dyamic string into static memory space.\r
-\r
-str2Dstr ( address handle -- )\r
- Copy static string into dyamic string.\r
-\r
-Dstr+str ( Dstr addr -- )\r
- Add contenc of dynamic string to static string.\r
-\r
-D" any string" ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr".\r
-\r
-D> any_string ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr".\r
- Space marks end of string!\r
-\r
-D>2 any_string ( -- Dstr )\r
- Moves specified string into dynamic string called "defDstr2".\r
- Space marks end of string!\r
-\r
-Dstr+Dstr ( Dstr1 Dstr2 -- )\r
- Adds "Dstr1" to "Dstr2" and places result into "Dstr2". \r
-\r
-Dstrclear ( Dstr -- )\r
- Clears contenc of dynamic string.\r
-\r
-Dstr2Dstr ( Dstr1 Dstr2 -- )\r
- Moves "Dstr1" to "Dstr2".\r
-Dstr ( data" name -- )\r
- Creates new dynamic string and moves specified data into it.\r
- Then creates new constant with given "name" holding created\r
- dynamic string handle.\r
-\r
- ex: Dstr Hello, my name is Sven!" message \ creates it\r
- message Dstr. \ tests it\r
-\r
-Dstrlscan ( char Dstr -- loc )\r
- Searches dynamic string for "char", from left to right,\r
- returns first found "char" location in string, or 0,\r
- if not found.\r
-\r
-Dstrrscan ( char Dstr -- loc )\r
- Searches dynamic string for "char", from right to left,\r
- returns first found "char" location in string, or 0,\r
- if not found.\r
-\r
-Dstrlscane ( char Dstr -- loc )\r
- Same as "Dstrlscan" buf returns string length+1 as location.\r
-ΓΏ\r
-Dstrleft ( amo Dstr -- )\r
- Only specified amount of characters from left remains\r
- in dynamic string. ie. cut right part out.\r
-\r
-Dstrright ( amo Dstr -- )\r
- Only specified amount of characters from right remains\r
- in dynamic string. ie. cut left part out.\r
-\r
-Dstrcutl ( amo Dstr -- )\r
- Cut specified amount of characters from left of dynamic\r
- string out.\r
-\r
-Dstrsp ( char Dstr1 Dstr2 -- )\r
- Separate dynamic string in Dstr1 into two parts,\r
- using "char" as separator. First part will be stored in\r
- "Dstr2", second part in "Dstr1".\r
- ex: asc \ \ ..separator\r
- D> listF\listLIB\5TH_DRVMOUSE \ ..separate from\r
- defDstr2 \ ..place result in\r
- Dstrsp \ separation command\r
- defDstr Dstr. \ will be: listLIB\5TH_DRVMOUSE\r
- defDstr2 Dstr. \ will be: listF\r
-\r
-Dv ( addr -- )\r
- Allocates empty dynamic string, and places it's handle\r
- into given address.\r
-\r
-Df ( addr -- )\r
- Reads dynamic string handle from given address and\r
- deallocates (frees) it.\r
-\r
-ex: var mystring1\r
- : testmodule\r
- mystring1 Dv \ allocates string\r
-\r
- <whatever>\r
-\r
- mystring1 Df ; \ deallocates it again when no longer needed.\r