clint0577 Posted December 5, 2012 Posted December 5, 2012 I have a routine that I'm working on, which is my first attempt using COND and IF, and I'm running into a problem with how to end the routine. Towards the end, I have (IF (EQ YR "N.F.H.A.") (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "") I need it to skip (setq L3 (getstring t "\nType Flood Panel Number: ")) (setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": " )) (SETQ L4 (STRCAT "DATE " FD)) (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 "")) if the statement is true, otherwise continue on. I'm sure this is an easy fix, I'm just not seeing it. Thanks in advance. here is everything (DEFUN c:LF () (SETQ CL (GETVAR "CLAYER")) (command "layer" "M" "FLOOD" "C" "70" "" "L" "BORDER2" "" "S" "FLOOD" "") (command ".osnap" "NONE") (setq DS (getvar 'dimscale)) (SETQ TW (* DS 1.3)) (SETQ TH (* DS 0.07)) (setq pt1 (getpoint "\nPick Insertion Point: ")) (SETQ L1 (STRCAT "APPROX. LOCATION")) (if (eq (setq ZN (getstring T "\nFlood Zone A, AE or X?: <X> ")) "") (setq zn "X")) (COND ((EQ ZN "A") (setq YR "100")) ((EQ ZN "AE") (SETQ yr "100")) (t (IF (EQ (setq YR (getstring T "\n500 or NFHA? <NFHA> : ")) "") (SETQ YR "N.F.H.A.")))) (COND ((EQ YR "100") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) ((EQ YR "500") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) (T (SETQ L2 (STRCAT "ZONE " ZN " " YR )))) ;===============================PAST THIS POINT IS WHERE I'M HAVING THE ISSUE======================================================= (IF (EQ YR "N.F.H.A.") (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "") (setq L3 (getstring t "\nType Flood Panel Number: ")) (setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": " )) (SETQ L4 (STRCAT "DATE " FD)) (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 "")) (COMMAND "CLAYER" CL) ) Quote
clint0577 Posted December 5, 2012 Author Posted December 5, 2012 So I'm close... That's good news. Quote
clint0577 Posted December 5, 2012 Author Posted December 5, 2012 Thanks Lee Mac for not giving me the solution. I did a little research and got it! (DEFUN c:LF () (SETQ CL (GETVAR "CLAYER")) (command "layer" "M" "FLOOD" "C" "70" "" "L" "BORDER2" "" "S" "FLOOD" "") (command ".osnap" "NONE") (setq DS (getvar 'dimscale)) (SETQ TW (* DS 1.3)) (SETQ TH (* DS 0.07)) (setq pt1 (getpoint "\nPick Insertion Point: ")) (SETQ L1 (STRCAT "APPROX. LOCATION")) (if (eq (setq ZN (getstring T "\nFlood Zone A, AE or X?: <X> ")) "") (setq zn "X")) (COND ((EQ ZN "A") (setq YR "100")) ((EQ ZN "AE") (SETQ yr "100")) (t (IF (EQ (setq YR (getstring T "\n500 or NFHA? <NFHA> : ")) "") (SETQ YR "N.F.H.A.")))) (COND ((EQ YR "100") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) ((EQ YR "500") (SETQ L2 (STRCAT "ZONE " ZN " " YR "YR"))) (T (SETQ L2 (STRCAT "ZONE " ZN " " YR )))) ;===============================NOT AN ISSUE ANYMORE!!======================================== (IF (EQ YR "N.F.H.A.") (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 "") (progn (setq L3 (getstring t "\nType Flood Panel Number: ")) (setq FD (getstring t "\nType Flood Panel Date \"MM/DD/YY\": " )) (SETQ L4 (STRCAT "DATE " FD)) (COMMAND "MTEXT" "_non" pt1 "J" "MC" "S" "STANDARD" "H" TH "W" TW L1 L2 L3 L4 ""))) (COMMAND "CLAYER" CL) ) Quote
Lee Mac Posted December 5, 2012 Posted December 5, 2012 Thanks Lee Mac for not giving me the solution. I did a little research and got it! Nice one Clint - well done! A few pointers to help improve your code some more: Remember to Localise your Variables Use conditional expressions (if / cond) to allow for null user input when prompting the user (e.g. getpoint) strcat is not required unless concatenating two or more strings. Use (princ) or (prin1) to suppress the return of the last evaluated expression and exit the command 'cleanly'. Consider using a redefined *error* function to reset System Variable values should the user press Esc or the program encounter an error. 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.