+Lee Stewart Posted January 25, 2018 Author Share Posted January 25, 2018 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. Again, welcome aboard! ...lee Quote Link to comment Share on other sites More sharing options...
+TheBF Posted February 1, 2018 Share Posted February 1, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 1, 2018 Author Share Posted February 1, 2018 Cool! ...lee Quote Link to comment Share on other sites More sharing options...
+TheBF Posted February 9, 2018 Share Posted February 9, 2018 (edited) 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 February 9, 2018 by TheBF 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 10, 2018 Author Share Posted February 10, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
GDMike Posted February 20, 2018 Share Posted February 20, 2018 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! Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 20, 2018 Author Share Posted February 20, 2018 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 Quote Link to comment Share on other sites More sharing options...
GDMike Posted February 20, 2018 Share Posted February 20, 2018 (edited) 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 February 20, 2018 by GDMike Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 20, 2018 Author Share Posted February 20, 2018 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 Quote Link to comment Share on other sites More sharing options...
GDMike Posted March 10, 2018 Share Posted March 10, 2018 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!! 2 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted October 23, 2018 Author Share Posted October 23, 2018 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 5 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 6, 2018 Author Share Posted November 6, 2018 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! ...lee 2 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 25, 2018 Author Share Posted November 25, 2018 Here are the character codes using fbForth 2.0’s CHAR : \ FONT0230 pattern source code for CAMEL99 Forth \ ..converted to fbForth 2.0 HEX 0000 0000 0000 0000 20 CHAR 0010 1010 1000 1000 21 CHAR 0028 2828 0000 0000 22 CHAR 0028 7C28 287C 2800 23 CHAR 0038 5430 1854 3800 24 CHAR 0044 4C18 3064 4400 25 CHAR 0020 5020 5448 3400 26 CHAR 0008 1020 0000 0000 27 CHAR 0008 1010 1010 0800 28 CHAR 0020 1010 1010 2000 29 CHAR 0000 2810 7C10 2800 2A CHAR 0010 107C 1010 0000 2B CHAR 0000 0000 0030 1020 2C CHAR 0000 007C 0000 0000 2D CHAR 0000 0000 0030 3000 2E CHAR 0004 0810 2040 0000 2F CHAR 0038 4444 4444 3800 30 CHAR 0010 3010 1010 3800 31 CHAR 0038 4408 1020 7C00 32 CHAR 0038 4418 0444 3800 33 CHAR 0008 1828 487C 0800 34 CHAR 0078 4078 0444 3800 35 CHAR 0038 4078 4444 3800 36 CHAR 007C 0408 1020 2000 37 CHAR 0038 4438 4444 3800 38 CHAR 0038 4444 3C04 7800 39 CHAR 0000 3030 0030 3000 3A CHAR 0000 3030 0030 1020 3B CHAR 0000 1020 4020 1000 3C CHAR 0000 007C 007C 0000 3D CHAR 0000 1008 0408 1000 3E CHAR 0038 4408 1000 1000 3F CHAR 0038 4C54 5C40 3C00 40 CHAR 0038 4444 7C44 4400 41 CHAR 0078 4478 4444 7800 42 CHAR 0038 4440 4044 3800 43 CHAR 0078 4444 4444 7800 44 CHAR 007C 4078 4040 7C00 45 CHAR 007C 4078 4040 4000 46 CHAR 0038 4440 4C44 3800 47 CHAR 0044 447C 4444 4400 48 CHAR 0038 1010 1010 3800 49 CHAR 0004 0404 0444 3800 4A CHAR 0044 4850 7048 4400 4B CHAR 0040 4040 4040 7C00 4C CHAR 0044 6C54 4444 4400 4D CHAR 0044 6454 544C 4400 4E CHAR 007C 4444 4444 7C00 4F CHAR 0078 4444 7840 4000 50 CHAR 0038 4444 544C 3C00 51 CHAR 0078 4444 7848 4400 52 CHAR 0038 4430 0844 3800 53 CHAR 007C 1010 1010 1000 54 CHAR 0044 4444 4444 3800 55 CHAR 0044 4444 4428 1000 56 CHAR 0044 4444 5454 2800 57 CHAR 0044 2810 1028 4400 58 CHAR 0044 4428 1010 1000 59 CHAR 007C 0810 2040 7C00 5A CHAR 0038 2020 2020 3800 5B CHAR 0000 4020 1008 0400 5C CHAR 0038 0808 0808 3800 5D CHAR 0010 2844 0000 0000 5E CHAR 0000 0000 0000 7C00 5F CHAR 0020 1008 0000 0000 60 CHAR 0000 0038 4848 3C00 61 CHAR 0020 2038 2424 3800 62 CHAR 0000 001C 2020 1C00 63 CHAR 0004 041C 2424 1C00 64 CHAR 0000 0018 2C30 1C00 65 CHAR 000C 103C 1010 1000 66 CHAR 0000 001C 241C 0438 67 CHAR 0020 2038 2424 2400 68 CHAR 0010 0030 1010 3800 69 CHAR 0008 0008 0808 4830 6A CHAR 0020 2024 3828 2400 6B CHAR 0030 1010 1010 3800 6C CHAR 0000 0078 5454 5400 6D CHAR 0000 0038 2424 2400 6E CHAR 0000 0018 2424 1800 6F CHAR 0000 0038 2438 2020 70 CHAR 0000 001C 241C 0404 71 CHAR 0000 0028 3420 2000 72 CHAR 0000 001C 300C 3800 73 CHAR 0010 1038 1010 0C00 74 CHAR 0000 0024 2424 1C00 75 CHAR 0000 0044 2828 1000 76 CHAR 0000 0044 5454 2800 77 CHAR 0000 0024 1818 2400 78 CHAR 0000 0024 241C 0438 79 CHAR 0000 003C 0810 3C00 7A CHAR 000C 1010 2010 100C 7B CHAR 0010 1010 0010 1010 7C CHAR 0060 1010 0810 1060 7D CHAR 0000 2054 0800 0000 7E CHAR DECIMAL 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 1 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 25, 2018 Share Posted November 25, 2018 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) 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 25, 2018 Author Share Posted November 25, 2018 I need to think on this a bit, but there are a couple of things that need changing for fbForth 2.0. 2DUP 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 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 25, 2018 Share Posted November 25, 2018 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.com/neil_bawd/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." 2 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 25, 2018 Author Share Posted November 25, 2018 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 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 25, 2018 Share Posted November 25, 2018 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. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 25, 2018 Author Share Posted November 25, 2018 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 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 26, 2018 Share Posted November 26, 2018 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. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 26, 2018 Author Share Posted November 26, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 26, 2018 Author Share Posted November 26, 2018 (edited) 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 November 27, 2018 by Lee Stewart Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 27, 2018 Share Posted November 27, 2018 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. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 27, 2018 Author Share Posted November 27, 2018 How is ?OF to be used? ...lee Quote Link to comment Share on other sites More sharing options...
+TheBF Posted November 27, 2018 Share Posted November 27, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.