Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

show alert if not true

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
323 Views, 10 Replies

show alert if not true

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
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

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

"Kiwi Russ" wrote in message
news:0FB67C05AAD4AAE3A48774FAC7B618EC@in.WebX.maYIadrTaRb...
> 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
>
>
Message 3 of 11
Anonymous
in reply to: Anonymous

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
Message 4 of 11
Anonymous
in reply to: Anonymous

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


"Kiwi Russ" wrote in message
news:4A541CC7F0B23A5A16DA052E059F198C@in.WebX.maYIadrTaRb...
> 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
>
>
Message 5 of 11
Anonymous
in reply to: Anonymous

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

(< "A" "B")
T

-David


Kiwi Russ wrote:
> 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
>
>
Message 6 of 11
Anonymous
in reply to: Anonymous

How about just deriving a valid revision from the old rev?

;;; A function to "increment" a letter

;;; The argument is a string (usually one character long)

;;; Returns a string containing the letter after the first letter of
;;; the argument string, except I, O and Q are skipped.

(defun incr_ltr (string / tempstr)
(setq tempstr (chr (1+ (ascii string))))
(if (or (= tempstr "O") (= tempstr "I") (= tempstr "Q"))
(setq tempstr (chr (1+ (ascii tempstr))))
)
(eval tempstr)
)

;;; BUMPREV increments the string passed to it, either a letter or a
;;; number

(defun bumprev (oldrev / rev_chars last_char)
;; Check for zero-length string
(if (= (strlen oldrev) 0)
(setq oldrev "0")
)
;; Check for validity of the string (last character
;; must be a letter or numeral)
(if
(or
(wcmatch
(setq
last_char (strcase (substr oldrev
(setq rev_chars (strlen oldrev))
1
)
)
)
"@"
)
(wcmatch last_char "#")
)
;; If it's an alphabetic revision ...
(if (>= last_char
"A"
)
;; increment the letter
(if (= last_char "Z")
;; Got to Z, need to increment first character (this
;; won't work right after rev ZZ)
(if (> rev_chars 1)
;; It's already a two letter revision
(setq oldrev (strcat (incr_ltr oldrev) "A"))
;; It's rev Z, go to AA
(setq oldrev "AA")
)
;; The last character isn't Z, all we need to do is
;; increment the last character
(if (> rev_chars 1)
;; It's a two-letter revision, increment the last
;; letter
(setq oldrev (strcat (substr oldrev 1 1)
(incr_ltr (substr oldrev
rev_chars
1
)
)
)
)
;; It's a one letter revision, just increment it
(setq oldrev (incr_ltr oldrev))
)
)
;;it's a number revision, increment it
(setq oldrev (itoa (1+ (atoi oldrev))))
)
;; The original string is not a valid thing to increment,
;; take our best guess
(setq oldrev "1")
)
)


--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services

In article <0FB67C05AAD4AAE3A48774FAC7B618EC@in.WebX.maYIadrTaRb>, Kiwi Russ
wrote:
> 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
>
Message 7 of 11
Anonymous
in reply to: Anonymous

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.


"Kiwi Russ" wrote in message
news:0FB67C05AAD4AAE3A48774FAC7B618EC@in.WebX.maYIadrTaRb...
> 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
>
>
Message 8 of 11
Anonymous
in reply to: Anonymous

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

"Kiwi Russ" wrote in message
news:0FB67C05AAD4AAE3A48774FAC7B618EC@in.WebX.maYIadrTaRb...
> 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
>
>
Message 9 of 11
Anonymous
in reply to: Anonymous

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.
___

"Kiwi Russ" wrote in message
news:0FB67C05AAD4AAE3A48774FAC7B618EC@in.WebX.maYIadrTaRb...
> 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
>
>
Message 10 of 11
Anonymous
in reply to: Anonymous

Many thanks!!! everyone.
I have it solved now
cheers Russ
Message 11 of 11
Anonymous
in reply to: Anonymous

Russ,

And the solution was... ?

Joe Burke

"Kiwi Russ" wrote in message news:f18a035.8@WebX.maYIadrTaRb...
> Many thanks!!! everyone.
> I have it solved now
> cheers Russ
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report