;;; Date: 31 Jan 1999 ;;; Version: 1.0 ;;; Copyright © 1999 Herman Mayfarth ;;; Permission granted to freely use without fee. ;;; Provided "as is" and without warranty, express or implied. ;;;--------------------------------------------------------- ;;; Converts a real to MTEXT fractional (not arch) representation ;;; Returns a string to be passed to MTEXT creation function ;;; Calling function must provide MTEXT vertical justification code ;;; Calling function must provide the inch mark if desired ;;;--------------------------------------------------------- (defun rtofrm ( inreal ; real to convert prec ; integer: desired precision of fraction ; must be at least 1 relht ; decimal: ht of fraction relative to whole # ; must have leading zero, i.e. 0.75, not .75 / ;local function fraction_code ;local symbols instrg i j k whole fract len ) (defun fraction_code (frac / ) (strcat "{\\H" (rtos relht 2 2) "x;\\S" frac ";}") );fraction_code ;;;initialize variables (setq i 1 instrg (rtos inreal 5 prec) len (strlen instrg) );setq (while (< i len) (if (= (substr instrg i 1) " ")(setq j i));found a space (if (= (substr instrg i 1) "/")(setq k i));found a slash (setq i (1+ i)) );while (cond ((and (null j)(null k)) (setq whole instrg)) ((null j) (setq whole (fraction_code instrg))) ( (setq whole (substr instrg 1 (1- j)) fract (fraction_code (substr instrg (1+ j))) whole (strcat whole fract) );setq ) );cond );rtofrm