How do i find the location of error: bad argument type: fixnump: nil

How do i find the location of error: bad argument type: fixnump: nil

stanovb
Advocate Advocate
4,514 Views
30 Replies
Message 1 of 31

How do i find the location of error: bad argument type: fixnump: nil

stanovb
Advocate
Advocate

What's the best way to find the cause of this error? From what I found online, "The error is caused by a function requiring an integer argument has been passed an argument of incorrect data type with the value noted in the error
message". The message I get is nil, but I don't know what part of the code this error is occurring at. I tried to break on error than ran the routine , but its still unclear to me where the error is at. Is there a better approach? Should I try the variable watch? I can post the code if someone needs to see it, but there are multiple routines that work together. I'm pretty sure which routine is causing the error, I just don't know how to locate where in the routine the error is occurring at.

0 Likes
4,515 Views
30 Replies
Replies (30)
Message 21 of 31

marko_ribar
Advisor
Advisor

Now to the point of first (smaller) lisp - setting things...

 

At the end you have this :

;;ELSE ERROR-ALL REQUIRED FIELDS NOT ENTERED
((lambda(/ id)(setq id(LOAD_DIALOG "Nofill.dcl"))(cond((>= id 0)(if(NEW_DIALOG "Nofill" id
"(done_dialog)")(START_DIALOG))(UNLOAD_DIALOG id)))))

 

But it's placed in wrapper of (if) function in this manner :

 

(if expression

  (progn

    ... then statements ...

  )

  (progn

    ... else statements ...

  )

  and here you placed this :

;;ELSE ERROR-ALL REQUIRED FIELDS NOT ENTERED
((lambda(/ id)(setq id(LOAD_DIALOG "Nofill.dcl"))(cond((>= id 0)(if(NEW_DIALOG "Nofill" id
"(done_dialog)")(START_DIALOG))(UNLOAD_DIALOG id)))))

 

); end (if)

 

Those blue wrapped things in (progn ... ) are correct and only allowed in correct way of using (if) function...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 22 of 31

marko_ribar
Advisor
Advisor

Here is one of goodies from me that can be useful in debugging large and difficult codes...

I haven't used it too much in my past, but it was composed just for purposes of debugging...

 

http://www.theswamp.org/index.php?topic=56787.0 

 

(but you have to be logged to theswamp to access the topic...)

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 23 of 31

Sea-Haven
Mentor
Mentor

Interesting idea I use the same as Kent and check !a !b etc. Will try it have something crashing at moment.

0 Likes
Message 24 of 31

marko_ribar
Advisor
Advisor

I've altered something in explanation...

Have another look @Sea-Haven  : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-do-i-find-the-location-of-error-... 

 

Those things in red color are important ones...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 25 of 31

stanovb
Advocate
Advocate

This morning I checked the ok variable that I set before I ran the program & it was nil. I then ran the code, typed in !ok at the command line and it was set to 12 so I was wrong about the variable not getting changed. o was looking at the watch console.

stanovb_0-1645796538440.png

I'm not sure why its stopping there.it doesn't make much sense because this part of the code has always worked before.

0 Likes
Message 26 of 31

Kent1Cooper
Consultant
Consultant

[That should really have been in reply to @john.uhden rather than to me, but in any case....]

 

If it doesn't get as far as setting the 'ok' variable to 13, does it at least get as far as completing the definition of the PopListPick3 function?  If you do something like:

(PopListPick3 "1")

[or with any text string representing an integer] does it give you a no-such-function error message?

 

[That is, assuming PopListPick3 is not in the localized variables list, so it will survive past the end of the routine.]

Kent Cooper, AIA
0 Likes
Message 27 of 31

john.uhden
Mentor
Mentor

@Kent1Cooper 

I got a kick out of your using the word "prehistoric" relative to my "antedeluvian."

Except that antedeluvian cannot be prehistoric because if that were the case, then no history would have been recorded that there was a Great Flood.  Unless I'm all wet <get it?> and that the Great Flood was discovered by scientific evidence in 1971, which means it didn't exist before 1971, which confirms that it was not prehistoric because I was taking a history class in college at that time, which would not have been possible if history had not yet been invented.  QED

John F. Uhden

0 Likes
Message 28 of 31

stanovb
Advocate
Advocate

i apologize for that. I'm not sure I did this right but now I get this message when I select the region from the pull down on the dcl dialog box :

 

Command: stp Hard error occurred ***
internal stack limit reached (simulated)

 

stanovb_0-1645803443641.png

If I don't select something in the dialog box it just gives me the same error I was getting before.

0 Likes
Message 29 of 31

Kent1Cooper
Consultant
Consultant

@marko_ribar wrote:

.... I won't do at beginning : (setq a nil b nil c nil ... )

I'd rather do : (mapcar '(lambda ( %%% ) (if %%% (set %%% nil))) '(a b c d ... [copy+paste what's from localization here] )))

Then when it breaks : (vl-some '(lambda ( %%% ) (setq $$$ (if (not $$$) 0 (1+ $$$))) (null %%%)) (list a b c d ... [ -||- ] )))

Then to see which one is nil - probably cause of error like you explained : (nth $$$ '(a b c d ... [ -||- ] )) => you get for ex. : W meaning this varibable is the alien...


A somewhat shorter way to achieve the same thing, without the need for the $$$ counter variable:

 

(setq vl '(a b c d)) ; list of variable names

(mapcar '(lambda (x) (if x (set x nil))) vl) ; set them all to nil

Then the routine proceeds, and let's say it manages to set values into the 'a' and 'b' variables, but fails in setting 'c', so that remains nil.  This returns the name of the first nil variable, directly:

Command: (nth (vl-position nil (mapcar 'eval vl)) vl)
C

 

EDIT:  BUT I'm now realizing that this won't always be a legitimate approach, because it depends on the expectation that all the variables should be set to non-nil values.  But there are routines that legitimately set certain variables to nil -- for example, a routine working with a Polyline could have a variable that stores whether or not it's closed, with T or nil value.  It would not be a failure for that variable to be nil, but in checking after a failure, the above approach would flag that one when the failure is actually somewhere later in the routine.

For that reason, I would still prefer the !-prefix check approach.  As long as I'm aware of variables that could "successfully" get a nil value, I can check only those that should always have a non-nil value, until one of those is nil.

Kent Cooper, AIA
0 Likes
Message 30 of 31

stanovb
Advocate
Advocate

I made a mistake & had one too many (setq ok  #) statements. I had an extra spot at the end of the program where  the ok variable was being set to 12 for the second time. It was not failing where I had thought it was originally. Its actually at the end of the program. Now that I have zeroed in on the location I have to figure out which statement is causing the error. I guess with using your method once again. At least I am a lot closer now. I have a general idea where in the code the problem is

0 Likes
Message 31 of 31

john.uhden
Mentor
Mentor

@stanovb 

Sometimes you have to break things down into smaller pieces and add more oks.

You will find it, I'm sure.  It's probably looking right at you but you're avoiding the stare.

John F. Uhden

0 Likes