\ User interface for automatic unit conversion on \ data entry and display \ --------------------------------------------------- \ (c) Copyright 1999 Julian V. Noble. \ \ Permission is granted by the author to \ \ use this software for any application pro- \ \ vided this copyright notice is preserved. \ \ --------------------------------------------------- \ This is an ANS Forth program requiring the CORE and \ CORE EXT wordsets MARKER -units VARIABLE \ name its location : as TRUE ! ; : ~as FALSE ! ; ~as : units CREATE ( SWAP) , , DOES> 2@ @ IF SWAP THEN */ ~as ; VARIABLE \ redefine to hide it \ With the definitions below the internal units are millimeters; \ this works fine on 16-bit systems. 254 10 units inches 254 12 * 10 units feet 254 36 * 10 units yards 10 1 units centimeters 1000 1 units meters \ For finer grain--say 0.01 mm (suitable for 32-bit systems)-- \ multiply by 100, as in 25400 10 units inches FALSE [IF] Usage: 10 FEET . 3048 ok 3 METERS . 3000 ok ....................... etc. 10 FEET . 3048 ok 3048 AS FEET . 10 ok [THEN]