At 10:04 PM 8/12/2002 +0200, Jerome Quelin wrote:

>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.

Ow.  The I/O still hurts my head even now.  It seemed to be an ugly 
stepchild at the time.

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

I don't think the I/O's quite mature enough for something like a 
tutorial.  I've got a couple of examples in the BASIC source code.  They are:

basic.pl -- Where the immediate mode command is read.  Nothing special 
here.  Note though that I run the command through a STRIPSPACE (alpha.pasm) 
routine which removes trailing whitespace.  You get the newlines here, and 
in Win32 PASM I've seen inconsistencies as to what exactly this means (one 
char or two).  These may be fixed now.

instructions.pasm  -- Look down where the LOAD instruction is 
processed.  Since there's isn't (or wasn't) a functional line-read PASM 
instruction I wind up reading the whole damndable file into a buffer and 
splitting it back out into an array.  Also note that errors on the open are 
silently ignored.  I don't think they work right yet.  Or they didn't.  The 
EOF detection didn't work IIRC, but checking for a zero-length read was 
good enough at the time.

[Line I/O from files seems strange but Line I/O from the tty is just 
peachy.  *shrug*]

Also the INPUT routine does some line I/O just like basic.pl.


>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) )?

*shrug*


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

Thanks for asking this, as Simon Glover's answer was... 
informative.  Didn't know this before now.

Reply via email to