Jump to content

Photo

fbForth—TI Forth with File-based Block I/O [Post #1 UPDATED: 12/12/2018]

fbForth Forth TI Forth

1492 replies to this topic

#1451 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Thu Jan 25, 2018 10:54 AM

I just received a paper copy of the fbForth manual. Much easier to digest!  Lee, thanks for all your work on this. The list of differences with Starting Forth is a gem: I wish I'd had that for TI FORTH in 1984 when some kind engineer gave me that book!

 
I especially enjoyed the chapter on division - T-division and F-division. The example (of the plotter line drawing) answered my question: what application determines if you choose one or the other?
 
Last weekend I spent some time in fbForth and TI FORTH. All of my hobby time has been on various FORTHs this year.
 
-Erik

 

Good to have another Forther on board!  :)

 

Thank you for your kind words.  It has certainly been fun (mostly) for me to do.  Regarding the appendix showing the differences between Starting Forth and fbForth, I cannot take credit for much more than editing it from the 1983 original TI Forth Manual.  I corrected errors I found and brought it in line with fbForth.

 

I can, however, take full credit for Chapter 18 in my book, fbForth 2.0: A File-Based Cartridge Implementation of TI Forth (see my website below).  I should say that Matthew Splett (jedimatt42) graciously assisted with editing and proofreading of the book.  If you are referring to §18.3 (reproduction of the 1983 Dr. Dobb’s Journal article) of the PDF before I published the book, all credit there, of course, goes to its author, Robert L. Smith.  I had tried repeatedly to obtain permission for reproducing the article, but, alas, had to settle for quoting and evaluating it in research-paper mode.

 

As you have no doubt observed, there are a handful of willing Forth accomplices here on this forum.  :grin:  Again, welcome aboard!

 

...lee



#1452 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Thu Feb 1, 2018 2:50 PM

To show how it could be done I ported this VDP sound list player to FB-Forth.

Works as expected.

TEXT substitutions could be made to improve size and speed.

\ TI sound list player using VDP RAM        CAMEL99 Forth V1.99
\ ========================================================
HEX
\ ----------------
\ FB-FORTH Translation Harness
: VARIABLE   0 VARIABLE ;
: VC!     VSBW ;
: VC@     VSBR ;

: JIFF    100 0 DO LOOP ;  ( ~1/60 sec)
: JIFFS    0 DO JIFF LOOP ;

: 2DUP      OVER OVER ;
: SND!      8400 C! ;
: BOUNDS    OVER + SWAP ;
\ ----------------

\ vdp memory manager words
VARIABLE VP

HEX 1000 VP !   \ start of free VDP RAM


: VHERE   ( -- addr) VP @ ;   \ FETCH the value in VDP pointer
: VALLOT  ( n -- )   VP +! ;  \ add n to the value in VDP pointer
: VC,     ( n -- )   VHERE VC!  1 VALLOT ;
: VCOUNT  ( vdp$adr -- vdpadr len ) DUP 1+ SWAP VC@ ; \ convert counted string to addr,len
: VCREATE ( <text> -- addr) VHERE CONSTANT ;

\ ========================================================
\ sound list player
HEX

: SILENT ( --)  9F SND!  BF SND!  DF SND! FF SND! ;  \ turn off all sounds

: VPLAY$ ( sound_string -- ) \ play 1 sound string from VDP memory
       VCOUNT                \ -- addr len
       2DUP + VC@  >R        \ get duration at end of string, Rpush
       BOUNDS                \ convert addr/len to end-addr. start-addr.
       DO  I VC@ SND! LOOP   \ feed bytes to sound chip
       R> JIFFS ;            \ use the delay from Rstack (JIFF=1/60)

: VPLAYLIST   ( addr -- )    \ play a TI sound list
         BEGIN DUP VC@ WHILE \ while the length is not 0
            DUP VPLAY$       \ play a single string
            VCOUNT + 1+      \ advance to the next sound string
         REPEAT
         SILENT
         DROP ;

: /END   0 VC, 0 VC, ;   \ end the list with 2 bytes

