Author Topic: can you use a list as an argument?  (Read 1614 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
can you use a list as an argument?
« 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))
  )

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: can you use a list as an argument?
« Reply #1 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.

hermanm

  • Guest
Re: can you use a list as an argument?
« Reply #2 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.

andrew_nao

  • Guest
Re: can you use a list as an argument?
« Reply #3 on: June 28, 2011, 08:49:00 AM »
thanks for the reply

yall are awesome  :-)