Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.forth Subject: Re: comma-free arrays Keywords: array, counted string Message-ID: <6548@ficc.uu.net> Date: 16 Oct 89 15:10:20 GMT References: <4075@cosmo2.UUCP> Reply-To: peter@ficc.uu.net (Peter da Silva) Organization: Xenix Support, FICC Lines: 39 In article <4075@cosmo2.UUCP> gamber@cosmo.UUCP (Johannes Teich) writes: > - is there a better solution to create 'comma-free' arrays? You can use a sentinal: -1 data data data data data data data -1 addr array! (or arrayc!) You can use a stack counter: variable stackhold : [ sp@ stackhold ! ; : ] sp@ stackhold @ swap - ; [ data data data data data ] addr array! For strings, I do this: " stuff" ( use " as terminator , like in ." ) $ *stuff* ( use next char as terminator ) .$ *stuff* ( ditto ) In FIG, " is easy: : ($) r> count 2dup + =cells r> ; : [$] word state @ if compile ($) here c@ else here count dup then 1+ =cells allot ; : $ tib @ in @ dup 1+ in ! + c@ [$] ; immediate : " 34 [$] ; immediate : [.$] state @ if compile type else type then ; : .$ [compile] $ [.$] ; immediate : ." [compile] " [.$] ; immediate -- Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation. Biz: peter@ficc.uu.net, +1 713 274 5180. Fun: peter@sugar.hackercorp.com. `-_-' 'U` Quote: Structured Programming is a discipline -- not a straitjacket. (wuf)