Thank you.. I was also wondering about possible conflict with the numbers in parenthesis but I don't think it is (could still be wrong).
Your code appears to work fine (although without the closing parenthesis) but I can still see something going on in the background. Looking at the text screen readout afterwards, I see a pattern: for every execution of a layout copy there are (2) displays of Command: *Cancel* when the program is done.
My objective is to start with any given layout tab description and starting page number for ex. "XX (3)" and continue creating additional layout tabs with any desired description with the next incremental page number, for ex. "YY (4)" until the RETURN key terminates during the description prompt.
My code (again entered below) will successfully create and name the first new layout tab but the program crashes after setting to the new layout tab.
I need to have the layout tabs numbered and there will always be at least (1) numbered layout tab already existing.
Drawing file is attached. Below the program code I have pasted the text screen readout.
My code:
(defun C:lyt_test (/ dsc pg lyt)
(setq dsc (getstring "\nLayout description: ")
pg (getint "\nNew page #: ")
lyt (strcat dsc " (" (itoa pg) ")")
);setq
(command "layout" "c" (getvar "ctab") lyt);copies current tab
(command "layout" "s" lyt);makes the new layout current
(while
(/= dsc "")
(setq dsc (getstring "\nNEXT Layout description: ")
pg (+ pg 1)
lyt (strcat dsc " (" (itoa pg) ")")
);setq
(command "layout" "c" (getvar "ctab") lyt);copies current tab
(command "layout" "s" lyt);makes the new layout current
);while
);defun
Text screen readout:
Command: LYT_TEST
Layout description: SHT
New page #: 2
layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: c
Enter name of layout to copy <SHT (1)>: SHT (1)
Enter layout name for copy <SHT (2)>: SHT (2) Layout "SHT (1)" copied to "SHT (2)".
Command: layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: s
Enter layout to make current <SHT (1)>: SHT (2) Regenerating layout.
Command:
NEXT Layout description: *Cancel*
; error: Function cancelled
Command: *Cancel*
Command: 'VLIDE
Command: