Solved! Go to Solution.
Solved by Simon_Weel. Go to Solution.
@Simon_Weel wrote:
There's a post about the behavior of AutoCAD 2015 and (command ...) functions in custom *error* functions. AutoCAD 2015 displays this message if it encounters this situation: "Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended." So I edited all LISP files and changed (command ...) to (command-s ...). And then I found out this doesn't work in AutoCAD 2010. Command-s was introduced in release 2012. We use different versions of AutoCAD and they all use the same LISP routines. I would like to keep it that way, so I wonder if I can either get rid of the 2015-message or tweak things to get (command-s ...) working in release 2010. Any ideas? Simon
Just a thought, untest (I don't have 2015 in this laptop) try to change the command function to vl-cmdf function (vl-load-com first)...
HTH
Henrique
This works in all versions:
((if command-s command-s command) "XXXX" "XXXX")
I like it Owen. If a file used command-s more than once in a file, I wonder if it would be more convenient to put one of these at the top of the file:
;;backward compatibility for earlier versions
(if (not command-s) (setq command-s command))
or
;;backward compatibility for earlier versions
(or command-s (setq command-s command))
or for the really paranoid to head of the case of a non-functional binding of command-s
;;backward compatibility for earlier versions
(if (/= 'subr (type command-s)) (setq command-s command))
Then the rest of the file could be written as normal.
For the benefit of the the casual readers of this thread, be reminded that command-s is only for complete command sequences. No user input can be nested into the arguments to the command-s function.
@dbroad3 wrote:If a file used command-s more than once in a file, I wonder if it would be more convenient to put one of these at the top of the file:
Once could of course, but for code readability and debuggability, I prefer to see the logic at the point where it is used.
Could also build it as a utility wrapper defun e.g. (defun command-i ( arg_list / )...), although the arguments would need to be (list ...) 'ed rather than a variable number of strings. Opens up a few additional interesting thought, like global variable(s) with re-useable command argument lists for common command sequences.
@Anonymous wrote:
oops, wrong version... command-s was introduced in 2013 (ver 19) it seems...
G
Garry,
command-s was introduced in 2012, but only referenced in 2013 Help files...
Henrique
I guess that is possible but I would probably not use such a function. Over the years, I've built up my own way of handling defaults. If you develop the thought further, I might be interested.
I know this is months past this thread, but
((if command-s command-s command) "XXXX" "XXXX")
does not work in acad 2009. It gives an odd error.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Sounds like you guys all have really technical solutions, which I would appreciate if i had to hack further. I had this problem with the CLIPIT command (cropping some jpeg images) and I merely closed out of cad, regened, and reopened. Problem solved. just a thought before going to town on a LISP.
That kind of answer makes support people look bad though.
You might get past one problem, but people start to lose faith in you if you don't fix things right, so hence the search for a real fix here.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi Simon,
I understand this is an old thread, but I hope you'll see my message! I encountered a similar problem with a lisp recently. all of a sudden, when trying to use a lisp which worked just fine until now, I get the message you mention. I have AutoCAD 2015 and would like to try edit all LISP files and change (command ...) to (command-s ...). Can you please tell me how?
desperateMolly
Just check each custom/local *error* function inside your LISPs, and change each (command "func" "arg") in (command-s "func" "arg"). (You can (SHOULD) leave the rest of the lisp alone !)
For the record, command-s became mandatory for *error* functions as of ACAD2015 (R20), so to keep it working in both newer and older versions, i use a version check myself (as has been mentioned before in this thread).
Example:
(defun *error* ( msg / ) (if (< (atoi (getvar "acadver")) 20) ; ACAD 2014 or older (command "_.UNDO" "_End") ; End Undo - old version ; else (command-s "_.UNDO" "_End") ; End Undo - new version ) ; rest of error function here...
edit:
...and don't mind @sinisterkid as he's comparing apples & oranges.
You can restart, regen and/or reopen until you weight about one ounce, but 2015 & higher will simply keep telling you it is not allowed to use (command ...) within a *error* function.
Just like 2011 & older will keep telling you it doesn't recognize the command (command-s ...)
(2012-2014 are 'hybrids'. They have the command-s, but they will (still) accept command for *error* functions.