TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andrew_nao on June 27, 2011, 09:50:48 AM

Title: can you use a list as an argument?
Post by: andrew_nao on June 27, 2011, 09:50:48 AM
is it possible or suggested to use a list as an argument?

i have a sub function that creates a list and i want to use this list in other sub functions is it a good idea to do this?

im trying to keep the list variable to this code only without it getting in the way of other code.

any help or guidance is appreciated

Code: [Select]
(defun test (/ datafile file_content_list)
 (setq datafile (strcat "C:\\dwg-history" (menucmd "M=$(edtime,$(getvar,date), MON DD YYYY)") ".txt"))
  (setq ofile (open datafile "r")) 
  (while (setq curline (read-line ofile)) 
    (setq file_content_list (cons curline file_content_list)) 
  ) 
  (close ofile) 
  (setq file_content_list (reverse file_content_list))
  )
Title: Re: can you use a list as an argument?
Post by: Lee Mac on June 27, 2011, 09:58:50 AM
Since in LISP a value of any datatype can be bound to a symbol, any datatype may be passed as an argument.
Title: Re: can you use a list as an argument?
Post by: hermanm on June 27, 2011, 10:23:48 PM
and in fact, to my knowledge, passing a list of varying length is the only way to pass a variable number of arguments to an AutoLISP function written in AutoLISP.
Title: Re: can you use a list as an argument?
Post by: andrew_nao on June 28, 2011, 08:49:00 AM
thanks for the reply

yall are awesome  :-)