a build-in symbol name for a function

a build-in symbol name for a function

Moshe-A
Mentor Mentor
1,364 Views
12 Replies
Message 1 of 13

a build-in symbol name for a function

Moshe-A
Mentor
Mentor

Hi Guys,

 

i know this is very rare but i wonder if anyone ever deal with it...

does AutoLISP (or core lisp) has a build-in symbol holding the function name or a function to retrieve the current running function name. something similar we have in callback reactors like (vlr-current-reaction-name) or (vlr-data)

 

example:

 

(defun function_name ()

   (if (null (member <LISP-SYMBOL> funcNames))

     (setq funcNames (cons <LISP-SYMBOL> funcNames))

  ) 

  .....

  .....

)

 

<LISP-SYMBOL> holds or retrieve function_name.

would like to collect all functions name that were called in one big list.

 

thanks in advance

Moshe

 

 

0 Likes
1,365 Views
12 Replies
Replies (12)
Message 2 of 13

doaiena
Collaborator
Collaborator

I've never had the need to track the function names, so i don't know for sure if there is such a built-in-symbol. If using reactors is an option for you, you can get the function name from the vlr-lisp-reactor.

0 Likes
Message 3 of 13

CodeDing
Advisor
Advisor

@Moshe-A ,

 

I do not believe that it's possible, but can you give me a practical example of when it might even be needed?

 

Best,

~DD

0 Likes
Message 4 of 13

john.uhden
Mentor
Mentor

I did something like that once because I was having so much trouble fining the source of an error.  But my method was not at all fancy.  Inside a function I would setq the function name, as in...

(defun @Anonymous (input / x y z)
  (setq fun "@convert")
  ...
)
Then, in my *error* function I would include...
  (if fun (print fun))

I had a lot of functions in this one particular program, so while it was a pain adding all the setqs, it helped me find the source of the error(s).

John F. Uhden

Message 5 of 13

martti.halminen
Collaborator
Collaborator

Error handlers are somewhat problematic: they can also hide errors so you don't get to debug those.

 

I've not seen mention of the current function name being stored in a Lisp variable, but the call stack, i.e. those functions that have been called but have not yet exited, is available in VLIDE. When you hit a breakpoint, see View>Trace Stack in the VLIDE menu.

 

I usually run with Debug>Break on Error set and Vlide running, so when the system notices a Lisp error, the program crashes into the debugger and I can see the call stack. In that situation, Debug>Last Break Source is also useful, if the program has been loaded as .lsp instead of .fasl or .vlx .

 

There is also an undocumented function, (vl-bt), which prints the call stack, also showing plenty of internal stuff so recognizing your own takes a little practice:

_$ (vl-bt)

Backtrace:
[0.141] (VL-BT)
[1.137] (#<USUBR @000001443ad18570 -top->) LAP+7
[2.133] (al-top-funcall #<USUBR @000001443ad18570 -top->)
[3.128] (alide-load-stream #<FILE internal> T)
[4.122] (al-load-stream #<FILE internal> T)
[5.116] (#<SUBR @000001443b7e2098 -unwind-protect->)
[6.113] (rep-cntx.apply #<rep-cntx :AUTOLISP> al-load-stream (#<FILE internal> T))
[7.106] (rep-cntx.sys-str-top nil #<rep-cntx :AUTOLISP> "(vl-bt)")
[8.99] (sys-str-top #<rep-cntx :AUTOLISP> "(vl-bt)")
[9.93] (console.terminal-entered! (terminal.terminal-entered!) #<console "Visual LISP Console">)
[10.87] (terminal-entered! #<console "Visual LISP Console">)
[11.82] (!accept-enter #<console "Visual LISP Console">)
[12.77] (#<SUBR @000001443b7e2098 -unwind-protect->)
[13.74] (rep-cntx.apply #<rep-cntx :AUTOLISP> #<SUBR @000001442b24ad90 !accept-enter> (#<console "Visual LISP Console">))
[14.67] (rep-cntx.funcall #<rep-cntx :AUTOLISP> #<SUBR @000001442b24ad90 !accept-enter> #<console "Visual LISP Console">)
:TOP-COMMAND.60 (((:USER-INPUT "(vl-bt)")) "(vl-bt)")
[15.57] (#<SUBR @000001442b3487f0 _sys-top-loop>)
[16.54] (_catched-apply (#&1) #<SUBR @000001442b3487f0 _sys-top-loop> nil)
[17.47] (sys-top) ...

 

-- 

 

0 Likes
Message 6 of 13

cadffm
Consultant
Consultant

Hi,

 

i guess TO want to know which function are in use. @Moshe-A 

Sebastian

0 Likes
Message 7 of 13

Moshe-A
Mentor
Mentor

Guys,

 

Sorry i was away for few days. what i'm after is to eliminate some c:  lisp functions from  command line input search  \ auto complete.  i know i can disable this feature but as soon as this enable, all commands are restored.

 

it look like if you (setq c:xxx nil) it disable the command but still appears in input search \ auto complete.

 

thank you all for your help

Moshe

  

Message 8 of 13

Kent1Cooper
Consultant
Consultant

@Moshe-A wrote:

.... what i'm after is to eliminate some c:  lisp functions from  command line input search  \ auto complete.  ....  


Can you explain in more detail how this relates to the request in Message 1?  I'm not following....

Kent Cooper, AIA
0 Likes
Message 9 of 13

Moshe-A
Mentor
Mentor

@Kent1Cooper  hi,

 

Actually i'm 'talking' about opendcl event handlers. is it possible to remove them from

the command line input search?

 

Moshe

  

0 Likes
Message 10 of 13

Kent1Cooper
Consultant
Consultant

@Moshe-A wrote:

...

Actually i'm 'talking' about opendcl event handlers. is it possible to remove them from

the command line input search?  


[Sorry, that's beyond my knowledge or experience.]

Kent Cooper, AIA
0 Likes
Message 11 of 13

john.uhden
Mentor
Mentor
This is certainly a bit extreme, but...

(mapcar '(lambda (x)(if (wcmatch (strcase x) "C:*")(set (read x)
nil)))(atoms-family 1))

I don't think anyone would really want to do that.

John F. Uhden

0 Likes
Message 12 of 13

Moshe-A
Mentor
Mentor

thanks @john.uhden but that doesn't eliminate the c: commands from input search option. i wonder if ObjARX/c# has the power to do that?!

 

 

0 Likes
Message 13 of 13

john.uhden
Mentor
Mentor
My guess is that the input search option uses its own database or internal
list that you are not going to be able to find or change using any
programming language.

John F. Uhden