Solution to see if program is already running.

Discuss any general programming issues here
Post Reply
Posts: 915
Joined: Sun Feb 14, 2010 7:11 pm

Solution to see if program is already running.

Post by Bugala »

There was, i think Rev. Bloedel that was asking for feature to see if another incident of hollywood program is already running. Unfortunately i went on to delete that post right away after reading, and after clicking that delete button, it came to my mind that i would have some sort of soltuion for that problem.

This how you can do it.

Everytime you start the program, you first check if there is this "check.dat" file in the folder you start the program from.

If it doesnt exist, then it means there is no other incident of the same program running already.

IN which case you create the "check.dat" file.

After you close the program, then you will before closing program delete that "check.dat" file.

Naturally there is possibility that computer have crashed and hence "check.dat" file is still there, so in case it is there, you need to give user the option to start the program anyway, although your simple test thinks there already is one incident runnning.

You can also make more sophisticated versions of this. LIke you could make "check.dat" file to contain number of incidents runnning. that:
n = readfile("check.dat")
n = n + 1
writefile(n, "check.dat")

and similarly on closing n = n - 1

Posts: 522
Joined: Sun Feb 21, 2010 1:28 am

Re: Solution to see if program is already running.

Post by PEB »

Your idea could work in certain situations. But I was hoping for a solution that would allow other Hollywood programs (which might be found anywhere on the user's hard drive) to check if another Hollywood program were running (without knowing where that program is located).

As I mentioned in that mailing list post, the thing that works best in AmigaOS is to check for the existence of a specific ARexx port; but this is not an option for Windows and Mac.

It would be nice if Hollywood programs could have an internal messaging system to communicate with each other on platforms that do not offer ARexx. (That would allow for a lot of interesting possibilities.) But Andreas has mentioned that though this is on his wish-list, it is not easily realized.

User avatar
Posts: 629
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy

Re: Solution to see if program is already running.

Post by Allanon »

What about using environment variables? Almost all system has support for them
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply