View Full Version : bad argument type: FILE nil, help plz
jgroh
2007-10-25, 12:03 AM
I was wondering if someone could help me with an old LSP that I did not write and I know nothing of LISP code. I have an LSP that draws a tank head and has recently started erroring out for no apparent reason. I enter two values, the tank diameter and the thickness of the head, then get the error
Command: asme1
What is the outside diameter? 144
What is it's thickness? .25
; error: bad argument type: FILE nil
After you enter the thickness, it is supposed to ask you for an insertion point but of course it never makes it that far. Can anyone give me some advice please? It would be much appreciated. Thank You.
I have attached the LSP, any suggestions??
T.Willey
2007-10-25, 01:16 AM
The first thing that stands out is it is trying to find a text file, if it can't find it you will get that error when trying to read it. To see if it is able to find your file, copy/paste this to the command line.
(findfile "hdata.txt")
It will either show the full path to the file, or return nil (meaning it couldn't find the file). If it can't find the file, then you need to put the file into one of the Acad's search paths.
If that doesn't fix the problem, then post back.
jgroh
2007-10-26, 06:02 PM
well i think i was able to change the correct search path...when i enter what you told me to i get:
Command:
Command: (findfile "hdata.txt")
"J:\\Eng\\LSP\\hdata.txt"
so then i ran it again and got the same result:
Command: asme1
What is the outside diameter? 144
What is it's thickness? .25
; error: bad argument type: FILE nil
After that didnt work i tried putting the complete file path infront of the "hdata.txt", so it then read:
(setq fp (open "J:\Eng\LSP\hdata.txt" "r"))
and it returned with the same result:
Command: asme1
What is the outside diameter? 144
What is it's thickness? .25
; error: bad argument type: FILE nil
So then I was thinking that the "r" has something to do with it. There is an r a few lines above the open command line.
(defun dxf (code elist) (cdr (assoc code elist)))
(setq od (getreal "What is the outside diameter? "))
(setq thk(getreal "What is it's thickness? "))
(setq fp (open "J:\Eng\LSP\hdata.txt" "r"))
So I removed the "r" and the r from those two lines just as a trial and error type thing, so the code looks like this:
(defun dxf (code elist) (cd (assoc code elist)))
(setq od (getreal "What is the outside diameter? "))
(setq thk(getreal "What is it's thickness? "))
(setq fp (open "J:\Eng\LSP\hdata.txt"))
loaded the lsp with those changes and got:
Command: asme1
What is the outside diameter? 144
What is it's thickness? .25
; error: too few arguments
Does that "r" have anything to do with it? I am clueless...hehe
Change this line if you need to read 'em:
(setq fp (open "J:\Eng\LSP\hdata.txt"))
on this one:
(setq fp (open "J:\Eng\LSP\hdata.txt" "r")); where "r" is means READ
and this is a missed argument in this expression
______________________________________________
And also as Robert said below use double backslashes:
(setq fp (open "J:\\Eng\\LSP\\hdata.txt" "r"));
~'J'~
RobertB
2007-10-26, 07:36 PM
Change this line if you need to read 'em:
(setq fp (open "J:\Eng\LSP\hdata.txt"))
on this one:
(setq fp (open "J:\Eng\LSP\hdata.txt" "r")); where "r" is means READ
and this is a missed argument in this expression
~'J'~Also, hasn't anyone noticed the missing double-backslashes?
Ah, thanks, the eagle eye :)
I missed it out
Cheers
~'J'~
jgroh
2007-10-26, 09:09 PM
wow, problem solved! thanks for your help guys! you rule
jgroh
2007-10-26, 11:44 PM
This lsp is for drawing tank saddles...everything goes great until, well...just check out the screen shots...
T.Willey
2007-10-27, 12:55 AM
Usually when that happens you have an extra enter in a command prompt. What that means is there is an extra pair of double quotes. That is what looks wrong in a quick look at your code.
(command "arc" pt4 "e" pt2 "r" d1 "")
(command "arc" pt5 "e" pt3 "r" d2 "")
You should take out the last double quotes, and check all the other command calls to see that they don't have any extra enter calls.
jgroh
2007-10-29, 05:16 PM
Alrighty, i took all the extra "" from the ends of the command lines, then ran the lisp and now im getting:
Command: SADDLE
What is the tank gallonage? 60000
What is the tank O.D.? 144
What is the tank shell thickness? .375
What is the saddle height? 6
; error: bad argument type: stringp nil
And once again, I have no idea what stringp means...ill upload the updated version of the code..
Also, there were a few double "" in the middle of the command code, so i wasnt sure if i should remove those or not.
Thanks for your help on this, much appreciated.
T.Willey
2007-10-30, 12:57 AM
Sorry didn't have time today to help, and it doesn't look like I will tomorrow.
Hopefully someone can help you out.
jgroh
2007-10-30, 03:15 PM
oh well thats ok man, i just found out yesterday that there was a service pack for 2004. so we got that installed and now all the LSP's work on a co-workers computer but still not on mine...hopefully i can play around with it a bit and not screw it up too badly lol, thanks for your help tho tim. i have nothing but time lol
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.