6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 1:27 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Error messages
PostPosted: Sat Feb 05, 2022 5:26 am 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
I like the way FigForth handles message printout, either error messages or other messages.

Normally, error messages are stored on screens 4 & 5.

The meaning of MESSAGE according to the Fig Guide is:
Code:
MESSAGE prints on the terminal n'th line of text relative to screen 4.


I take this as it can also mean that messages can be stored on Screens 2 & 3 and displayed using a negative number. Although, according to the guide, it doesn't look like MESSAGE allows for block numbers to be subtracted from the starting point of Screen #4, to get to 2 or 3.

1) Is this even a good idea, or is there some reason one shouldn't do this?

1) Another question is, is there even a standard for error numbers stating that a certain error number should produce a certain error?

3) And one more question, in other Forths, are errors grouped together and printed using message #'s or are they printed inline with the definition where the error happens?


Top
 Profile  
Reply with quote  
 Post subject: Re: Error messages
PostPosted: Sat Feb 05, 2022 6:05 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
For fig Forth, what it is coded to do is its "standard".

In Forth94, there are standard THROW codes, from -255 to -1, and -4095 to -256 are reserved for system defined throw codes. Applications may use any throw codes outside this range.

I think if you wanted a block of application specific MESSAGES ... "MYMESSAGE"... you could set aside a variable for your "MYMESSAGE" base block, somewhere 4095 or less and define:

(edited -- I don't have a running fig-Forth so these are untested)

( THE USING APPLICATION SETS THIS IN ITS LOAD BLOCK )
( DEFAULT REUSES SYSTEM MESSAGES 0-15 )
VARIABLE MYMSGS 0 MYMSGS !

( LINE 15 SHOULD BE "MYMESSAGE out of range error" )
: MYMESSAGE ( mymsg# -- ) 15 UMIN MYMSGS @ 4 + 16 * MESSAGE ;


Top
 Profile  
Reply with quote  
 Post subject: Re: Error messages
PostPosted: Tue Oct 11, 2022 2:39 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
IamRob wrote:
3) And one more question, in other Forths, are errors grouped together and printed using message #'s or are they printed inline with the definition where the error happens?


The Forth-83 Standard has the word ABORT" which compiles the error message inline in the definition where it is used.
Code:
          ABORT                                      79                   
               Clears the data stack and performs the function of QUIT .
               No message is displayed.

          ABORT"       flag --                       C,I,83  "abort-quote"
                       --   (compiling)             
               Used in the form:                     
                       flag ABORT" ccc"             
               When later executed, if flag is true the characters ccc,
               delimited by " (close-quote), are displayed and then a
               system dependent error abort sequence, including the
               function of ABORT , is performed.  If flag is false, the
               flag is dropped and execution continues.  The blank
               following ABORT" is not part of ccc.

My Forth's ABORT" compiles (ABORT") and the string denoted by ccc. (ABORT") consumes the top stack item. If the item is false, the inline string is skipped over and execution resumes after the string. If the item is true, my Forth displays the location of the error, the error message, and aborts.

Here is an example:
Code:
: ?PAIRS  ( N1 N2 -- )
   <>
   ABORT" STRUCTURE MISMATCH" ;

The word ?PAIRS aborts with the message 'STRUCTURE MISMATCH' if the top two items on the stack are different.


Top
 Profile  
Reply with quote  
 Post subject: Re: Error messages
PostPosted: Sat Aug 05, 2023 11:08 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895

Although ?PAIRS is not in the Forth-83 Standard, it is not a trivial example just off the top of my head. My Forth uses ?PAIRS for compiler security either directly or indirectly in the following words in the Forth vocabulary
Code:
-; DOES> >RESOLVE <RESOLVE
; THEN AGAIN UNTIL
ELSE ELIF REPEAT +LOOP

And these words in the assembler vocabulary
Code:
THEN AGAIN UNTIL ;CODE
ELSE ELIF REPEAT BRAN END-CODE

As for displaying messages which are not from an error, the Forth-83 Standard has ."
Code:
          ."           --                            C,I,83    "dot-quote"
                       --   (compiling)

               Used in the form:
                       ." ccc"
               Later execution will display the characters ccc up to but
               not including the delimiting " (close-quote).  The blank
               following ." is not part of ccc.

64Forth for the Commodore 64, a superset of FIG-Forth, had ." as well.
Adding error messages to new definitions with ABORT" is as easy as using ." (dot quote).

I was wondering, on a FIG-Forth system, what happens if the disk is damaged rendering screens 3 and 4 unreadable? When an error occurs and the system can't read those screens will that result in the system attempting to read one of those screens recursively as each attempt fails?
Will a blank error message be displayed instead?
Are the error messages relating to disk access built in?

I already mentioned 64Forth. It was on a cartridge. Although it used error message numbers, those messages were all stored on the cartridge.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: