Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #208

Re: As it's launched, how can a program test if a copy of itself is already running ?

From Martin <News03@avisoft.f9.co.uk>
Subject Re: As it's launched, how can a program test if a copy of itself is already running ?
Newsgroups comp.sys.acorn.programmer
Date 2011-04-24 18:32 +0100
Message-ID <51c90e63f1News03@avisoft.f9.co.uk> (permalink)
References <9c9556c5-8dd0-498a-b6f5-6aa531f4be63@d28g2000yqf.googlegroups.com> <c2f1bcd8-56dc-4422-a744-1c24bbcdd8c8@l36g2000vbp.googlegroups.com>
Organization None

Show all headers | View raw


On 24 Apr, in article
<c2f1bcd8-56dc-4422-a744-1c24bbcdd8c8@l36g2000vbp.googlegroups.com>,
   Gazza <usenet@garethlock.com> wrote:
> On Apr 4, 8:37 am, Martin Hansen <m...@shrewsbury.org.uk> wrote:
> > Dear All,
> > Let us suppose that program X is running on the desktop.
> > If a second copy of X is now launched, I'd like it to know that it is
> > the second copy.
> > I suspect that there is an easy way of doing this.
> > Program X is in BBC BASIC, so any code fragments in that language,
> > please.
> > Regards,
> > Martin.
> >
> > http;//www.RISCOScode.comhttp://www.MathMagical.co.uk

> Maybe I'm a little bit late here, but wouldn't the easiest way to deal
> with this would be to set a system variable to a value, any value,
> after the task is setup (1st instance) and check for it's prescence in
> the system as each subsequent instance starts.

> 1. Check Prog$Var
> 2. IF SET <abort with message and bail> ELSE <set Prog$Var and
> continue init seq.>

> On exiting the only instance running, you'd just have to remember to
> unset the flag variable (Prog$Var in this case.)

> It might be a quick and dirty way of doing it, but it always worked
> for me, and back in the day there was at least one commercial program
> that used this method. Might even have been !Zap, haven't poked around
> in the Obey files for ages. I seem to remember it took the form of XXX
> $Running (where XXX was the program name.)

But it is guaranteed to cause users difficulties if there is a problem
after the set that does not do the Unset. 

As you say, quick and nasty!
Much better to check the tasks.

-- 
Martin Avison 
Note that unfortunately this email address will become invalid
without notice if (when) any spam is received. 

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-04 00:37 -0700
  Re: As it's launched, how can a program test if a copy of itself is already running ? "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-04-04 09:59 +0200
  Re: As it's launched, how can a program test if a copy of itself is already running ? James Lampard <dontreplytothis@mailinator.com> - 2011-04-04 01:39 -0700
  Re: As it's launched, how can a program test if a copy of itself is already running ? Dave Higton <davehigton@dsl.pipex.com> - 2011-04-04 20:35 +0100
    Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-05 12:13 -0700
      Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-07 09:47 -0700
  Re: As it's launched, how can a program test if a copy of itself is already running ? Gazza <usenet@garethlock.com> - 2011-04-24 02:58 -0700
    Re: As it's launched, how can a program test if a copy of itself is already running ? Martin <News03@avisoft.f9.co.uk> - 2011-04-24 18:32 +0100
      Re: As it's launched, how can a program test if a copy of itself is already running ? "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-04-24 20:35 +0200
      Re: As it's launched, how can a program test if a copy of itself is already running ? Alan Adams <alan@adamshome.org.uk> - 2011-04-25 12:29 +0100
        Re: As it's launched, how can a program test if a copy of itself is already running ? Steve Drain <steve@kappa.me.uk> - 2011-05-05 13:01 +0100
          Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Wuerthner <spamtrap@mw-software.com> - 2011-05-05 15:51 +0200
            Re: As it's launched, how can a program test if a copy of itself is already running ? Steve Drain <steve@kappa.me.uk> - 2011-05-05 16:37 +0100
              Re: As it's launched, how can a program test if a copy of itself is already running ? Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-05-06 00:32 +0200
    Re: As it's launched, how can a program test if a copy of itself is Howard Dawson <hsdawson@ormail.co.uk> - 2011-05-17 20:35 +0100

csiph-web