Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Section - [13] How can I pass a variable number of arguments to a lisp

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [12] How to Autoload my programs?
Next Document: [14] How can I avoid stack overflows?
See reader questions & answers on this topic! - Help others by sharing your knowledge

  With plain AutoLISP this is not possible.
  You can either pass all your arguments in a list like this:

  ;;; print a variable number of arguments (of any type)
  (defun my-princ (x)
    ;; simple version, for better stuff look at the SDK2: PRINTF.LLB
    (if (listp x)
      (mapcar 'princ x)
      (princ x)))

  Or you have to define the function in ADS and export it to
  AutoLISP.
  Then you are free to write:
    (ads-print "Hello " "World " 1 2 3)
  or even
    (ads-printf "Hello %s %i %i" "World" 2 3)

  Look at Reini Urban's and Vladimir Nesterovsky's ADS samples at
  http://xarch.tu-graz.ac.at/autocad/ads for implementations of the
  above examples.

  Official wishes were pointed to Autodesk regarding &optional as
  AutoLISP language enhancement, but it was not implemented in R14.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [12] How to Autoload my programs?
Next Document: [14] How can I avoid stack overflows?

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
rurban@xarch.tu-graz.ac.at (Reini Urban)





Last Update March 27 2014 @ 02:11 PM