'Drag and drop' app
BlitzMax Forums/BlitzMax Programming/'Drag and drop' app
| ||
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? |
| ||
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) |
| ||
That's interesting. Is there a way to check that the arguement supplied is for a filename other than trying to open it? |
| ||
If FileType( Dir:String ) = FILETYPE_FILE |
| ||
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? |
| ||
You can't, really, but why would that matter? |
| ||
I'm a pedant. :( |
| ||
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. |