\ basics 10/18/97 gwj create basics \ opposite of rot : -rot ( a b c -- c a b ) rot rot ; \ for variables used as flags : off ( addr -- ) false swap ! ; : on ( addr -- ) true swap ! ; \ different than the std word within \ but what I'm used to : within? ( n lo hi -- f ) rot tuck < -rot > or 0= ; \ assign a name to a unique value : unique.constant ( ; name -- ) here constant ; \ useful with execution vectors : perform ( 'xt -- ) @ execute ; \ help for simple data structures \ thanks Rick Hoselton : +constant ( n ; name -- ) create , does> ( base -- addr ) @ + ; \ useful for dealing with buffers \ thanks Rick Hoselton : 0allot ( len -- ) here over allot swap 0 fill ; \ print a number in hex : h. ( n -- ) base @ hex >r . r> base ! ; \ test for existence of a word \ thanks Ray Duncan : exists? ( ; word -- f ) 32 word find nip ; \ useful prompting word \ thanks Rick Hoselton : y/n? ( -- f ) begin key 32 or dup [char] y = over [char] n = or 0= while drop repeat [char] y = ; \ conditional include : require ( ; file -- ) >in @ exists? if drop else dup >in ! create >in ! include then ;