[Coco] How to use runb?
Walter Zambotti
zambotti at iinet.net.au
Mon Apr 6 03:51:14 EDT 2020
Guys found the real problem!
It turned out to be my procedure name.
It was called 'piper' LOL!!!
I should have called it line!!!
I discovered this when I entered Wayne's code and renamed his procedure
to piper it too wouldn't run from runb either.
And that's because there is already a module in memory called piper and any
basic09 procedure with the same name will conflict.
So in the end my code looks like this:
PROCEDURE XPIPER
DIM lcnt:INTEGER
DIM line:STRING
lcnt=0
ON ERROR GOTO 1000
LOOP
READ #0,line
lcnt=lcnt+1
WRITE #1,STR$(lcnt)+": "+line
ENDLOOP
1000 END
I removed the check for EOF as it would probably occur at the READ
statement anyway where an error will result. Hence the on erro.
And now it works as expected. Just send an EOF to abort.
Thanks to Wayne for the code and for everyone's time.
Walter
On 2020-04-05 22:48, Wayne Campbell wrote:
> I was just about to send a message when yours showed up, Greg. That is
> exactly the issue. The name of the procedure cannot be piper. I changed it
> to thru2 and it worked just fine from the command line. Didn't even have to
> type runb, just:
>
> [TERM|02]:thru2
>
> Why thru2? Because I wrote a slightly different version and called it thru,
> and that's how I discovered it was the name piper that was causing the
> problem. I renamed Walter's piper to thru2 and it worked fine.
>
> The problem with yours, Walter, is that there's no way to exit the loop
> since EOF never occurs on stdin. Here's my solution, but because of the PUT
> statement I couldn't add the line reference without going to extra steps:
>
> PROCEDURE thru
> DIM in:BYTE
> DIM lcnt:INTEGER
> DIM out$:STRING[3]
>
> lcnt:=0
> out$:=""
>
> LOOP
> GET #0,in
> IF in>$1F THEN
> IF LEN(out$)=3 THEN
> out$:=RIGHT$(out$,2)
> ENDIF
> out$:=out$+CHR$(in)
> ENDIF
> EXITIF out$="end" THEN
> ENDEXIT
> lcnt:=lcnt+1
> PUT #1,in
> ENDLOOP
> END
>
> Wayne
>
> The Structure of I-Code
> http://www.cocopedia.com/wiki/index.php/The_Structure_of_I-Code
>
>
>
> On Sun, Apr 5, 2020 at 7:13 AM Greg <glaw at live.com> wrote:
>
>> Do you also have the piper device driver loaded in your OS9Boot file? If
>> you do, runb is trying to link and execute the piper device driver and this
>> is not a Basic09 I-Code module.
>>
>> I seem to recall checking for EOF on stdin for an SCF device works fine
>> but it requires setting the EOF character in the device descriptor (I think
>> the default is 1B or escape) and providing this character at the end of the
>> input.
>>
>> On 4/5/2020 2:08:03 AM, "Walter Zambotti" <zambotti at iinet.net.au> wrote:
>>
>>> That's weird.
>>>
>>> If I run the packed version with basic09 like so:
>>>
>>> $ basic09 piper
>>>
>>> It works
>>>
>>> $ runb piper
>>> ERROR #051
>>>
>>> So not sure!
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>>
More information about the Coco
mailing list