viviancarvalho Posted October 21, 2009 Posted October 21, 2009 I am finding difficulty in getting this well done. It does gives me the end result of the calculation but not in the way i actually want. Please help. (defun c:cf(/ sm,cfm,q) (setq sm (getreal "\n PLEASE ENTER AREA IN SQ.MT : ") q (getreal "\n PLEASE ENTER THE REF FACTOR : ") cfm (getreal(* q(* 10.76 sm)))) (alert"THE REQUIRED CFM FOR THIS AREA IS" cfm)) Quote
MSasu Posted October 21, 2009 Posted October 21, 2009 Please take care that the GETREAL statement don’t accept another AutoLISP function as argument; however you can discontinue it’s usage since the result of the calculation is already a real number. And ALERT accept only one argument, so you need to concatenate the string - don't forget to convert the number: (alert (strcat "THE REQUIRED CFM FOR THIS AREA IS: " (rtos cfm))) Regards, Quote
viviancarvalho Posted October 21, 2009 Author Posted October 21, 2009 Thanks for that. It made my life more easier Quote
MSasu Posted October 21, 2009 Posted October 21, 2009 You are welcomed! Reading again my post just realizes that I wasn’t just right: the GETREAL statement will not accept an AutoLISP expression as response; however you may use an expression to construct the prompter: (getreal (strcat "Input the length <" (rtos Var 2 2) ">: ")) Sorry for inconvenience! Regards, Quote
MSasu Posted October 21, 2009 Posted October 21, 2009 Another issue that missed first time – the separator for local variables should be space not comma (even if this doesn’t raise a fatal error): Wrong syntax: defun c:cf(/ sm,cfm,q Right syntax: defun c:cf(/ sm fm q) Regards, Quote
viviancarvalho Posted October 21, 2009 Author Posted October 21, 2009 Yes i got it at ur first reply itself. thanks again. Quote
alanjt Posted October 21, 2009 Posted October 21, 2009 You should look into cond, and, if statement use to trap errors. If you don't enter a value for SM or Q, the routine will error. (defun c:CF (/ SM Q) (and (setq SM (getreal "\nArea in Sq. Mt: ")) (setq Q (getreal "\nRef. Factor: ")) (alert (strcat "Required CFM for area: " (rtos (* Q (* 10.76 SM))))) ) ;_ and (princ) ) ;_ defun Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.