\ ========================================================
\ VDP sound lists
HEX
VCREATE MUNCHMAN
         08 VC, 85 VC, 2A VC, 90 VC, A6 VC, 08 VC, B0 VC, CC VC, 1F VC, 12 VC,
         08 VC, 85 VC, 2A VC, 90 VC, A4 VC, 1C VC, B0 VC, C9 VC, 0A VC, 12 VC,
/END

VCREATE PACMAN
         06 VC, 86 VC, 0D VC, 97 VC, AC VC, 1A VC, B7 VC, 08 VC,
         02 VC, 8F VC, 08 VC, 02 VC,
         02 VC, AB VC, 23 VC, 05 VC,
         02 VC, 86 VC, 0D VC, 04 VC,
         01 VC, BF VC, 03 VC,
         02 VC, 8E VC, 0B VC, 08 VC,
         02 VC, 8A VC, 0A VC, 02 VC,
         03 VC, AC VC, 1A VC, B7 VC, 08 VC,
/END

VCREATE NOKIA
         01 VC, 9F VC, 20 VC,
         03 VC, 90 VC, 85 VC, 05 VC, 09 VC,
         02 VC, 8F VC, 05 VC, 09 VC,
         02 VC, 87 VC, 09 VC, 12 VC,
         02 VC, 87 VC, 08 VC, 12 VC,
         02 VC, 85 VC, 06 VC, 09 VC,
         02 VC, 81 VC, 07 VC, 09 VC,
         02 VC, 8E VC, 0B VC, 12 VC,
         02 VC, 8A VC, 0A VC, 12 VC,
         02 VC, 81 VC, 07 VC, 09 VC,
         02 VC, 8F VC, 07 VC, 09 VC,
         02 VC, 8A VC, 0C VC, 12 VC,
         02 VC, 8A VC, 0A VC, 12 VC,
         02 VC, 8F VC, 07 VC, 24 VC,
         01 VC, 9F VC, 00 VC,
/END


#1453 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Thu Feb 1, 2018 3:41 PM

Cool!

 

...lee



#1454 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Fri Feb 9, 2018 5:00 PM

CRU wordset in FB-Forth/TI-Forth observation/alternative.

 

I needed these words to play with the SAMS card interface.

When I looked at them it seemed like they could be factored differently making each word much simpler.

 

First I made a word to set R12 called CRU!.  I don't play with R12 except as a CRU base so it's safe.

This allowed me to strip away all the R12 setting in SBO, SBZ and TB.   For TB it means you can scan for a bit much faster.

 

I also noticed that the DOCS seem to all use the CRU address without multiplying by 2. So CRU! does not double the value.

 

Am I missing something Lee?

 

(When looking at the code remember CAMEL99 keeps TOS in a register so it looks a littler different than what you are used to.)

CROSS-ASSEMBLING

CODE: CRU! ( addr -- ) \ set the CRU base address for CRU words
\         TOS  TOS ADD,    \ multiply adr by 2  (removed. Most DOCS use real address)
         TOS R12 MOV,      \ load CRU adr to R12
         TOS POP,          \ refill TOS register
         NEXT,
         END-CODE

CODE: SBO ( -- )    \ you must set the CRU address first
         0 SBO,
         NEXT,
         END-CODE

CODE: SBZ ( -- )
         0 SBZ,
         NEXT,
         END-CODE

CODE: TB ( -- ? )
         TOS PUSH,  \ save current TOS register
         TOS CLR,
         0 TB,
         EQ IF,
            TOS SETO,
         ENDIF,
         NEXT,
         END-CODE


Edited by TheBF, Fri Feb 9, 2018 5:24 PM.


#1455 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Fri Feb 9, 2018 7:56 PM

CRU wordset in FB-Forth/TI-Forth observation/alternative.

...

Am I missing something Lee?

 

Probably not.  I would much rather have made fbForth follow the E/A Manual, but I did not want to break TI Forth code.  See §11.3 of the fbForth 2.0 Manual for a detailed description and Appendix H for a vertical representation of the code.

 

...lee



#1456 GDMike OFFLINE  

