www.delorie.com/gnu/docs/gforth/gforth_100.html   search  
 
Buy GNU books!


Gforth Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.4 Values

A Value behaves like a Constant, but it can be changed. TO is a parsing word that changes a Values. In Gforth (not in ANS Forth) you can access (and change) a value also with >body.

Here are some examples:

 
12 Value APPLES     \ Define APPLES with an initial value of 12
34 TO APPLES        \ Change the value of APPLES. TO is a parsing word
1 ' APPLES >body +! \ Increment APPLES.  Non-standard usage.
APPLES              \ puts 35 on the top of the stack.

doc-value doc-to


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003