رد ﻪﻘﻠﺣ AutoLISP
رد ﻊﺑﺎﺗ ﻪﺳ AutoLISP
دﺎﺠﯾا رﻮﻈﻨﻣ ﻪﺑ ﻪﮐ دراد دﻮﺟو ﻪﻘﻠﺣ
ﺎﻬﻧآ زا ﻪﻣﺎﻧﺮﺑ رد ﻣ
ﯽ دﺮﮐ هدﺎﻔﺘﺳا ناﻮﺗ .
رد ﻊﺑﺎﺗ ﻪﺳ ﻦﯾا
هﺪﺷ هدروآ ﺮﯾز ﺪﻧا
.
ﻊﺑﺎﺗ ﻪﺑ طﻮﺑﺮﻣ دﺮﺑرﺎﮐ ﻦﯾﺮﺘﺸﯿﺑ While
ﺖﺳا .
(while testexpr [expr...])
Evaluates a test expression, and if it is not nil, evaluates other expressions; repeats this process until the test expression evaluates to nil
The while function continues until testexpr is nil.
Arguments testexpr
The expression containing the test condition.
expr
One or more expressions to be evaluated until testexpr is nil.
Return Values
The most recent value of the last expr.
Examples
The following code calls user function some-func ten times, with test set to 1 through 10. It then returns 11, which is the value of the last expression evaluated:
(setq test 1)
(while (<= test 10) (some-func test) (setq test (1+ test)) )
(foreach name list [expr...])
The foreach function steps through a list, assigning each element in the list to a variable, and evaluates each expression for every element in the list. Any number of expressions can be specified.
Arguments name
PDF created with pdfFactory Pro trial version www.pdffactory.com
Variable that each element in the list will be assigned to.
list
List to be stepped through and evaluated.
expr
Expression to be evaluated for each element in list.
Return Values
The result of the last expr evaluated. If no expr is specified, foreach returns nil.
Examples
Print each element in a list:
Command: (foreach n '(a b c) (print n)) A
B C C
foreach prints each element in the list and returns C, the last element. This command is equivalent to the following sequence of commands:
(print a) (print b) (print c)
except that foreach returns the result of only the last expression evaluated.
(repeat int [expr...])
Evaluates each expression a specified number of times, and returns the value of the last expression
Arguments int
An integer. Must be a positive number.
expr
One or more atoms or expressions.
PDF created with pdfFactory Pro trial version www.pdffactory.com
Return Values
The value of the last expression or atom evaluated. If expr is not supplied, repeat returns nil.
Examples
Command: (setq a 10 b 100) 100
Command: (repeat 4 (setq a (+ a 10)) (setq b (+ b 100))) 500
After evaluation, a is 50, b is 500, and repeat returns 500.
If strings are supplied as arguments, repeat returns the last string:
Command: (repeat 100 "Me" "You")
"You"
PDF created with pdfFactory Pro trial version www.pdffactory.com