TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hrishikesh on July 26, 2017, 09:32:37 AM
-
Hi,
Is it possible to use one loop multiple times in same loop? Or more than one loop under another loop?
example
1.
(repeat
(repeat
..........
..........
)
)
2.
(foreach
(foreach
(foreach
.............
.............
.............
)
)
)
3.
(repeat
(foreach
.............
.............
)
)
Thanks,
Hrishikesh
-
In round about ways you can, the question would be why?
-
the question would be why?
Today I am doing some Automation in Excel, looping some functions in one formula to obtain results.
I know Excel & Autolisp has different platforms for different purposes but I am just curious that can it be possible in autolisp & how?
Becase excel vba or excel itself has different syntex than autolisp.
Just a curiosity...
-
Certainly possible: since the expression argument for each of these looping functions is arbitrary, it may of course itself be an expression evaluating another looping function, e.g.:
"a" 1
"a" 2
"a" 3
"b" 1
"b" 2
"b" 3
"c" 1
"c" 2
"c" 3
"d" 1
"d" 2
"d" 3
As a more practical example, consider the following program which uses a nested repeat expression to iterate over every cell in a selected AutoCAD table:
(defun c:test
( / col obj row sel
) (if (setq sel
(ssget "_+.:E:S:L" '
((0 .
"ACAD_TABLE")))) )
)
)
)
)
-
Thanks Lee :-)