\ Working with counted strings : csLen COUNT SWAP DROP ; : csLen! C! ; : csA COUNT DROP ; : cs+Size ( cs1 cs2 -- Size ) csLen SWAP csLen + ; \ Сумма длин строк : cs>A ( cs A -- ) >R COUNT R> SWAP CMOVE ; \ Адрес строки : cs+! ( cs1 cs2 -- ) 2DUP cs+Size >R DUP csA 1- >R COUNT + cs>A R> R> SWAP C! ; \ cs2+=cs1 : cs>ASCIIZ COUNT + 0 SWAP C! ; \ : cs! >R DUP csLen 1+ R> SWAP CMOVE ; : "cs! ( addr u cs ) >R DUP R@ C! R> 1+ SWAP CMOVE ; : 0csCreate ( SIZE -- cs ) ALLOCATE THROW DUP 0 SWAP C! ; \ Create zero-length string from alloc size : "csCreate ( A # -- cs ) DUP 1+ ALLOCATE THROW >R R@ "cs! R> ; \ Creates counted string from ADDR and COUNTER : csFree FREE ; : csChar+! >R R@ COUNT + C! R> DUP csLen 1+ SWAP csLen! ; \ CREATE a C" aaa" ", \ CREATE b C" bbb" ", 20 ALLOT
Make your own free website on Tripod.com