From: dxforth@gmail.com   
      
   On 28/04/2025 9:52 pm, albert@spenarnc.xs4all.nl wrote:   
   > In article <03d13185898a1ee00bea4f420aa1a3721b0585f2@i2pn2.org>,   
   > dxf wrote:   
   >> On 27/04/2025 8:28 pm, Hans Bezemer wrote:   
   >>> ...   
   >>> Another handy word is >STRING that converts a "raw" string to a fully   
   qualified string ( a1 n1 -- a2) that can handle a COUNT (you have the carnal   
   knowledge - you take care   
   >> of the "how"). E.g. for counted strings it might be:   
   >>>   
   >>> : >STRING swap over over dup char+ rot cmove c! ;   
   >>   
   >> For forths that have PACK ( a u a2 -- a2 )   
   >>   
   >> : >STRING ( a u -- a ) over pack ;   
   >>   
   > Store a string in allocated memory.   
   > sc (string constant: a u)   
   > : $!A DUP ALLOCATE THROW >R   
   > R@ SWAP CMOVE   
   > R> ;   
   >   
   > It helps to have SIZE in the memory wordset:   
   > sva (string variable stored ALLOCATE d)   
   > : $@A DUP SIZE ;   
   >   
   > The proper mindset is that there are string variables,   
   > (string areas where a string could be stored and changed)   
   > and string constants, sc n where you are no supposed   
   > to change the content of the string.   
      
   I was more interested in showing the utility of PACK than >STRING .   
   PACK emerged soon after PLACE. PLACE is better known but to my mind   
   PACK is the better primitive and in machine code the cost was but one   
   instruction. For this reason my forth kernel has both PACK and PLACE .   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|