Hi there,

I'm rather new with Parrot, and I wanted to play with it a little. I'm 
playing with parrot 0.0.7, I did *not* fetch the last CVS version.

I have a problem when I'm trying to read a file.

I looked at parrot_assembly.pod and saw:
       open px, sy
           Open the file Y on filehandle X
       read px, py, pz
           Issue a read on the filehandle in y, and put the
           result in PMC X. PMC Z is the sync object.

but when I try this chunk of code:
LOAD:
        read S0, 256
        chopn S0, 1   # trailing newline
        open P10, S0
        set S1, ""        # Accumulator
LOAD_READ:
        read P1, P10
        print S1
        print "\n"
        end

all I got was:
$ perl assemble.pl foo.pasm > foo.pbc
Couldn't find operator 'open_p_s' on line 4.
Couldn't find operator 'read_p_p' on line 7.

As it is said that parrot_assembly.pod may be out of date, I checked in 
core.ops to see what was really implemented. And I saw:
=item B<open>(out INT, in STR)
=item B<open>(out INT, in STR, in STR)
=item B<read>(out INT, in INT)
=item B<read>(out NUM, in INT)
=item B<read>(out STR, in INT, in INT)

Thus, I thought this one was the one I wanted. So:
LOAD:
        read S0, 256
        chopn S0, 1   # trailing newline
        open I10, S0, "r"
        eq I10, 0, ERR_IO
        set S1, ""    # Accumulator
LOAD_READ:
        read S1, I10, 256
        print S1
        print "\n"
        end
ERR_IO:
        print "I/O err\n"
        end

This compiles ok, but when I ran it, it prompted me for the filename (that's 
what I want), but then it doesn't seem to read the file (I have read rights 
on the file - I tried it with the script file itself).

So, what am I doing wrong? What's the real syntax? (I wish there were a 
parrotopentut ;) ).

While I'm at reading files - why isn't there a readline op for file handles? 
Is it planned / forbidden for an unknown (to me) reason / other (patches 
welcome :o) )?

Another question. Is there a way to fetch command line arguments, such as:
$ ./parrot foo.pbc foo bar baz


Thanks,

Jerome
-- 
[EMAIL PROTECTED]

Reply via email to