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
>