1 - Forth Interest Group
1 - Forth Interest Group
1 - Forth Interest Group
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
To include more than one line when name is not found:<br />
HAVING name 0 [ IF]<br />
- whatever-<br />
[ THEN]<br />
LACKING ( " name" -- )<br />
: LACKING ( "name" -- )<br />
BL WORD FIND NIP<br />
IF POSTPONE \ THEN<br />
; IMMEDIATE<br />
If name is not found, interpret the rest of the line; otherwise,<br />
skip the line. This is IMMEDIATE and can be used in a<br />
definition.<br />
LACKING is generally used before defining the name that<br />
is lacking.<br />
Start compiling a nonce word. The same as:<br />
Used extensively for data initialization and testing.<br />
Use ; ; to complete the definition, execute it, and forget it.<br />
Nonce words let you execute loops from the keyboard.<br />
They also allow you to initialize data structures programmatically<br />
with no overhead.<br />
Nonce words wouldn't be needed with self-compiling:<br />
IF BEGIN DO DO<br />
From the Random House Dictionary:<br />
nonce word, a word coined and used only for the particular<br />
occasion.<br />
Finish compiling a nonce word, execute it, and forget it. If<br />
errors occur, start over or type NONCE to recover. The same as<br />
Procedarnus in pace.<br />
Wil Baden<br />
; NONCE-DEF NONCE<br />
ANEW NONCE : NONCE-DEF / [ THEN] [ THEN] [ THEN]<br />
Continued from page 29<br />
24 [ ELSE]<br />
2 6 CREATE upper-case-map 256 CHARS ALLOT<br />
28 ( Initialize the map to change characters into themselves. )<br />
29 :: 256 0 DO I upper-case-map I CHARS + C! LOOP ;;<br />
31 ( Replace the lower-case letters with upper-case. )<br />
32 :: [CHAR] a 26 BOUNDS DO<br />
33 I BL XOR upper-case-map I CHARS + C! LOOP<br />
34 ..<br />
I I<br />
3 6 ( Convert to upper-case by 'addr + C@ ' inline. )<br />
3 7 : UP-CHAR S" CHARS upper-case-map + C@ " EVALUATE ; IMMEDIATE<br />
39 : DOWN-CHAR BL XOR UP-CHAR BL XOR ;<br />
41 [ THEN] [ THEN] -<br />
43 ( Convert string to upper-case. )<br />
44 : UP-STRING ( a u - - )<br />
4 5 0 DO DUP C@ UP-CHAR OVER C! CHAR+ LOOP DROP<br />
46 ;<br />
48 SEE UP-STRING CR<br />
Neil Bawd<br />
Goat Hill, California<br />
"Anywhere is interesting for 15 minutes, except maybe Iowa."<br />
<strong>Forth</strong> Dimensions XlWl 27