Quote: "
no problem. That code snippet I posted is an infinite loop so if you used it as is you could have problems. I was really just intending to demonstrate the function that strips the filenames of the end of paths. If you use it in your code, omit the do-loop section
"
Heheh, yes, I knew that. I didn't keep the do-loop and it still made me infinitely loop. Something about my while success = 0 loop wasn't working anymore for some reason. It was like it never set success to 1 even though I tried putting it all over the while loop just to make sure it did. Hmm...maybe it's a bug? I doubt it, but just in case I'll post the routine in question in an edit (I need to put the open file dialog back in).
Edit: Here's that code. It works just fine if I use the gen_InputBox() but does not otherwise.
function LoadObject()
while success = 0
cls
sync
set cursor 0,45
show mouse
rem tempfilename$ = gen_InputBox("Object Filename", "Object Filename w/Extension?")
temppath$ = gen_OpenFileDialog(get dir$(), "")
tempfilename$ = GetFileName(temppath$)
rem message "Debug!", tempfilename$
hide mouse
objnum = FindNextObjectNumber()
rem TODO!!!!!! Make sure the file is an object or it will crash!
if file exist(tempfilename$) = 1 and success = 0
for o=1 to 256
rem HACK to get around a bug with just giving load object the objnum var.
if o=objnum
load object tempfilename$, o
Objects$(objnum) = tempfilename$ : rem Remember the name of this object.
position object o, camera position x(), camera position y(), camera position z()
rem Set the current object to the one just loaded.
currentobject = o
rem Check to see if a texture exists in bmp or dds format.
rawfilename$ = ParseString(tempfilename$, ".", 0)
rem message "Debug!", "PARSED STRING: " + rawfilename$
ddstexture$ = rawfilename$ + ".dds"
bmptexture$ = rawfilename$ + ".bmp"
if file exist(ddstexture$) = 1
if image exist(o) = 1 then delete image o : rem Watch for errors.
load image ddstexture$, o, 1
texture object o, o
endif
if file exist(bmptexture$) = 1
if image exist(o) = 1 then delete image o : rem Watch for errors.
load image bmptexture$, o, 1
texture object o, o
endif
endif
next o
success = 1
endif
if file exist(tempfilename$) = 0
while filewait < 300
cls
center text 512, 384, "Object does not exist!"
filewait = filewait + 1
endwhile
filewait = 0
endif
endwhile
rem success = 0
objnum = 0
rawfilename$ = ""
ddstexture$ = ""
bmptexture$ = ""
tempfilename$ = ""
endfunction
Thanks again for your help.