Post Reply 
FORTH Beginner Question.
09-06-2020, 09:31 PM
Post: #6
RE: FORTH Beginner Question.
Good answers already listed above, but keep in mind you need to set the proper numeric base (DECIMAL, HEX) before entering the amount to GROW, or you may grow by more (or less!) then you expected.

Not knowing the default base (you can always get it using "BASE @ .") can lead to confusion and unexpected results when first learning FORTH, and you should probably get in the habit of always specifying the base your code needs right at the top of the word definition source files. Another common technique is to preserve/restore the already existing default, by surrounding the word definitions in your source file as in:

: NEWNAME ( stack diagram )
( comments )
BASE @ ( Save the prior default base )
HEX ( or DECIMAL as you desire for use in your code )
CODE
CODE
CODE
BASE ! ; ( Restore the prior default )

You can change the base as often as you like to make your code easier for the reader (or you, months later) to understand what you're doing.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
FORTH Beginner Question. - twoweims - 09-06-2020, 06:49 PM
RE: FORTH Beginner Question. - twoweims - 09-06-2020, 07:59 PM
RE: FORTH Beginner Question. - rprosperi - 09-06-2020 09:31 PM
RE: FORTH Beginner Question. - twoweims - 09-07-2020, 02:09 AM
RE: FORTH Beginner Question. - rprosperi - 09-07-2020, 02:50 AM
RE: FORTH Beginner Question. - Jim Horn - 09-08-2020, 02:26 AM



User(s) browsing this thread: 1 Guest(s)