Author Topic: VLisp can detect unknown command, before execute?  (Read 1177 times)

0 Members and 1 Guest are viewing this topic.

d2010

  • Bull Frog
  • Posts: 326
VLisp can detect unknown command, before execute?
« on: December 10, 2021, 04:02:27 AM »
Now they either do not work or return "unknown command".
How to detect the command "leader" not exists inside this version of Acad?

Code: [Select]
(defun c:ll () (command "linetype" "load" "*" ""))
(defun c:le () (command "leader" pause pause pause "" "" "none"))
(defun c:ld () (command "leader" pause pause pause pause "F" "S" "" "" "none"))
(defun c:ldT () (command "leader" pause pause pause pause "F" "S" "" "" "none" "dtext" "j" "ml" pause "" ""))
(defun c:lt () (command "leader" pause pause pause "" "" "nONE" "dtext" "j" "ml" pause "" "" "dtext" "j" "l" ^C^C)


JohnK

  • Administrator
  • Seagull
  • Posts: 10623
Re: VLisp can detect unknown command, before execute?
« Reply #2 on: December 10, 2021, 09:36:21 AM »
On the interpreter level, There really isn't a way to know for sure but we can make a guess. They most likely have a lookup function like below.

Code - C++: [Select]
  1. lispval* builtin(lispval* a, char* func) {
  2.   if (strcmp("list", func) == 0) { return builtin_list(a); }
  3.   if (strcmp("car",  func) == 0) { return builtin_car(a); }
  4.   if (strcmp("cdr",  func) == 0) { return builtin_cdr(a); }
  5.   if (strcmp("eval", func) == 0) { return builtin_eval(a); }
  6.   if (strstr("+-/*", func)) { return builtin_op(a, func); }
  7.   ...
  8.   lispval_del(a);
  9.   return lispval_err("Unknown Function!");
  10. }
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

d2010

  • Bull Frog
  • Posts: 326
Re: VLisp can detect unknown command, before execute?
« Reply #3 on: December 10, 2021, 09:47:02 AM »
(getcname "leader") ?
Thank you,happym Best Regards..
Code: [Select]
AutoCAD menu utilities loaded.
Command: _RIBBON
Command: COMMANDLINE
Command: (getcname "leader")
"_LEADER"
Command: (getcname "leadeaar")
nil
Command: (getcname "trinitas.tv")
nil
Command: (getcname "line")
"_LINE"
Command: (getcname "Mline")
"_MLINE"
  :police:

mhupp

  • Bull Frog
  • Posts: 250
Re: VLisp can detect unknown command, before execute?
« Reply #4 on: December 10, 2021, 12:23:49 PM »
This will only run a command if its loaded.

Code - Auto/Visual Lisp: [Select]
  1. (if (vl-symbol-value 'c:vp2m)
  2.   (C:VP2M)
  3. )

If you develop AutoLISP programs that can be used with a foreign-language version of AutoCAD, the standard AutoCAD commands and key words are automatically translated if you precede each command or key word with an underscore (_).

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ll () (command "_linetype" "load" "*" ""))
« Last Edit: December 10, 2021, 03:19:55 PM by mhupp »

baitang36

  • Bull Frog
  • Posts: 213
Re: VLisp can detect unknown command, before execute?
« Reply #5 on: December 16, 2021, 09:18:29 AM »