GDMike

    Star Raider

  • 88 posts

Posted Mon Feb 19, 2018 9:55 PM

Off subject, so sorry! BUT im trying to add your "DIR" catalog routine into a defined word such as  : test dir dsk1. ; but its not working. TB forth does not like the . period OR the whole command? I dunno, I just want to call the routine during runtime, as in dir dsk1.  thanks!

- Mike (GD mike). It's for my editor im putting together, a great way to learn some forth!



#1457 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Mon Feb 19, 2018 11:33 PM

Off subject, so sorry! BUT im trying to add your "DIR" catalog routine into a defined word such as  : test dir dsk1. ; but its not working. TB forth does not like the . period OR the whole command? I dunno, I just want to call the routine during runtime, as in dir dsk1.  thanks!

- Mike (GD mike). It's for my editor im putting together, a great way to learn some forth!

 

In this thread, no question about Forth and, especially, about fbForth is off subject/topic.

 

Regarding compiling DIR into the definition of another word:  DIR was written to expect the disk drive’s device name (“DSK1.”, “DSK2.”, ...) in the input stream.  What you want to do can probably be done, but not easily with the current definition of DIR .  Presuming you loaded the definition of DIR from FBLOCKS before you defined TEST (required), the interpreter choked on “DSK1.” because it did not find that word in the dictionary and then could not convert it to a number to compile as a literal that would get placed on the stack at runtime.  I would need to redefine DIR to expect the address of a string on the stack for this to work the same compiled into a definition as written on the command line.

 

What you want to do here can easily be done with CAT , however.  First, load the definition of CAT from FBLOCKS with

58 LOAD 

and then define TEST as

: TEST 1 CAT ; 

to catalog DSK1 when it is executed.  The interpreter will compile the ‘1’ as a literal that will get placed on the stack at runtime just before CAT is executed at runtime.

 

BTW, welcome aboard the Forth train—the more, the merrier!

 

...lee



#1458 GDMike OFFLINE  

GDMike

    Star Raider

  • 88 posts

Posted Tue Feb 20, 2018 1:39 AM

I couldn't find the page to load. It took me into floating point.. SO i went to DL TF again, thinking I may have the incorrect ver. SO the instructions i received say find the MODS folder and paste a couple of bin files, I do not have a MODs folder, Im using win 7

and classic 99 and it creates a config file on my desktop and that's seems to be all I can find - i never went through an install. - Ill go and find another classic99 package to run, maybe it will be there.


Edited by GDMike, Tue Feb 20, 2018 2:28 AM.


#1459 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Tue Feb 20, 2018 7:56 AM

I couldn't find the page to load. It took me into floating point.. SO i went to DL TF again, thinking I may have the incorrect ver. SO the instructions i received say find the MODS folder and paste a couple of bin files, I do not have a MODs folder, Im using win 7

and classic 99 and it creates a config file on my desktop and that's seems to be all I can find - i never went through an install. - Ill go and find another classic99 package to run, maybe it will be there.

 

I was talking about fbForth’s system blocks file, FBLOCKS.  I mistakenly thought you were talking about working in fbForth and trying the same thing in TurboForth (with its system blocks file, BLOCKS).  Sorry about that.

 

Also, the MODS folder is a Classic99 sub-folder.  The current version of Classic99 (v399a) has the current versions of fbForth and TurboForth built in.  You can certainly load a version of TF or fbF into the MODS folder yourself, but you should not need to do that.

 

...lee



#1460 GDMike OFFLINE  

GDMike

    Star Raider

  • 88 posts

Posted Sat Mar 10, 2018 6:45 AM

Thanks, I was in the process of "Physically Moving" to another house. Now I'm settled and forgot what I was doing prior? Oh, Right. Building a Directory. thanks for that tip Mr. Stewart I see where I went wrong now. I guess I'm also waiting on a Nano PEB to come available to purchase too. But it doesn't stop the Forth Train!!



#1461 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Tue Oct 23, 2018 9:51 AM

Sorry for such a long hiatus, folks.  |:)   My knee surgery in May went very well and I am fast returning to normalcy (well...I was probably never normal!).  My outdoor home projects are mostly behind me for this year—especially one that was particularly exhausting, now that I am 75.

 

I am aiming to officially release fbForth 2.0:11 by week’s end.  I know I said something like that back in January, but then lots of life got in the way.  If you are inclined to test the current beta, check post #1441 for the downloadable ZIP file.  Also, check posts prior to #1441 to see what has been added and fixed.

 

Ere long, I will put together an addendum to the manual and post it on my website (see below) to explain changes, bug fixes and new words.  If anyone finds errata in the manual or feels something about fbForth should be included in the manual, please let me know.

 

...lee



#1462 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Tue Nov 6, 2018 10:16 AM

I will not get to any updates of post #1 or my website in re  build 11 (fbForth 2.0:11) until after the Chicago Faire, but consider the beta_2 release of post #1441 the release of build 11.

 

I will have available at the Chicago Faire, fbForth 2.0:11 cartridges ($30 or free exchange) and EPROMs (small charge or free exchange) as well as some copies of the manual, fbForth 2.0: A File-Based Cartridge Implementation of TI Forth, for a little less than the Amazon.com price.

 

See you at CHI Friday and the Chicago Faire on Saturday!  :waving:

 

...lee



#1463 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Sat Nov 24, 2018 7:19 PM

 

Here are the character codes using fbForth 2.0’s CHAR :

Spoiler

 

After running the above code, I invoked the Font Editor with FONTED , but, alas, the Font Editor initializes by unconditionally changing to Graphics mode, which reloads the current, default font, overwriting the just changed character codes.  I should change the initializing code to not invoke Graphics mode if it is already there.  That way codes could be changed with the above Forth code and output to a font file from the Font Editor.

 

On second thought, it would be easy enough to write a word like yours that saves a font.  The Font Editor is, after all, for editing existing fonts.  | :)  There is already a way to change the current font by loading a font file, viz., “ USEFFL DSKn.<fontfile> ” followed by FNT .  And, if you only want to edit a font, it can be loaded into the Font Editor without changing the current, default font.  But, I digress...

 

...lee

 

