[Gambas-user] Running program

Cogier charlie at ...2793...
Fri Nov 9 17:36:20 CET 2012


Thanks Fabien Bodard (good thought) & Johny Provoost. I tried Johny's
solution and it did work, with modifications. I am using Gambas 2.23 and the
following code did the trick. (The program is called "Barcode")

Public Sub Form_Open()
DIM sOutput AS String 
     'Check if the program not already started 
     EXEC ["pgrep", "-f", "-l", "Barcode"] WAIT TO sOutput 
     IF Split(Trim$(sOutput), gb.NewLine).Count > 1 THEN 
     Message.Info("The program already started") 
         QUIT 
     ENDIF
END

The Fmain.TempString kept throwing up errors

Problem solved


Johny Provoost wrote:
> 
> 
> Op 07-11-12 12:12, Cogier schreef:
>> Can you tell me the best way to spot that there is another instance of
>> the
>> same Gambas program running at the same time.
>>
>> I have users who sometimes start the same program written in Gambas twice
>> and I would like the 2nd instance to pop up a message saying that there
>> is
>> already a copy of the program running.
>>
>> Thanks for your help.
> 
> Got this from one of the listmembers long time ago. Forgot his name 
> (shame on me)
> 
> Public Sub Form_Open()
> Dim sOutput As String
>      'Check if the program not already started
>      Exec ["pgrep", "-f", "-l", "NameProgram"] Wait To sOutput
>      If Split(Trim$(sOutput), gb.NewLine).Count > 1 Then
>          FMain.TempString = ("Program already started")
>          Message.Info(FMain.TempString)
>          Quit
>      Endif
> End
> 
> 
> Johny Provoost
> 
> 
> 
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
-- 
View this message in context: http://old.nabble.com/Running-program-tp34651275p34661414.html
Sent from the gambas-user mailing list archive at Nabble.com.



More information about the User mailing list