Next: , Previous: , Up: Forth Words   [Contents][Index]


5.4 Boolean Flags

A Boolean flag is cell-sized. A cell with all bits clear represents the flag false and a flag with all bits set represents the flag true. Words that check a flag (for example, IF) will treat a cell that has any bit set as true.

true ( – f  ) core-ext “true”

Constantf is a cell with all bits set.

false ( – f  ) core-ext “false”

Constantf is a cell with all bits clear.

on ( a-addr –  ) gforth-0.4 “on”

Set the (value of the) variable at a-addr to true.

off ( a-addr –  ) gforth-0.4 “off”

Set the (value of the) variable at a-addr to false.

select ( u1 u2 f – u ) gforth-1.0 “select”

If f is false, u is u2, otherwise u1.