This one perplexes me.
If I run this, I get the expected result (12)
(setq value (+ 8 4))
However, if I do this:
(setq value (- 8 4))
I get this error message:
; error: bad function: 1
As a workaround I am using
( setq value (+ 8 (* 4 -1)) )
Any ideas?
thanks
Solved! Go to Solution.
Have you tried an AUDIT on the mischievous files?
At the command prompt, what does !- return (for both the bads and the goods)?
Are the mischievous files from an older version such that some code you are loading loads say "this" versus "that" based on the version in which the drawing was last saved? ACADVER won't tell you the version in which the file was saved, but there is an easy way to read the first 6 characters of a DWG file to determine that.
How about if you save a "bad" drawing and reopen it? Does the symptom disappear? Or are you maybe saving as default to an older version?
John F. Uhden
"value" is a command in autolisp. So (setq value ....) will not work. Try a different variable. I use notepad++ when coding, and if you save the file as a .lsp, the variables will be become blue, it it is already defined.
"value" is a command in autolisp/autocad. So (setq value ....) will not work. Try a different variable. I use notepad++ when coding, and if you save the file as a .lsp, the variables will be become blue, it it is already defined.
@gcsjlewis wrote:
"value" is a command in autolisp/autocad. .....
It's not listed in Help [2021], neither as an AutoCAD command nor system variable nor as an AutoLisp function. Besides, if that were the problem, their first example wouldn't have worked.
@Anonymous wrote:; error: bad function: 1
Any ideas?
Could it be that you somehow redefine "-" as something else within other lisp code
(setq - 1);<--- somewhere in any your lisp codes
(setq value (+ 8 4))
(setq value (- 8 4))
Which explains why it works on a new drawing, until some other codes triggers the redefining of the symbol?
Someone (some LISP code) has redefined your function '-.
You can simulate this (bad) behaviour e.g. with:
(defun - (a b)+(1))
Vladimir Michl, www.cadstudio.cz - www.cadforum.cz
In N++ if you have language selected set on LISP it stands for Common LISP. It has something called accessor functions and one of this is "VALUE"(that's why it is highlighted blue).
For Autolisp I use this
Miljenko Hatlak
Hi, no, opening and closing the file does not solve the problem. I cannot share the file, it contains sensitive information.
You put me in the right track. I wasn't aware of the audit command, but when I read the docs about it I found a mention to the RECOVER command. That one did the trick. Thank you and thanks everybody for your collaboration.
Interesting possibility. I 'll watch for that in future developments. In this particular case, I reduced the source code to perform the substraction and nothing else. However, the error remained.
value is not a command or a function in either my 2002 or my 2020.
But it appears that somewhere in the code he loading there is (setq - 1).
Thus...
Command: (- 8 4)
; error: bad function: 1
We must all be careful not to use function symbol names as variables.
John F. Uhden
Can't find what you're looking for? Ask the community or share your knowledge.