crazy_precisian 发表于 2022-7-6 11:26:35

如何获得函数#039;s

你好
 
我需要将当前函数的名称(由defun定义)转换为字符串,并在函数中使用此字符串。。。有可能吗?
 
谢谢你的回答!

Lee Mac 发表于 2022-7-6 11:34:07

使用atoms家族是我现在唯一能想到的事情——你为什么要这么做?

jammie 发表于 2022-7-6 11:36:28

你能发布一个你想要实现的示例代码吗?

jammie 发表于 2022-7-6 11:41:27

一些使用反应堆的东西,但我不确定这是否是你想要的。。
 
关键是它只返回初始函数名
 

;Create a command reactor to watch for lisp functions
(vlr-lisp-reactor nil '((:vlr-lispWillStart . storeFunctionName)))

;Store the command name in a global variable called *currentLispFunction*

(defun storeFunctionName (<Reactor> <Command>)

(setq *currentLispFunction*(car <Command>))
)


(defun c:test ()

(alert(strcat "\nFunction [" *currentLispFunction* "] started..."))

   )

crazy_precisian 发表于 2022-7-6 11:45:48

我只是AutoLISP的初学者,我认为有比反应堆更简单的方法。也许我会尝试找到不同的解决方案。。。
 
非常感谢您的回答!

Lee Mac 发表于 2022-7-6 11:51:51

只是好奇,你想实现什么?

David Bethel 发表于 2022-7-6 11:58:13

以下是我所拥有的:
 

;converts a quoted symbol to a string
(defun symstr (name)
(if (= (type name) 'SYM)
   (
   (list
       (if (boundp name)
         (cons '/ (atoms-family 0))
         (cons '/ (cons name (atoms-family 0)))
       )
       (list setq name 0)
       (list car (list atoms-family 1))
   )
   )
   nil
)
)
 
但是你的个人资料上写着?
 
-大卫

Lee Mac 发表于 2022-7-6 12:00:55

如果你有这个符号,你能不能不用:
 

(vl-princ-to-string sym)

David Bethel 发表于 2022-7-6 12:04:04

 
李,
 
你抓住我了-大卫

Lee Mac 发表于 2022-7-6 12:10:17

不,我知道你不能使用VL功能,大卫,这对你有点不公平。
 
但是,回到你的例子——我不太理解你正在使用的方法,如果你有时间,请你解释一下思维过程好吗?
页: [1] 2
查看完整版本: 如何获得函数#039;s