Drag and drop and LoadImage
Blitz3D Forums/Blitz3D Programming/Drag and drop and LoadImage
| ||
Hi guys, (1st time i write something here.) The problem in shortly When you make an EXE file of your Blitzbasic code you could use c$=CommandLine() I did a very easy test just try to view a picture i 2D mode. Graphics 800,600:c$=CommandLine() micke=LoadImage(c$):DrawImage micke,0,0:Delay 3000:End I maked a exe file of this blitzbasic code and found out, if i did "drag and drop" picture with no space in filename or path it worked, but when a picture named "c:\this picture.jpg" or "c:\1 space\picture.jpg" I get "Memory access violation" Error!. Anyone knows why ? Anyway i make a function for it that worked, code is below. But Is it possible to make this in a better way ? Graphics 800,600:c$=CommandLine() Global cfolder$,cfile$ MickeImage(c$):ChangeDir cfolder$:micke=LoadImage(cfile$):DrawImage micke,0,0:Delay 3000:End Function MickeImage (c$) c$=Right$(c$,Len(c$)-1):c$=Left$(c$,Len(c$)-1):For a=Len(c$) To 1 Step -1:b=Instr(c$,"\",a):If b>0 Then ci=a : Exit Next:cfolder$=Left$(c$,ci):cfile$=Right$(c$,Len(c$)-ci) End Function |
| ||
The problem is that Windows appends " to the start and to the end of the path if there where spaces in befor it is given to your program. To face with that problem you have to replace all " with nothing: tempStr$ = Replace(Commandline(), chr(34), "") Edit: The best way to see what happens with the overgiven path is if you use the debuglog command. tempStr$ = Commandline() Debuglog(tempStr$) Waitkey End |
| ||
OK, looks like it worked :) Graphics 800,600:c$ = Replace(CommandLine(), Chr(34), "") micke=LoadImage(c$):DrawImage micke,0,0:Delay 3000:End Tnx Addi |