Page 1 of 1
File association with a program
Posted: Wed Jul 30, 2003 9:17 am
by Large
Sorry if the title to the thread is not correct, did not know what to call it, lol.
Anyway want I want to be able to achieve is this . . .
I have created a program that will print a fax header ready to be faxed on a fax machine, I have managed to get the program to save the faxes which is basically a text file containing things like the recipient, date, message, etc.
I have associated my program files (.fxm) with the program and when you click on one of these files it opens my program which is kinda right but when the program opens all the fields are blank, I want to click a file and my program to read in the values and put them in the appropriate boxes, similar to clicking on a Word document and it opening Word with the letter on your screen.
Can anyone give me an example, please remember I'm a newbie.
Kind regards
Andy ( aka Large )
Posted: Wed Jul 30, 2003 9:20 am
by Pupil
You might want to checkout, in your program, what parameters is passed to it

Look in manual for the command 'ProgramParameter()''.
Posted: Wed Jul 30, 2003 11:41 am
by Large
This could be useful Pupil . . .
But I'm clicking on a file to open my program I need a way for my program to know what the path and filename I have just clicked on then I can set the gadgets with values.
basically . . .
if user clicked file
get filename and path
read file and set gadget values
end if
Kind regards
Andy ( aka Large )
Posted: Wed Jul 30, 2003 12:38 pm
by Kale
When someone d-clicks on your file the file name will be sent as a parameter to the recieving program, as if you are starting your program from the cmd line.
like this:
FaxHeaderPrinter.exe TestFax.fxm
so in your FaxHeaderPrinter.exe program check for the name of 'TestFax.fxm' file using ProgramParameter() then open this file read the contents and do with them what you will. simple

Posted: Wed Jul 30, 2003 2:32 pm
by Large
Thanks Kale and Pupil, you guys are cool !
I'm gonna try a few things with the programparameter() command, I'll let you know how I get on.
Kind regards
Andy ( aka Large )
Posted: Thu Jul 31, 2003 11:52 am
by Large
Well I'm afraid I'm not getting on to well . . .
I'm using this line at the beginning of my program.
and then to see what parameter$ holds I'm testing it with.
that way I can see the filename but when I try this gadget 1 is empty.
You guys got any idea's how I can click on a file which will open the associated program and the program to know the path and filename that launched it.
Any help greatly appreciated.
Kind Regards
Andy ( aka Large )
Posted: Thu Jul 31, 2003 2:59 pm
by TerryHough
Andy, I think Kale's advice puts you on the right path. But, your file
association must tell the OS what to do with the file. So your "open"
command must pass the filename.
I don't have my notes with me, but as I recall it is something like this:
in action you need
\PureBasic\PBProgram.exe "%1"
or
\PureBasic\PBProgram.exe "%file"
Sorry I can't be more exact. I have simply forgotten how these
parameters are defined in the association. Hope this will get you a
starting place to figure it out.
Terry
Posted: Fri Aug 01, 2003 1:30 pm
by Large
Hi Terry,
I think I understand, I have alter the association on my pc so that it send the filename when I click on it.
I will look up file assocation setting to get the correct parameters.
Kind regards
Andy ( aka Large )
Posted: Fri Aug 01, 2003 3:23 pm
by Large
I have set up the file association so that clicking on the file and the program opens, the file assocation has by default added "%1" for the file path part.
I'm using :
Code: Select all
file$=programparameter()
setgadgettext(2,file$)
but the gadget is empty.
Any idea's anyone ???
Kind regards
Andy ( aka Large )
Posted: Sun Aug 03, 2003 5:29 pm
by Kale
Compile this code and associate a file to the .exe, then double click the file!
Code: Select all
parameter.s = ProgramParameter()
OpenWindow(1, 0, 0, 600, 40, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, parameter)
CreateGadgetList(WindowID(1))
StringGadget(1, 10, 10, 580, 20, "")
SetGadgetText(1, parameter)
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
Posted: Sun Aug 03, 2003 11:21 pm
by HarryO
Large,
Look at this posting:
viewtopic.php?t=6365
it is just a snippet of code to help you get all of the
parameters passed to a program.
Hope this helps.
HarryO
Posted: Mon Aug 04, 2003 4:48 pm
by Large
Thanks for all your help guys.
I managed to get the program parameters correctly and I have read the file back into my program with success.
Kind regards
Andy ( aka Large )