Multiple statements in a IF function

155 views Asked by At

Part of a custom command I have written I'm trying to have the IF function read thru 3 different statements but I'm finding out its not as straight forward as I initially thought it would be. I commented on the below piece of code what I would like each line to do. I'm wondering if there is a way to get this done thru an IF statment that I'm overlooking or if there is a different method I should be looking at instead.

 (if (or (/= flr "0_01.") ;if variable "FLR" is not 0.01 and
     (/= flr "4_01.") ;if its not 4_01, and
     (/= flr "6_01.") ;if its not 6_01...
     );if
  (progn ;then....
    ;repath an xref using the already established variables
    (command "-xref" "p" afile afilepathname))
  (Progn
    (princ "/n This is a model file") 
    );progn
  );if

I've tried using Cond to get this same result but I can't seem to find a day due to the "FLR" variable needing to be looked at and verified its not "0_01", "4_01", or "6_01" before the command can proceed any further.

1

There are 1 answers

1
gileCAD On

If I do not misunderstand your goal (reading the comments in the code), this is a logic issue. You should use 'and' instead of 'or':

(if (and (/= flr "0_01.")       ; if variable "FLR" is not 0.01 and
     (/= flr "4_01.")       ; if it's not 4_01, and
     (/= flr "6_01.")       ; if it's not 6_01...
    ) ;_ and
  (progn                ; then....
    ;; repath an xref using the already established variables
    (command "-xref" "p" afile afilepathname)
  ) ;_ progn
  (progn
    (princ "/n This is a model file")
  ) ;_ progn
) ;_ if

Or:

(if (or (= flr "0_01.")         ; if variable "FLR" is 0.01 or
    (= flr "4_01.")         ; if it's 4_01, or
    (= flr "6_01.")         ; if it's 6_01...
    ) ;_ or
  (progn                ; then....
    (princ "/n This is a model file")
  ) ;_ progn
  ;; else, repath an xref using the already established variables
  (progn
    (command "-xref" "p" afile afilepathname)
  ) ;_ progn
) ;_ if