-
Notifications
You must be signed in to change notification settings - Fork 9
Tour
ww edited this page Dec 6, 2014
·
17 revisions
A first view on the console and the command line. - TclForth changes the standard Forth command line just a little:
Strings need no space after the first "
ok> "Hello World"
({Hello World}) ok> . cr
Hello World
ok>
The command line evaluates immediate words.
ok> 7 0 do I . loop
0 1 2 3 4 5 6 ok>
ok>
Stack diagrams are enclosed in braces. The parameters are treated as local variables.
ok> : Star { -- } "*" . ;
ok> Star
* ok>
Here is a simple structure added by TclForth.
ok> : Stars { n -- } n times Star repeat ;
ok> 5 Stars
* * * * * ok
ok> : Grid { n m -- } n times m Stars cr repeat
ok> 3 4 Grid
* * * *
* * * *
* * * *
ok>
Say, you prefer to print the grid without trailing spaces: simply redefine Star.
ok> : Star {} "*" ascii emit ;
ok> 3 4 Grid
****
****
****
Tcl replaces code in a loaded word. The change is active also for all dependent words. - You can change a running TclForth program.
TclForth makes good use of the variable substitutions in Tcl.
ok> 33 variable V
ok> "The value of V is $V" . cr
The value of V is 33
ok>
Work on the GUI: Add a command to the help menu.
ok> : SayHello {} "Hello TclForth!" . cr ;
ok> "Hello!" {SayHello} hMenu addcommand
And try it.
Enjoy exploring TclForth!