<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>
Constants simply allow the Forth programmer to use a word to represent a number. Once declared, their value cannot be changed. There are three reasons for using Constants in Forth programs:
Constants should be declared outside of a colon definition, like this:
99 CONSTANT NinetyNine
As can be seen, CONSTANT requires a number on the stack, followed by the name of the constant to create.
Using constants in your code could not be simpler; simply name them. For example:
99 CONSTANT NinetyNine : TEST NinetyNine 0 DO I . LOOP ;
<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>