So from time to time I run into situations where I find myself running the same series of commands over and over again. Previously if I felt it would save time I would bang out a quick little temporary sequencer routine so I could just hit enter and run the next command or autolisp function in the sequence, but now I'm trying to put together one I can define on the fly, and be something I can share around to other users in my company but I have hit one snag, I'm hoping someone has some good input. the code is as follows
Code:
;SEQUENCER DEFINITION FUNCTION
(DEFUN C:SETSEQUENCER ( / TX1 TX2) ;GLOBAL *SEQ-LIST* *SEQ-CNTR*
(SETQ *SEQ-LIST* (LIST) *SEQ-CNTR* 0)
(WHILE (NOT (= (SETQ TX1 (GETSTRING (STRCAT "ENTER COMMAND " (ITOA (+ 1 *SEQ-CNTR*)) ":\n "))) ""))
(IF <EVALUTAE IF TX1 IS AN AUTOCAD COMMAND>;<----------------------------------------------------------------need advice here
(SETQ TX2 "COM")
(PROGN (SETQ TX2 "FN" TX1 (STRCAT "C:" TX1))))
(SETQ *SEQ-LIST* (APPEND *SEQ-LIST* (LIST (LIST TX2 TX1))))
(SETQ *SEQ-CNTR* (+ 1 *SEQ-CNTR*))
)
(SETQ *SEQ-CNTR* 0)
(PRINC "SEQUENCE SET!\n")
(PRINC)
)
;MAIN SEQUENCER FUNCTION
(DEFUN C:SEQUENCER ( / TMP)
(IF (AND *SEQ-CNTR* *SEQ-LIST*) (PROGN
(SETQ TMP (NTH *SEQ-CNTR* *SEQ-LIST*))
(IF (= TMP NIL)
(PROGN
(SETQ *SEQ-CNTR* 0)
(SETQ TMP (NTH *SEQ-CNTR* *SEQ-LIST*))
))
(COND
((= (CAR TMP) "COM")
(PRINC (STRCAT "EXECUTING COMMAND " (ITOA (+ 1 SEQ-CNTR*))))
(COMMAND (CADR TMP)))
((= (CAR TMP) "FN")
(PRINC (STRCAT "EXECUTING COMMAND " (ITOA (+ 1 SEQ-CNTR*))))
(EVAL (LIST (READ (CADR TMP)))))
(T (PRINC)))
(SETQ *SEQ-CNTR* (+ 1 *SEQ-CNTR*))
))
(PRINC)
)
The part I've marked above is where I'm running into the snag. For debugging purposes I just used "OR" with several "=" functions to check if the code as a whole works, and it does. What I want to know is if anyone has an easier way to check if the string in TX1 correlates to an autocad command without using a cumbersome "OR" "=" "=" "=" "=" and manually putting in all the commands I can think of.
If nothing else I'll have the user input whether the input is an autocad command or a lisp function, but honestly we have some people here who don't know the difference so that route only really make the routine useful for myself. And I'd like to avoid unnecessary steps.
After I figure this bit I can spit shine this, its still kind of set up from my debugging.
Thanks all!