How do you get a file name argument when a file is chosen from within a file manager?
I can make it so I tap on a file and my program launches, but I want it to load the file I tapped on as well, which I can't work out how to code. I figure its probably an argument option or something, but I can't work it out. What do I have to do?
Afraid I don't really understand the help on it, I assume the program will be launched with the file name as an argument but I can't see how I capture that to use. Might fiddle with the code shown in help, but I could do with some more pointers...
(Also I apologise, but I seem to have posted this in 'Code Samples and Tips', rather then the more suitable 'questions/help needed' forum. Can someone move it? I've no idea why I put it here.... *feels silly*)
Ah, thanks agraham, the help file, your last comment and some trial and error seem to have got it all working now. Suddenly it all seems quite obvious. :sign0161:
my code for anyone else with the problem is:
B4X:
(In app start)
If ArrayLen(Args()) = 1 Then 'Will catch if a single argument is given. (Like a file name)
file = args(0)
If SubString(file,StrLength(file) - 3, 3) <> "jgf" Then 'Checks the file extension to see if its the right type.
Msgbox(File & " is not a valid file","Error")
Return
End If
opendialog1.File = file
LoadFile
Which seems to work fine.
EDIT: First version only worked when given an argument to check. :signOops:. New code checks if the argument is there...