Gizmos Freeware Reviews  

Go Back   Gizmo's Freeware Forum > Freeware Forum > General Computer Support

Reply
 
Thread Tools Display Modes
Old 29. Dec 2010, 07:49 PM   #1 (permalink)
Member
 
Join Date: Jul 2008
Posts: 1
Cool Programing tip

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
HMaier is offline   Reply With Quote
Old 30. Dec 2010, 05:39 PM   #2 (permalink)
Progradminstrateditor
 
George's Avatar
 
Join Date: May 2008
Location: Frankfurt, GER
Posts: 1,253
Default

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
I suggest to Google for the exact way of doing this in your language.

Hope that helps.
__________________
Best regards, George
George is offline   Reply With Quote
Old 30. Dec 2010, 07:46 PM   #3 (permalink)
Full Member
 
Awgeewhiz's Avatar
 
Join Date: Jul 2010
Location: USA East Coast
Posts: 94
Default

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
Awgeewhiz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 02:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2