'Drag and drop' app

BlitzMax Forums/BlitzMax Programming/'Drag and drop' app

Jaydubeww(Posted 2010) [#1]
As the topic title suggests, I would like to create a 'drag and drop' application. Ie. I would like to be able to drag a text file onto a blitzmax .exe and have the .exe open the file and make some changes. Is there anyway to force blitzmax into automatically opening it?


TomToad(Posted 2010) [#2]
When you drag-n-drop, the file name will be passed to blitzmax in AppArgs[].
SuperStrict

Local Filename:String
If AppArgs.length = 2
	Filename = AppArgs[1]
Else
	Filename = RequestFile("Load TXT file")
End If

If Filename
	Local Stream:TStream = ReadStream(Filename)
	If Stream
		While Not Eof(Stream)
			Local a:String = ReadLine(Stream)
			Print a
		Wend
	End If
	CloseStream Stream
End If
	
Delay(10000)



Czar Flavius(Posted 2010) [#3]
That's interesting. Is there a way to check that the arguement supplied is for a filename other than trying to open it?


Thareh(Posted 2010) [#4]
If FileType( Dir:String ) = FILETYPE_FILE



Czar Flavius(Posted 2010) [#5]
That's not exactly what I mean. Let's say my program can open files by either dragging and dropping on the exe, or by running it from a console window and providing it with arguements that way. If I give it a valid file path in each method, how can my program tell by which way it got that file name?


BlitzSupport(Posted 2010) [#6]
You can't, really, but why would that matter?


Czar Flavius(Posted 2010) [#7]
I'm a pedant. :(


TomToad(Posted 2010) [#8]
Well, you can check AppArgs[0], if it is "Full/Path/To/Program/ProgramName.exe", then it is most likely drag-n-drop since most people don't type the entire path when running from a console.