Board Logo
« How to open files with a double-click? »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 6:16pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: How to open files with a double-click?  (Read 1727 times)
orangetree
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx How to open files with a double-click?
« Thread started on: Feb 19th, 2011, 03:16am »

Hi, can anyone help?

I have written a program which allows the user to save files created in it. I have amended the registry to associate the extension of these files with the JB runtime engine (which I have renamed as runtime.exe). This means that, provided the user files is in the same directory as the runtime engine, they can be opened by double-clicking on them, which is quite nifty.

Unfortunately, this does not work when the files are in a different folder to the runtime engine (and therefore the associated TKN file, which of course is called runtime.tkn.

If I double-click on a user file in that case, Windows (or maybe JB, it's hard to tell) puts up a message with the caption "Application load aborted" and the message "File not found: runtime.TKN"

I think this might be because Windows calls the runtime engine, but the runtime engine thinks that the TKN is in the same folder as the folder containing the user's file, rather than in the same folder as the runtime engine, so it stops with an error.

Can anyone help as to how I might solve this problem?
User IP Logged

Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3711
xx Re: How to open files with a double-click?
« Reply #1 on: Feb 19th, 2011, 05:03am »

The problem is, that the runtime engine looks for the TKN file in the current working directory.

In case of selecting a file with explorer, the current working directory is the location of the selected file.

To overcome this problem you need to include the TKN file as an argument to the runtime engine.

The file association must look like: "C:\MyPath\MyApp.EXE" "C:\MyPath\MyApp.TKN" "%1"
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
orangetree
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: How to open files with a double-click?
« Reply #2 on: Feb 19th, 2011, 06:40am »

Thanks Stefan, that's very helpful.

This works, but it seems to cause a rather odd effect. The very first line of my program is

print "The command line is: ";CommandLine$

When the TKN element of the registry entry is NOT present, this works fine and CommandLine$ is printed to the main window, showing the full file path.

But when the TKN argument IS included in the registry entry, nothing is printed to the main window.

Even so, my program does correctly identify and start loading the file. This rather implies that the program knows what CommandLine$ is even if it cannot print anything to the main window. But the program then crashes when this method of using the file is loaded. An inspection of the error log shows a rather unclear "subscript out of range" problem. At first glance this might imply that there is a problem with the file or the program design. However, if I open my program first, and then open the file from within the program, then it loads fine, so I'm pretty sure it's not the file or the load routine that's the problem.

I can't debug this because of course it is the TKN that is using the file, not the JB editor/compiler.

Any ideas?
User IP Logged

orangetree
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: How to open files with a double-click?
« Reply #3 on: Feb 19th, 2011, 07:02am »

SORRY, ignore the post above! I have made a silly mistake...let me go and test it out properly...!
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3619
xx Re: How to open files with a double-click?
« Reply #4 on: Feb 19th, 2011, 07:29am »

You may try with a BAT file, as in here: File association
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
orangetree
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: How to open files with a double-click?
« Reply #5 on: Feb 22nd, 2011, 4:48pm »

tsh73, thanks for that. Stefan's advice turned out to be perfect and completely solved the problem, but I was interested to hear of the .bat solution. Do you think that has extra advantages?
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3619
xx Re: How to open files with a double-click?
« Reply #6 on: Feb 23rd, 2011, 02:26am »

Quote:
Do you think that has extra advantages?

If first approach works, stick with it.

But it looks that BAT file does not have exact path coded in.
Though for for actually making file association you should know the path anyway.

User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls