Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Life sucks, but death doesn't put out at all...." -- Thomas J. Kopp


devel / comp.sys.apple2.programmer / Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

SubjectAuthor
* Using Applesoft Internal Error Messages in a BASIC Error HandlerBill Chatfield
`* Re: Using Applesoft Internal Error Messages in a BASIC Error Handlerfadden
 +* Re: Using Applesoft Internal Error Messages in a BASIC Error HandlerBill Chatfield
 |`* Re: Using Applesoft Internal Error Messages in a BASIC Error HandlerJerry Penner
 | +- Re: Using Applesoft Internal Error Messages in a BASIC Error Handlerfadden
 | `- Re: Using Applesoft Internal Error Messages in a BASIC Error HandlerBill Chatfield
 `- Re: Using Applesoft Internal Error Messages in a BASIC Error HandlerMichael J. Mahon

1
Using Applesoft Internal Error Messages in a BASIC Error Handler

<010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=371&group=comp.sys.apple2.programmer#371

 copy link   Newsgroups: comp.sys.apple2.programmer
X-Received: by 2002:ad4:4584:0:b0:67a:21aa:6512 with SMTP id x4-20020ad44584000000b0067a21aa6512mr479968qvu.3.1701282688206;
Wed, 29 Nov 2023 10:31:28 -0800 (PST)
X-Received: by 2002:a25:d808:0:b0:da0:cbe9:6bb5 with SMTP id
p8-20020a25d808000000b00da0cbe96bb5mr497555ybg.11.1701282687926; Wed, 29 Nov
2023 10:31:27 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2.programmer
Date: Wed, 29 Nov 2023 10:31:27 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f86:a000:0:0:0:d;
posting-account=5B6FzAkAAAC8G3BRlbc_dHzwxqbWctPI
NNTP-Posting-Host: 2600:1700:5f86:a000:0:0:0:d
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
Subject: Using Applesoft Internal Error Messages in a BASIC Error Handler
From: billchat...@gmail.com (Bill Chatfield)
Injection-Date: Wed, 29 Nov 2023 18:31:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4757
 by: Bill Chatfield - Wed, 29 Nov 2023 18:31 UTC

I need an ONERR GOTO error handler to CLOSE files or return to TEXT mode or various other situations. In the error handler, I can get the error code with PEEK(222). Error codes are a waste of time because it just forces the user to look up what the error code means. That is often very hard to do, especially for retro computing. Computers are much better than humans at looking up error messages corresponding to error codes. A good user interface should never display an error code. It should always display the error message corresponding to the error code.

I could write BASIC code in every BASIC program to convert the error code into and an error message. But that is silly when those messages are already in the Applesoft source code, which is here: https://github.com/cmosher01/Apple-II-Source/blob/master/src/system/applesoft/applesoft.m4

I've copied the error table itself below. How can I use this from BASIC? There is an error subroutine called ERROR, but I don't think it does an RTS and I don't understand how it works. It would be nice if there was a standard subroutine in the Applesoft code that I could CALL to display the error message. But at least I could use the error table to get the messages. But I'm not sure how to do that either. Any ideas?

; --------------------------------
; --------------------------------
; ERROR MESSAGES
; --------------------------------
ERROR_MESSAGES
ERR_NOFOR = *-ERROR_MESSAGES
LHASCII(`NEXT WITHOUT FOR')
ERR_SYNTAX = *-ERROR_MESSAGES
LHASCII(`SYNTAX')
ERR_NOGOSUB = *-ERROR_MESSAGES
LHASCII(`RETURN WITHOUT GOSUB')
ERR_NODATA = *-ERROR_MESSAGES
LHASCII(`OUT OF DATA')
ERR_ILLQTY = *-ERROR_MESSAGES
LHASCII(`ILLEGAL QUANTITY')
ERR_OVERFLOW = *-ERROR_MESSAGES
LHASCII(`OVERFLOW')
ERR_MEMFULL = *-ERROR_MESSAGES
LHASCII(`OUT OF MEMORY')
ERR_UNDEFSTAT = *-ERROR_MESSAGES
LOASCII(`UNDEF')
ASM_DATA($27)
LHASCII(`D STATEMENT')
ERR_BADSUBS = *-ERROR_MESSAGES
LHASCII(`BAD SUBSCRIPT')
ERR_REDIMD = *-ERROR_MESSAGES
LOASCII(`REDIM')
ASM_DATA($27)
LHASCII(`D ARRAY')
ERR_ZERODIV = *-ERROR_MESSAGES
LHASCII(`DIVISION BY ZERO')
ERR_ILLDIR = *-ERROR_MESSAGES
LHASCII(`ILLEGAL DIRECT')
ERR_BADTYPE = *-ERROR_MESSAGES
LHASCII(`TYPE MISMATCH')
ERR_STRLONG = *-ERROR_MESSAGES
LHASCII(`STRING TOO LONG')
ERR_FRMCPX = *-ERROR_MESSAGES
LHASCII(`FORMULA TOO COMPLEX')
ERR_CANTCONT = *-ERROR_MESSAGES
LOASCII(`CAN')
ASM_DATA($27)
LHASCII(`T CONTINUE')
ERR_UNDEFFUNC = *-ERROR_MESSAGES
LOASCII(`UNDEF')
ASM_DATA($27)
LHASCII(`D FUNCTION')
; --------------------------------

QT_ERROR LOASCII(` ERROR')
ASM_DATA($07,0)

QT_IN LOASCII(` IN ')
ASM_DATA(0)

QT_BREAK ASM_DATA($0D)
LOASCII(`BREAK')
ASM_DATA($07,0)

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=372&group=comp.sys.apple2.programmer#372

 copy link   Newsgroups: comp.sys.apple2.programmer
X-Received: by 2002:a0c:ff0b:0:b0:67a:52c7:f44d with SMTP id w11-20020a0cff0b000000b0067a52c7f44dmr255172qvt.5.1701325437357;
Wed, 29 Nov 2023 22:23:57 -0800 (PST)
X-Received: by 2002:a05:6808:34c:b0:3b5:6432:e0ec with SMTP id
j12-20020a056808034c00b003b56432e0ecmr670551oie.1.1701325437119; Wed, 29 Nov
2023 22:23:57 -0800 (PST)
Path: i2pn2.org!rocksolid2!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2.programmer
Date: Wed, 29 Nov 2023 22:23:56 -0800 (PST)
In-Reply-To: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.130.68.111; posting-account=UAtoeQoAAADrX7T-MHdWWRC4Fzf0dsLP
NNTP-Posting-Host: 24.130.68.111
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
From: fad...@fadden.com (fadden)
Injection-Date: Thu, 30 Nov 2023 06:23:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2198
 by: fadden - Thu, 30 Nov 2023 06:23 UTC

The error code, passed in the X register, is just the index of the start of the error text (table at $d260). The error routine prints "?", then the error text, then "ERROR" and a bell (from $d350). If the code was running, it prints the line number, and does the Applesoft error handling.

So for example, SYNTAX ERROR is error code 16. $d260 + 16 = $d270, which is the string "SYNTAX". The last letter has the high bit set (Dextral Character Inverted format, or DCI), which is how the code knows when to stop printing characters.

Try this:

100 BASE = 53856: REM $D260
110 ERRCODE = 16: GOSUB 1000: REM SYNTAX ERROR
120 ERRCODE = 53: GOSUB 1000: REM ILLEGAL QUANTITY
130 END
1000 PTR = BASE + ERRCODE
1010 L = PEEK (PTR): IF L > = 128 THEN PRINT CHR$ (L - 128);: PRINT " ERROR": RETURN
1020 PRINT CHR$ (L);:PTR = PTR + 1: GOTO 1010

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<249c977a-9c90-4b82-8996-16a65fc8a368n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=373&group=comp.sys.apple2.programmer#373

 copy link   Newsgroups: comp.sys.apple2.programmer
X-Received: by 2002:a05:620a:2057:b0:77d:84f0:9cb1 with SMTP id d23-20020a05620a205700b0077d84f09cb1mr596785qka.4.1701357276756;
Thu, 30 Nov 2023 07:14:36 -0800 (PST)
X-Received: by 2002:a05:690c:845:b0:5c9:b567:e61a with SMTP id
bz5-20020a05690c084500b005c9b567e61amr721885ywb.0.1701357276461; Thu, 30 Nov
2023 07:14:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2.programmer
Date: Thu, 30 Nov 2023 07:14:36 -0800 (PST)
In-Reply-To: <95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f86:a000:0:0:0:d;
posting-account=5B6FzAkAAAC8G3BRlbc_dHzwxqbWctPI
NNTP-Posting-Host: 2600:1700:5f86:a000:0:0:0:d
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com> <95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <249c977a-9c90-4b82-8996-16a65fc8a368n@googlegroups.com>
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
From: billchat...@gmail.com (Bill Chatfield)
Injection-Date: Thu, 30 Nov 2023 15:14:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 33
 by: Bill Chatfield - Thu, 30 Nov 2023 15:14 UTC

On Thursday, November 30, 2023 at 1:23:58 AM UTC-5, fadden wrote:
> The error code, passed in the X register, is just the index of the start of the error text (table at $d260). The error routine prints "?", then the error text, then "ERROR" and a bell (from $d350). If the code was running, it prints the line number, and does the Applesoft error handling.
>
> So for example, SYNTAX ERROR is error code 16. $d260 + 16 = $d270, which is the string "SYNTAX". The last letter has the high bit set (Dextral Character Inverted format, or DCI), which is how the code knows when to stop printing characters.
>
> Try this:
>
> 100 BASE = 53856: REM $D260
> 110 ERRCODE = 16: GOSUB 1000: REM SYNTAX ERROR
> 120 ERRCODE = 53: GOSUB 1000: REM ILLEGAL QUANTITY
> 130 END
> 1000 PTR = BASE + ERRCODE
> 1010 L = PEEK (PTR): IF L > = 128 THEN PRINT CHR$ (L - 128);: PRINT " ERROR": RETURN
> 1020 PRINT CHR$ (L);:PTR = PTR + 1: GOTO 1010

Wow, that makes a lot more sense in BASIC. I'm use to an ASCII code 0 terminator for strings, so setting the high bit is new to me. But it is more efficient because it saves one character. It's also more efficient than using a length byte at the beginning.

Yeah, this is just what I was looking for. This is so much better than an IF/THEN for each error code in every BASIC program.

I thought I was getting good at reading 6502 assembly, but the Applesoft source code is a little harder. I guess Bill Gates wrote it. Haha.

Thank you so much for translating!

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<yubv89j5dfr.fsf@jpen.ca>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=374&group=comp.sys.apple2.programmer#374

 copy link   Newsgroups: comp.sys.apple2.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jerry...@jpen.ca (Jerry Penner)
Newsgroups: comp.sys.apple2.programmer
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
Date: Thu, 30 Nov 2023 11:00:24 -0700
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <yubv89j5dfr.fsf@jpen.ca>
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
<95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>
<249c977a-9c90-4b82-8996-16a65fc8a368n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="db290eb942428b345874e51af455347e";
logging-data="1536706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/doTb9xFqwS/jHgDCat00T"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:U7cRdz3TnUmCEym4SKjFQraAzos=
sha1:aAe8mWpKAp9XWXGRmAHkig2HH20=
 by: Jerry Penner - Thu, 30 Nov 2023 18:00 UTC

Bill Chatfield <billchatfield1@gmail.com> writes:

> On Thursday, November 30, 2023 at 1:23:58 AM UTC-5, fadden wrote:
>> The error code, passed in the X register, is just the index of the start of the error
>> text (table at $d260). The error routine prints "?", then the error text, then "ERROR"
>> and a bell (from $d350). If the code was running, it prints the line number, and does
>> the Applesoft error handling.
>>
>> So for example, SYNTAX ERROR is error code 16. $d260 + 16 = $d270, which is the string
>> "SYNTAX". The last letter has the high bit set (Dextral Character Inverted format, or
>> DCI), which is how the code knows when to stop printing characters.
>>
>> Try this:
>>
>> 100 BASE = 53856: REM $D260
>> 110 ERRCODE = 16: GOSUB 1000: REM SYNTAX ERROR
>> 120 ERRCODE = 53: GOSUB 1000: REM ILLEGAL QUANTITY
>> 130 END
>> 1000 PTR = BASE + ERRCODE
>> 1010 L = PEEK (PTR): IF L > = 128 THEN PRINT CHR$ (L - 128);: PRINT " ERROR": RETURN
>> 1020 PRINT CHR$ (L);:PTR = PTR + 1: GOTO 1010
>
> Wow, that makes a lot more sense in BASIC. I'm use to an ASCII code 0 terminator for
> strings, so setting the high bit is new to me. But it is more efficient because it saves
> one character. It's also more efficient than using a length byte at the beginning.
>
> Yeah, this is just what I was looking for. This is so much better than an IF/THEN for each
> error code in every BASIC program.
>
> I thought I was getting good at reading 6502 assembly, but the Applesoft source code is a
> little harder. I guess Bill Gates wrote it. Haha.
>
> Thank you so much for translating!

Here's another way to see the errors:

10 ONERR GOTO 1000
20 REM make line 30 have your error of choice
30 NEXT
1000 PTR = 53856 + PEEK (222)
1005 POKE 216,0
1010 FOR X = 0 TO 1 STEP 0
1020 C = PEEK (PTR): PTR = PTR + 1: X = C > = 128
1030 PRINT CHR$ (C - 128 * (C > = 128));
1040 NEXT
1050 PRINT " ERROR IN LINE " PEEK (218) + PEEK (219) * 256

Try different things for line 30:

]30 ASDF
]RUN

SYNTAX ERROR IN LINE 30

]30 NEXT
]RUN

NEXT WITHOUT FOR ERROR IN LINE 30

]30 X = 1 / 0
]RUN

DIVISION BY ZERO ERROR IN LINE 30

]30 POKE 0,256
]RUN

ILLEGAL QUANTITY ERROR IN LINE 30

--
--
Jerry jerry+a2 at jpen.ca

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<90b7cc73-782d-406d-bf15-8189c7ee00e2n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=375&group=comp.sys.apple2.programmer#375

 copy link   Newsgroups: comp.sys.apple2.programmer
X-Received: by 2002:a05:622a:1894:b0:41e:55ad:8211 with SMTP id v20-20020a05622a189400b0041e55ad8211mr761482qtc.8.1701379401289;
Thu, 30 Nov 2023 13:23:21 -0800 (PST)
X-Received: by 2002:a25:3055:0:b0:da0:3117:f35 with SMTP id
w82-20020a253055000000b00da031170f35mr707126ybw.3.1701379401031; Thu, 30 Nov
2023 13:23:21 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2.programmer
Date: Thu, 30 Nov 2023 13:23:20 -0800 (PST)
In-Reply-To: <yubv89j5dfr.fsf@jpen.ca>
Injection-Info: google-groups.googlegroups.com; posting-host=24.130.68.111; posting-account=UAtoeQoAAADrX7T-MHdWWRC4Fzf0dsLP
NNTP-Posting-Host: 24.130.68.111
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
<95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com> <249c977a-9c90-4b82-8996-16a65fc8a368n@googlegroups.com>
<yubv89j5dfr.fsf@jpen.ca>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <90b7cc73-782d-406d-bf15-8189c7ee00e2n@googlegroups.com>
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
From: fad...@fadden.com (fadden)
Injection-Date: Thu, 30 Nov 2023 21:23:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 4
 by: fadden - Thu, 30 Nov 2023 21:23 UTC

On Thursday, November 30, 2023 at 10:00:27 AM UTC-8, Jerry Penner wrote:
> 1010 FOR X = 0 TO 1 STEP 0

Nice. :-)

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<0e9645e0-623e-4f3d-b868-e753aca4173an@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=376&group=comp.sys.apple2.programmer#376

 copy link   Newsgroups: comp.sys.apple2.programmer
X-Received: by 2002:a05:620a:29d0:b0:77d:6045:539f with SMTP id s16-20020a05620a29d000b0077d6045539fmr1030184qkp.4.1701443460205;
Fri, 01 Dec 2023 07:11:00 -0800 (PST)
X-Received: by 2002:a81:be14:0:b0:5d0:a744:7194 with SMTP id
i20-20020a81be14000000b005d0a7447194mr614828ywn.2.1701443459918; Fri, 01 Dec
2023 07:10:59 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2.programmer
Date: Fri, 1 Dec 2023 07:10:59 -0800 (PST)
In-Reply-To: <yubv89j5dfr.fsf@jpen.ca>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f86:a000:0:0:0:d;
posting-account=5B6FzAkAAAC8G3BRlbc_dHzwxqbWctPI
NNTP-Posting-Host: 2600:1700:5f86:a000:0:0:0:d
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com>
<95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com> <249c977a-9c90-4b82-8996-16a65fc8a368n@googlegroups.com>
<yubv89j5dfr.fsf@jpen.ca>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0e9645e0-623e-4f3d-b868-e753aca4173an@googlegroups.com>
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
From: billchat...@gmail.com (Bill Chatfield)
Injection-Date: Fri, 01 Dec 2023 15:11:00 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1681
 by: Bill Chatfield - Fri, 1 Dec 2023 15:10 UTC

On Thursday, November 30, 2023 at 1:00:27 PM UTC-5, Jerry Penner wrote:
> 1020 C = PEEK (PTR): PTR = PTR + 1: X = C > = 128
> 1030 PRINT CHR$ (C - 128 * (C > = 128));

Line 1030 Could be simplified, right?
1030 PRINT CHR$(C - 128 * X);

I also think the boolean for loop is very cool.

Re: Using Applesoft Internal Error Messages in a BASIC Error Handler

<HOKdnXI0TYkR4jr4nZ2dnZfqnPWdnZ2d@giganews.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=446&group=comp.sys.apple2.programmer#446

 copy link   Newsgroups: comp.sys.apple2.programmer
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.27.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 17 Jan 2024 07:19:40 +0000
User-Agent: NewsTap/5.5 (iPhone/iPod Touch)
Cancel-Lock: sha1:O309nFECNS/s0WOhB/SdHgufosY=
Newsgroups: comp.sys.apple2.programmer
Subject: Re: Using Applesoft Internal Error Messages in a BASIC Error Handler
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
From: mjma...@aol.com (Michael J. Mahon)
References: <010cc230-427a-485e-9a90-bcd294ba96b5n@googlegroups.com> <95461d63-9b7a-47b8-b433-c31432d43d24n@googlegroups.com>
Message-ID: <HOKdnXI0TYkR4jr4nZ2dnZfqnPWdnZ2d@giganews.com>
Date: Wed, 17 Jan 2024 07:19:40 +0000
Lines: 31
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-KV9UunyTOgZcff0+Rq20TQSey1kq8GqPhGGkO/5plWUo8AzlhL8B/jkEiZ0HCVee/iDXNz+eTY6fDKU!nw7Cznu3jgy4+tmnkcENslXL39vbwzJQCwr1gl0iSz6ilOpzMslJYQVKsnVxtV6UF4Yzrs74GGhh!nQ==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Michael J. Mahon - Wed, 17 Jan 2024 07:19 UTC

fadden <fadden@fadden.com> wrote:
> The error code, passed in the X register, is just the index of the start
> of the error text (table at $d260). The error routine prints "?", then
> the error text, then "ERROR" and a bell (from $d350). If the code was
> running, it prints the line number, and does the Applesoft error handling.
>
> So for example, SYNTAX ERROR is error code 16. $d260 + 16 = $d270, which
> is the string "SYNTAX". The last letter has the high bit set (Dextral
> Character Inverted format, or DCI), which is how the code knows when to
> stop printing characters.
>
> Try this:
>
> 100 BASE = 53856: REM $D260
> 110 ERRCODE = 16: GOSUB 1000: REM SYNTAX ERROR
> 120 ERRCODE = 53: GOSUB 1000: REM ILLEGAL QUANTITY
> 130 END
> 1000 PTR = BASE + ERRCODE
> 1010 L = PEEK (PTR): IF L > = 128 THEN PRINT CHR$ (L - 128);: PRINT " ERROR": RETURN
> 1020 PRINT CHR$ (L);:PTR = PTR + 1: GOTO 1010
>

When writing the NadaNet ampersand extension for Applesoft, I needed a
“standard” way to signal a data packet error. Since there is no easy way to
extend the error message table, I chose to piggyback on an existing message
by choosing an error number that points to the last word in the “OUT OF
DATA” error, creating a “DATA” error message for NadaNet communication
errors. ;-)

--
-michael - NadaNet 3.1 and AppleCrate II: http://michaeljmahon.com

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor