Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GNU FORTH have an editor?

Tags:

forth

gforth

Chapter 3 of Starting FORTH says,

Now that you've made a block "current", you can list it by simply typing the word L. Unlike LIST, L does not want to be proceeded by a block number; instead it lists the current block.

When I run 180 LIST, I get

Screen 180 not modified     
0                                                                 
...                                                             
15                                                                 
 ok

But when I run L, I get an error

:30: Undefined word
>>>L<<<
Backtrace:
$7F0876E99A68 throw 
$7F0876EAFDE0 no.extensions 
$7F0876E99D28 interpreter-notfound1 

What am I doing wrong?

like image 660
NO WAR WITH RUSSIA Avatar asked Dec 03 '25 09:12

NO WAR WITH RUSSIA


2 Answers

Yes, gForth supports an internal (BLOCK) editor. Start gforth

  1. type: use blocked.fb (a demo page)
  2. type: 1 load
  3. type editor
  4. words will show the editor words,

    s b n bx nx qx dl il f y r d i t 'par 'line 'rest c a m  ok
    
  5. type 0 l to list screen 0 which describes the editor,

    Screen 0 not modified     
     0 \\ some comments on this simple editor                 29aug95py
     1 m marks current position        a goes to marked position       
     2 c moves cursor by n chars       t goes to line n and inserts    
     3 i inserts                       d deletes marked area           
     4 r replaces marked area          f search and mark               
     5 il insert a line                dl delete a line                
     6 qx gives a quick index          nx gives next index             
     7 bx gives previous index                                         
     8 n goes to next screen           b goes to previous screen       
     9 l goes to screen n              v goes to current screen        
    10 s searches until screen n       y yank deleted string           
    11                                                                 
    12 Syntax and implementation style a la PolyFORTH                  
    13 If you don't like it, write a block editor mode for Emacs!      
    14                                                                 
    15                                                                 
     ok
    

Creating your own block file

To create your own new block file myblocks.fb

  1. type: use blocked.fb
  2. type: 1 load
  3. type editor

Then

  1. type use myblocks.fb
  2. 1 load will show BLOCK #1 (lines 0 till 15. 16 Lines of 64 characters each)
  3. 1 t will highlight line 1
  4. Type i this is text to [i]nsert into line 1
  5. After the current BLOCK is edited type flush in order to write BLOCK #1 to the file myblocks.fb

For more information see, gForth Blocks

like image 71
Fred Zelders Avatar answered Dec 08 '25 00:12

Fred Zelders


It turns out these are "Editor Commands" the book says,

For Those Whose EDITOR Doesn't Follow These Rules

The FORTH-79 Standard does not specify editor commands. Your system may use a different editor; if so, check your systems documentation

I don't believe gforth supports an internal editor at all. So L, T, I, P, F, E, D, R are all presumably unsupported.

like image 24
NO WAR WITH RUSSIA Avatar answered Dec 08 '25 01:12

NO WAR WITH RUSSIA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!