![]() |
|
|
#1 (permalink) |
|
Member
Join Date: Jul 2008
Posts: 1
|
I write programs to do oil field calculations. I would like to add the ability to double click the data file and have it launch the program I created, then have it read the data file. I can make it launch the program but I don't know how the program should know which data file I double clicked. I tried looking for a command line argument but that does not seem to work. Any hints you can give me will be most appreciated.
Thanks Herb M |
|
|
|
|
|
#2 (permalink) |
|
Progradminstrateditor
Join Date: May 2008
Location: Frankfurt, GER
Posts: 1,253
|
Hi Herb,
I don't know what programming language you use, but usually all languages support checking an argument given in the launch command. I understand you have figured out how to assign your program to the file extension of your data files. I assume you have done that by configuring the default program in Windows for that extension. When you double-click a data file, Windows is basically invoking a command statement in the background, something like: yourprogram.exe yourdata.dat At the entry point of your program you will have "yourdata.dat" available as the first call argument. It depends on your programming language how you can access it. Logically your piece of code should look like this: Code:
if ( arg1 NOT empty) then
if ( file_exists(arg1)) then
open_file(arg1)
endif
endif
Hope that helps.
__________________
Best regards, George |
|
|
|
|
|
#3 (permalink) |
|
Full Member
Join Date: Jul 2010
Location: USA East Coast
Posts: 94
|
If your operating system is windows you can just change the file association registery to point to your program when you double click on the data file.
Open any folder, goto tools/folder options/file type and locate the file extension of your data file or create a new one. You can either select CHANGE or ADVANCED to change the program associated with that file extension. If you have written the program I would suggest a unique file extention for your data file and add a new extention to the list. Then on any double click (open) on that data file type would automatically launch your program and open the file for input. Understanding MS Windows File Associations How File Extensions Work
__________________
I started out with nothing and still have most of it left. Last edited by Awgeewhiz; 30. Dec 2010 at 08:02 PM. Reason: Spelling |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|