SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => Topic started by: Hardcoal on January 06, 2020, 03:00:30

Title: Getting File URL MaxGUI
Post by: Hardcoal on January 06, 2020, 03:00:30
Hi,
I told Windows To open my Note Editor when I Press a Text File, But I want My Note Editor To know the URL of the Pressed Text File.
how can i get it?

Thanks
Title: Re: Getting File URL MaxGUI
Post by: TomToad on January 06, 2020, 11:37:48
you should be able to use AppArgs[] to get the file path and name.
' appargs.bmx
' print the command line arguments passed to the program at runtime

SuperStrict

Print "Number of arguments = "+AppArgs.length

For Local a:String = EachIn AppArgs
Print a
Next

Title: Re: Getting File URL MaxGUI
Post by: Hardcoal on January 06, 2020, 21:27:30
This is no good for me because the apparg doesnt work for what I asked..
only if you drag a file onto your app the apparg will return info..

what im trying to do is that when i press a text file when then ill get the info
Title: Re: Getting File URL MaxGUI
Post by: Derron on January 07, 2020, 08:59:15
This is for sure in the appargs (if it is to find with default functions).

If you double click on a file in the explorer it will start it according to your setup - something like "myapp.exe thefile.ext".


bye
Ron
Title: Re: Getting File URL MaxGUI
Post by: fielder on January 07, 2020, 09:19:56
Yep, i'm usign it in a lot of applications.. i take appargs, if there is a (valid) file name on one of these... i use it as a filename. (i have to add my application to the windows list using OPEN WITH on the icon.. and selecting the Blitzmax application one time)

automatically associate your application to the file type can be done ONLY with registry changes, replacing the current association. (this make that in future when you remove your app.. the association will broke... and wil be necessary to select anotehr defualt software to open the specific file-type)


name="dummy.txt"
If AppArgs.length=2 name=AppArgs[1]
' do some checks '
Global file:TStream=ReadFile(name)


this make dummy.txt the default choice (for testing porpouses) but if the applications will be associated to ".txt" make the name can be changed to location and name of the file.
Title: Re: Getting File URL MaxGUI
Post by: Derron on January 07, 2020, 09:31:07
I would at least change
If AppArgs.length=2 name=AppArgs[1]
to
If AppArgs.length>=2 name=AppArgs[1]

bye
Ron
Title: Re: Getting File URL MaxGUI
Post by: Hardcoal on January 07, 2020, 15:36:10
Ok thanks .. Ive managed to Get the File url from the second apparg cell.. so it seems to work.
Great Thanks..
I dont understand why first time it didnt..
I probably did something wrong
Title: Re: Getting File URL MaxGUI
Post by: fielder on January 08, 2020, 08:11:34
Quote from: Derron on January 07, 2020, 09:31:07

If AppArgs.length>=2 name=AppArgs[1]
Ron

Right :)