Vlisp_Variable function name

Vlisp_Variable function name

Anonymous
Not applicable
949 Views
3 Replies
Message 1 of 4

Vlisp_Variable function name

Anonymous
Not applicable

Hi!

I would like to get set of functions (with keyboard shortcuts = prefix "C:") with one loop.

i.e.

Names of functions "a1" "a2" "a3" .... "a9"  (9 functions)

Function expresion: princ name of function.

 

Is it possible to define a function with variable name? I've tried to do this in many ways but without good results. Tracing error is almost impossible because of the simplicity of the function. I will be grateful for any advices.

 

 

 

0 Likes
Accepted solutions (1)
950 Views
3 Replies
Replies (3)
Message 2 of 4

rkmcswain
Mentor
Mentor
Accepted solution

Is this what you are wanting?

 

(defun myfun (x / ss1)
  (princ (strcat "\nFunction Name: " (itoa x) ))
  (princ)
)    
(setq i 1)
(while (<= i 9)
  (eval (read (strcat "(defun c:a" (itoa i) (chr 40)(chr 41) "(myfun " (itoa i) "))")))
  (setq i (1+ i))
) 


R.K. McSwain     | CADpanacea | on twitter
Message 3 of 4

Anonymous
Not applicable

Excellent! Thank you very much!

0 Likes
Message 4 of 4

cadffm
Consultant
Consultant
Abd check for valid symbolnames with snvalid http://help.autodesk.com/view/ACD/2018/ENU/?guid=GUID-2EFBE198-9860-456B-A090-206C743ACB90

For general function

Sebastian

0 Likes