Post Reply 
FORTH for the SHARP PC-E500 (S)
04-03-2022, 12:53 AM
Post: #67
RE: FORTH for the SHARP PC-E500 (S)
I haven't had the time to work on a text file editor for Forth500 to edit Forth source code. I usually INCLUDE my programs from COM: or use CLOAD with the CE-126P. Editing text files on the RAM disk can be done with a separate BASIC program called edit500 available at:

Or you could use my new Forth500 TLOAD command defined below that loads Forth from a TEXT file created in BASIC with the built-in BASIC editor:

\ TLOAD.FTH load TEXT file with line numbers as Forth source
\ Author: Robert van Engelen
\ TLOAD filename

.( Loading TLOAD...)



: TLOADED       ( c-addr u -- )
  \ open file and save fileid to the return stack
  \ read header 16 bytes + 0 0 CR bytes
  FIB 19 R@ READ-FILE 0= SWAP 19 = AND
  \ and check if it is a TEXT file header
  FIB 5 S\" \xff\x00\x08\x00\x34" S= AND IF
      \ while not EOF and line number high byte is not $FF
      \ read and nip line number low byte
      \ get line len byte
      R@ READ-CHAR 0= WHILE ( -- len1 )
      \ read the len number of bytes into the FIB
      FIB OVER R@ READ-FILE 0= WHILE ( -- len1 len2 )
      \ all bytes read?
      OVER = WHILE ( -- len1 )
      \ evaluate the line read
        \ drop string that failed to evaluate, close file and rethrow
    ." not TEXT"
  \ pop fileid from the return stack and close file

: TLOAD         ( "name" -- ) PARSE-NAME TLOADED ;

This approach is similar to the PC-G850(V)(S) C programming with its built-in line-number-based text editor. It is a bit odd to use line numbers. But hey, this is a throwback to the 80s Smile

How to use TLOAD:

1. in BASIC key in TEXT, the prompt will change to < to indicate the TEXT mode
2. type in your Forth program line-by-line with line numbers
3. use RENUM in case you can't insert a line
4. then SAVE "name" to save your program to RAM disk as name.BAS (don't forget this step!)
5. go back to Forth500 with CALL&B0000 (or CALL&B9000 on a 32K machine)
6. key in TLOAD name.BAS
7. done!

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
FORTH for the SHARP PC-E500 (S) - Helix - 09-06-2021, 11:41 PM
RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-02-2022, 02:29 PM
RE: FORTH for the SHARP PC-E500 (S) - robve - 04-03-2022 12:53 AM

User(s) browsing this thread: 1 Guest(s)