I am currently having a similar issue. This is a similar message to "bad argument type stringp" that I came across earlier with one of my programs. This is an error that pops up when the incorrect data type is being used. With the string case, I was able to use the atoi function to convert the data to an integer (required for my if statement). I am currently looking for a solution to the fixnump conversion.
Below is a chunk of code I used. This tests the data type (in case of future ACAD change) and converts if necessary.
(setq FMTdwgNum (c:wd_is_cur_dwg_in_proj))
(setq FMTdwgNumTy (type FMTdwgNum))
(if (= FMTdwgNumTy string)
(progn
(setq FMTdwgNumstr FMTdwgNum)
(setq FMTdwgNum (atoi FMTdwgNumstr))
)
(progn
(setq FMTdwgNumstr (itoa FMTdwgNum))
) )
@Anonymous wrote:
....
(if (= FMTdwgNumTy string)
....
That should be:
(if (= FMTdwgNumTy 'STR)
with apostrophe prefix, and only the first three letters [not case-sensitive].
But I confess to being curious as to why you don't know what type of result you're going to get from (c:wd_is_cur_dwg_in_proj), so that you don't have to test for it. Is that written in such a way that it can sometimes return a string and sometimes an integer?
I can try to test this with the 'str instead of string, but the program works fine while testing against string. I did switch to a test on this after finding different data type on this one of the test runs I was doing (I honestly don't know if it was a glitch or possibly something in my program that caused the issue, so made a basic test function to ensure no future issues).
I was able to find that the data type on my program was showing up with this error was LIST. I found this by adding a line with the "type" function after creating the variable, and then entering !VARIABLENAME in the command line. this is my work around for this data error. if this code bit doesn't help, feel free to post a copy of your code and we might be able to help a bit more.
(setq FMTpdNumstr1 (vl-prin1-to-string FMTpdNumlst))
(setq FMTpdNumlen (- (strlen FMTpdNumstr1) 2))
(setq FMTpdNumstr (substr FMTpdNumstr1 2 FMTpdNumlen))
(setq FMTpdNum (atoi FMTpdNumstr))
@Anonymous wrote:
.... the program works fine while testing against string. ....
If it has worked fine, I assume that (c:....) command must be returning an integer, because [using 12 arbitrarily here]:
(= (type 12) string)
nil
(= (type 12) 'str)
nil
(= (type "12") string)
nil
(= (type "12") 'str)
T
The first one is probably equivalent to what you were getting, even without the correct Type designation, and since that just returns nil, it went ahead with the 'else' expression and made a string from the integer, just as it would with the correct Type designation [the second one].
If it were working with a string returned by (c:....) [the 3rd and 4th ones], you should have gotten the equivalent of the third one, in which case it would also have tried to make a string out of an integer, but you should have gotten an error about the string "12" not being an integer.
@Anonymous wrote:
@Anonymous
... if this code bit doesn't help, feel free to post a copy of your code and we might be able to help a bit more.
....
[Watch dates -- this is a 12-year-old thread, and I don't recall seeing Adesu participating lately.]
Can't find what you're looking for? Ask the community or share your knowledge.