On 16 Oct 2001, Brian Wheeler wrote:

> I'm getting some weird results when using substr.  Here's my test
> program:

It's probably something wrong with the constant table or the assembly
phase, if the script is changed so that S1 is set to "-", say, it does
more what I expect.

        set     S0,"Hello world"
        print   "Arg to Reverse: "
        print   S0
        print   "\n"
        set     S1,"-"
        set     S2,""
        length  I0,S0
        dec     I0
$loop:  substr  S2,S0,I0,1
        print   "string so far:"
        print   S1
        print   ", "
        print   S2
        print   "\n"
        concat  S1,S2
        dec     I0
        ge      I0,0,$loop
        set     S0,S1
        end

[6:53PM]clean/parrot% ./test_prog foo.pbc 
Arg to Reverse: Hello world
-
string so far:-, d
string so far:-d, l
string so far:-dl, r
string so far:-dlr, o
string so far:-dlro, w
string so far:-dlrow,  
string so far:-dlrow , o
string so far:-dlrow o, l
string so far:-dlrow ol, l
string so far:-dlrow oll, e
string so far:-dlrow olle, H

Reply via email to