As noted above (post #209 in the Camel99 thread), I discovered that you cannot save a font you have changed by using CHAR (or similar technique) followed by entering the Font Editor with FONTED because FONTED initializes by reloading the default font, destroying what you did earlier.  The following code will allow you to create a font file from manipulations of the Pattern Descriptor Table (Font table) outside of FONTED :

\ Save 1 KiB (128 chars) or 2 KiB (256 chars) font to file
HEX
PABS @         \ VRAM address for PAB
HERE           \ RAM addres for PAB-BUF (dummy not actually used)
PDT            \ VRAM address for PAB-VBUF (Pattern Descriptor Table)
FILE FONTFIL   \ associate above 3 addresses with FONTFIL
: SAVE-FONT ( 1|2 --- )  ( IS:fontfilename )
   CASE
      1 OF 400 ENDOF    \ 1 KiB font
      2 OF 800 ENDOF    \ 2 KiB font
      ELSEOF ." ERROR: Must be 1 or 2!" ABORT ENDOF
   ENDCASE
   FONTFIL SET-PAB   \ set up FONTFIL
   BL WORD HERE DUP C@ 1+ PAB-ADDR @ 9 + SWAP VMBW  \ filename->PAB
   SV                \ save 1 or 2 KiB of binary font image to file
;
DECIMAL 

You can save the above font as a 1 KiB (128 chars) or 2 KiB (256 chars) file (DSK1.FONT0230, say).  To  include all of the above-defined characters, you only need a 1-KiB font file, so the following code will do the job:

1 SAVE-FONT DSK1.FONT0230 

You can then use that font file with the following code, as usual:

USEFFL DSK1.FONT0230
FNT 

...lee



#1464 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Sun Nov 25, 2018 11:55 AM

As I looked at your code I realized that Chuck says "the dictionary is your case statement"

(or something like that)

 

Here is my interpretation of what that means in regards to your SAVE-FONT word.

HEX
400 CONSTANT 1K \ these replace the case statement
800 CONSTANT 2K

PABS @ \ VRAM address for PAB
HERE \ RAM addres for PAB-BUF (dummy not actually used)
PDT \ VRAM address for PAB-VBUF (Pattern Descriptor Table)
FILE FONTFIL \ associate above 3 addresses with FONTFIL

: CLIP ( n min max -- n') ROT MIN MAX ; ( one of my creations)

: SAVE-FONT ( bytes -- ) \ Usage: 1K SAVE-FONT
          DUP 0 2K CLIP \ could of course use your error code
          FONTFIL SET-PAB \ set up FONTFIL
          BL WORD HERE DUP C@ 1+ PAB-ADDR @ 9 + SWAP VMBW \ filename->PAB
          SV \ save 1 or 2 KiB of binary font image to file
;
DECIMAL

Another factor that I took from modern Forth practice is the word PLACE ( addr len  addr --)  

PLACE takes a string's address and length and puts it in memory as a counted string.  

 

A counted string is what a PAB needs so I created VPLACE to do the job.  This might be useful for SAVE-FONT

: VPLACE   ( $addr len Vaddr -- )  \ like PLACE, but for VDP RAM
           2DUP VSBW 1+ SWAP VMBW ;

It might clarify this line and VPLACE is generally useful for any string handling in VDP RAM.

\ so this...
BL WORD HERE DUP C@ 1+ PAB-ADDR @ 9 + SWAP VMBW

\ becomes this
BL WORD COUNT PAB-ADDR 9 + VPLACE

My 2 cents Canadian.  (about 1.44 cents USD so take it for what it's worth)



#1465 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Sun Nov 25, 2018 12:25 PM

I need to think on this a bit, but there are a couple of things that need changing for fbForth 2.02DUP requires loading block #41 of FBLOCKS or its own definition of

: 2DUP  ( n1 n2 --- n1 n2 n1 n2 )   OVER OVER  ;

and

BL WORD COUNT PAB-ADDR 9 + VPLACE

needs to be

BL WORD HERE COUNT PAB-ADDR @ 9 + VPLACE

because (1) WORD does not place an address on the stack but puts the counted string at HERE and (2) PAB-ADDR is a variable containing the VRAM address of the currently referenced PAB.

 

...lee



#1466 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Sun Nov 25, 2018 12:54 PM

Ah yes.  WORD in modern systems leaves HERE on the stack. I forgot about Fig-Forth usage.

 

And I double reference the PAB address to make a syntax of sorts.

I have a pointer ^PAB which is your PAB-ADDR variable.

 

I wrap (hide) ^PAB as a code word [PAB  which does a fast fetch and then I made a bunch of field access words CHAR], FNAME] etc. that just add an offset to [PAB.

This lets me write phrases like: 

 

HEX 50 [PAB RECLEN] VC!  

S" DSK1.MYFILE"  [PAB FNAME] VPLACE

 

This is all part of my obsession with trying to make Forth code readable later on. 

I have a hard time sorting out my old code if I don't go to these lengths.

 

All this to say the old adage is still true: "When you've seen one Forth, you have seen one Forth."

 

History from http://www.wilbaden....d/wnuvsn1f.html

Wil Baden interjected this at FORML, November 24, 1984, from the audience, responding to remarks of the speaker.

 

It's from an old family saying, going back to 1963. His six year old daughter corrected him after he said "When you've seen one, you have seen them all."

"No, Daddy. When you've seen one, you have seen one."



#1467 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Sun Nov 25, 2018 2:04 PM

This is all part of my obsession with trying to make Forth code readable later on. 

I have a hard time sorting out my old code if I don't go to these lengths.

 

My problem with a lot of this code is in my attempt to stay compatible with TI Forth.  It really does get in the way at times.

 

...lee



#1468 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Sun Nov 25, 2018 3:04 PM

 

My problem with a lot of this code is in my attempt to stay compatible with TI Forth.  It really does get in the way at times.

 

...lee

 

 

But it's a noble cause.  



#1469 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Sun Nov 25, 2018 5:21 PM

As I looked at your code I realized that Chuck says "the dictionary is your case statement"

(or something like that)

 

Oh—but did you notice the ELSEOF clause?  My inspiration for this was Willsy’s TurboForth word, default: .

 

...lee



#1470 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Sun Nov 25, 2018 8:06 PM

I did notice. It caught my eye right away.   Mr. Eaker would be proud of you.

It's a very nice addition.  Shows us the code.

 

I stole an addition from MPE Forth that you may like: (in ANS Forth)

: ?OF    ( flag -- here )
          POSTPONE DUP
          POSTPONE IF POSTPONE DROP  ; IMMEDIATE

With this one you can use the common comparison operators in your case statement as needed.

Sometimes it's handy for weird logic situations.



#1471 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Mon Nov 26, 2018 7:24 AM

The code and details for ELSEOF are back in post #1032.  It duplicates the CASE number on the stack to guarantee a match for the ELSEOF clause, which obviously must be the last clause within the CASE ... ENDCASE construct.  It also guarantees that ENDCASE never executes, obviating the convoluted code necessary between the last OF ... ENDOF clause and ENDCASE , when default processing is necessary:

: ELSEOF   Compile Time: ( 4 --- addr 5 )  Runtime: ( n --- )
  COMPILE DUP
  [COMPILE] OF
;  IMMEDIATE

...lee



#1472 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Mon Nov 26, 2018 10:31 AM

I stole an addition from MPE Forth that you may like: (in ANS Forth)

: ?OF    ( flag -- here )
          POSTPONE DUP
          POSTPONE IF POSTPONE DROP  ; IMMEDIATE

With this one you can use the common comparison operators in your case statement as needed.

Sometimes it's handy for weird logic situations.

 

In fbForth, this would be

: ?OF    \ compile-time: ( -- here 2 )  run-time: ( flag -- flag|[] )
          COMPILE DUP
          [COMPILE] IF COMPILE DROP  ; IMMEDIATE

I am having a little trouble seeing how I would use this, seeing as how fbForth’s IF also leaves 2 on the stack and ultimately requires THEN or ENDIF to consume here and 2 (compile-time check number) on the stack, but nothing within the CASE ... ENDCASE construct provides the same compile-time check number (2), which would throw an error when ; (at the end of the colon definition) is executed.

 

...lee


Edited by Lee Stewart, Tue Nov 27, 2018 7:39 AM.


#1473 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Mon Nov 26, 2018 8:24 PM

 

In fbForth, this would be

: ?OF    compile-time: ( -- here 2 )  run-time: ( flag -- flag|[] )
          COMPILE DUP
          [COMPILE] IF COMPILE DROP  ; IMMEDIATE

I am having a little trouble seeing how I would use this, seeing as how fbForth’s IF also leaves 2 on the stack and ultimately requires THEN or ENDIF to consume here and 2 (compile-time check number) on the stack, but nothing within the CASE ... ENDCASE construct provides the same compile-time check number (2), which would throw an error when ; (at the end of the colon definition) is executed.

 

...lee

 

It's use within the CASE statement so I think if you added added 2 ?PAIRS it would work like OF.

: ?OF    compile-time: ( -- here 2 )  run-time: ( flag -- flag|[] )
          2 ?PAIRS
          COMPILE DUP
          [COMPILE] IF COMPILE DROP  ; IMMEDIATE

But now that I try to use it I am having trouble so I might have slipped a neuron somewhere.



#1474 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,871 posts
  • Location:Silver Run, Maryland

Posted Mon Nov 26, 2018 9:45 PM

How is ?OF to be used?

 

...lee



#1475 TheBF OFFLINE  

TheBF

    Dragonstomper

  • 855 posts
  • Location:The Great White North

Posted Tue Nov 27, 2018 5:56 AM

A while back I was playing with it but I can't find the file. (i.e.: remember what project I was working on)

 

But as an example I wanted a case statement with range  of values for each case. So I used WITHIN that gives me a boolean flag and ?OF to test for true.







Also tagged with one or more of these keywords: fbForth, Forth, TI Forth

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users