show alert if not true

Discussion in 'AutoCAD' started by Kiwi Russ, Sep 14, 2003.

  1. Kiwi Russ

    Kiwi Russ Guest

    I have a statment below which I can't get to work. Basically revision
    letters need to be A then B then C then D etc If the revision letters are
    not in this order then I want to show awarning.
    In other words:
    If RevLettOld equals "A" and RevLettNew equals "B"
    or RevLettOld equals "B" and RevLettNew equals "C"
    or RevLettOld equals "C" and RevLettNew equals "D"
    and so on right through the alphabet
    then proceed
    however if for example RevLettOld equals "A" and RevLettNew equals C or D or
    E or F G etc
    and so then show alert box with warning message.
    I guess I could make the statement :
    if RevLettOld equals "A" and RevLettNew equals "C" or "D" or "E" or "F"
    or "G" or "H" etc
    and
    if RevLettOld equals "B" and RevLettNew equals "D" or "E" or "F" or "G" or
    "H" etc
    etc etc etc
    then show alert box
    But I think this is a little cumbersome. Surely there must be a better way
    to write the above expression

    here is my attempt, but I can't seem to get it right

    (if
    (not
    (and
    (= RevLettOld "A")
    (= RevLettNew "B")
    );and

    (or
    (and
    (= RevLettOld "B")
    (= RevLettNew "C")
    );and
    );or

    (or
    (and
    (= RevLettOld "C")
    (= RevLettNew "D")
    );and
    );or

    );not

    (progn
    (alert (strcat"\nRe-check rev letter and try again.... "

    );strcat
    );alert
    );progn

    );if

    thanks Russ
     
    Kiwi Russ, Sep 14, 2003
    #1
  2. Kiwi Russ

    Joe Burke Guest

    Hi Russ,

    Doubtful I understand what you are trying to do. But I wonder if you could just
    check to see if a list is in ascending order?

    (setq lst '("A" "B" "C" "D"))
    (if (not (equal lst (vl-sort lst '<)))
    (princ "alert")
    (princ "OK")
    )

    Joe Burke
     
    Joe Burke, Sep 14, 2003
    #2
  3. Kiwi Russ

    Kiwi Russ Guest

    Hi Joe
    I have an attributed title block and one of the tags is the
    revision letter. I'm trying to compare the old revision letter with the new
    revision letter. If "A" is not followed by a "B" or "B" is NOT followed by a
    "C" etc then I want to show a warning so that the user must type in a "B" if
    the existing rev is a "A" and so on.
    I hope that makes sense
    cheers
    Russ
     
    Kiwi Russ, Sep 14, 2003
    #3
  4. Kiwi Russ

    Tom Berger Guest

    (if (= 1 (- (ASCII RevLettNew) (ASCII RevLettOld)))
    thendothis
    (alert "wrong")
    )

    Tom Berger
     
    Tom Berger, Sep 14, 2003
    #4
  5. Kiwi Russ

    Joe Burke Guest

    Russ,

    Let's try this to see if I understand. Assume you know the old/existing revision
    letter is "A". You prompt the user for a new revision letter to replace "A",
    which must be "B", otherwise alert. The function needs to deal with whatever the
    old revision letter was. If it was "R", the user must enter "S". You can't use
    initget and getkword because those don't work with getstring.

    Am I on the right track? If not, it's not your fault. I seem to have my
    thick-head on this evening.

    If the above is correct, maybe the ascii function as follows.

    (setq existing (ascii "A")) ;example - returns integer
    (setq new (< prompt for new revision letter >))
    (if (not (= (1+ existing) (ascii new)))
    (princ "alert")
    )

    Totally untested, Russ.

    Joe Burke
     
    Joe Burke, Sep 14, 2003
    #5
  6. Kiwi Russ

    David Bethel Guest

    Strings comply with greater than (> ...) & less than (< .... )
    AutoLISP functions.

    (< "A" "B")
    T

    -David
     
    David Bethel, Sep 14, 2003
    #6
  7. Kiwi Russ

    Tom Berger Guest

    Yea, but (< "A" "C") also evaluates to T

    Tom Berger
     
    Tom Berger, Sep 14, 2003
    #7
  8. Kiwi Russ

    Rudy Tovar Guest

    If you plan on incrementing revisions, don't forget that not all sheets are
    affect by a revision, so you may even have to skip a revision.

    In the case of a Plan Checker he may or may not find an issue on one or more
    sheets. There are also client revisions, design revisions, and inhouse
    revisions to consider. so you may have a sheet with a revision of 1, 3, 4,
    5, 7 etc.

    Just my 2 cents.
     
    Rudy Tovar, Sep 14, 2003
    #8
  9. You can force the input with initget and getkword.

    (setq a "A")
    (initget (chr (1+ (ascii a))))
    (setq b (getkword (strcat "Old Rev.: " a "--Input new Rev.:")))

    --
    Ken Alexander
    Acad2000
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Sep 15, 2003
    #9
  10. Kiwi Russ

    Paul Turvill Guest

    You need just one (or ...) clause:

    (if
    (not
    (or ...
    (and ... ;;A/B
    );;and
    (and ... ;;B/C
    );;and
    (and ... ;;C/D
    );;and
    );;or
    );;not
    (alert "Your Message")
    (progn
    (do stuff)
    (do more stuff)
    );;progn
    );;if

    However, there are more efficient ways of doing what you want; see some of
    the other replies.
    ___
     
    Paul Turvill, Sep 15, 2003
    #10
  11. Kiwi Russ

    Kiwi Russ Guest

    Many thanks!!! everyone.
    I have it solved now
    cheers Russ
     
    Kiwi Russ, Sep 16, 2003
    #11
  12. Kiwi Russ

    Joe Burke Guest

    Russ,

    And the solution was... ?

    Joe Burke
     
    Joe Burke, Sep 16, 2003
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.