Page 1 of 1

Easy load and save with ToddyForth 1.4

Posted: Sun May 31, 2020 11:55 pm
by mrtinb
I've made som words for ToddyForth 1.4, to easily load and save 10 pages for the new editor. So this saves and load 769 * 10 bytes with simple commands.

A new word needed is PAD$+ which adds strings with the pad.

Code: Select all

( PAD$+                     #8 )
: PAD$+ ( N_STARTPOS           
      STR_STRING2ADD N_STRLEN --
      N_ENDPOS )
  ROT DUP >R PAD +
  SWAP DUP R> + >R
  CMOVE
  R> ;
If you want to save the 10 pages to NEWPRG.BLK and have it replace the old file with same name, then type:

Code: Select all

BSAVE NEWPRG

Code: Select all

: BSAVE ( -- )
  0 S" >" PAD$+
  BL WORD COUNT PAD$+
  S" .BLK;32768,7690" PAD$+
  PAD SWAP FSAVE ; 
You can load the 10 pages again with:

Code: Select all

BLOAD NEWPRG

Code: Select all

: BLOAD ( -- )
  0 BL WORD COUNT PAD$+
  S" .BLK;32768" PAD$+
  PAD SWAP FLOAD ;
I've also made a little utility, that displays the first line of every 10 pages. This is helpful, if your first line on the page has a comment about the page's content.

Just type

Code: Select all

INDEX

Code: Select all

: INDEX CLS
  10 0 DO
     32768 I 769 * + 32 TYPE
     LOOP
; 
If you want to add them permanently to your ToddyForth, you can load them with FLOAD and LOAD, and save the whole of ToddyForth afterward with this

Code: Select all

S" NEWTF" FSAVE
(FSAVE saves the current vocabulary with the runtime of TForth. So ToddyForth has this new vocabulary next time it is loaded.)

Re: Easy load and save with ToddyForth 1.4

Posted: Mon Jun 01, 2020 4:13 am
by kmurta
Very good, Martin!

I want to inform you that I made a small change in the block structure excluding the null byte at the end, so in TForth 1.5 the block will have 768 bytes. Sorry for this inconvenience but I believe that using blocks without the null byte is more practical and is how it is used in other Forths too.

That allows the possibility to compile several blocks at once and also makes it possible to start the definition of a word in one block and end it in a next block. To indicate the stop point for the compilation is used the word ;S

Until tomorrow I will make Toddy Forth 1.5 available with the new enhanced Editor.

Re: Easy load and save with ToddyForth 1.4

Posted: Mon Jun 01, 2020 6:59 pm
by mrtinb
For ToddyForth 1.5:

Replace 769 with 768
And 7690 with 7680