Demo program: ------------------------------------------------- .include "iterator.pasm" new P0, .CompoundString new P1, .SimpleString set P1, "String one" push P0, P1 new P2, .SimpleString set P2, " and two" push P0, P2 new P3, .CompoundString new P4, .SimpleString set P4, " and three" push P3, P4 push P0, P3
new P5, .Iterator, P0 set P5, .ITERATE_FROM_START fwd_loop: unless P5, fwd_end shift S1, P5 print S1 branch fwd_loop fwd_end: print "\n" set P5, .ITERATE_FROM_END rev_loop: unless P5, rev_end pop S1, P5 print S1 branch rev_loop rev_end: print "\n" set S6, P0 print S6 print "\n" end ------------------------------------------------- And the output: ------------------------------------------------- String one and two and three eerht dna owt dna eno gnirtS String one and two and three ------------------------------------------------- SimpleString is based on PerlString, with a lot of functionality deleted, and no morphing. Iterator code has been revised to support the nested operations. CompoundString is mainly a clone of Array, with get_string amended to return the concatenation of the elements. Iterator code has been amended to iterate into the elements. Work is ongoing to handle substr, etc. Comments welcome. -- Peter Gibbs EmKel Systems