program starting once

Bennie H.

New Member
How can i avoid a user starting the same program more than once? Is there a parameter to check this or do I have to program this myself? Do you have a suggestion?

Many thanks, Bennie
 

arekp

New Member
You can use simply code in the begin of your procedure (for example in standard include):

def var i as integer.
def var name as char.

name = PROGRAM-NAME(2).

i = 3.
DO WHILE PROGRAM-NAME(i) <> ?:
if PROGRAM-NAME(i) = name then do:
MESSAGE "You can't run '" name "' procedure twice !" view-as alert-box.
return.
end.
i = i + 1.
END.

Best Regards,
Arek


Bennie H. said:
How can i avoid a user starting the same program more than once? Is there a parameter to check this or do I have to program this myself? Do you have a suggestion?

Many thanks, Bennie
 

Bennie H.

New Member
Thx for your reply but I still have a problem. I think I can prevent users to start the same program within that program (example starting progX.r from progX.r) with your code,
but where I'm searching for is preventing users to start a program twice by double-clicking an destktop-icon twice.


arekp said:
You can use simply code in the begin of your procedure (for example in standard include):

def var i as integer.
def var name as char.

name = PROGRAM-NAME(2).

i = 3.
DO WHILE PROGRAM-NAME(i) <> ?:
if PROGRAM-NAME(i) = name then do:
MESSAGE "You can't run '" name "' procedure twice !" view-as alert-box.
return.
end.
i = i + 1.
END.

Best Regards,
Arek
 

arekp

New Member
Then your problem is not Progress Development problem, but windows administration problem :) And I don't know how can I help you.
My procedure blockade running the same procedure in one PROGRESS session of course.

Regards,
Arek



Bennie H. said:
Thx for your reply but I still have a problem. I think I can prevent users to start the same program within that program (example starting progX.r from progX.r) with your code,
but where I'm searching for is preventing users to start a program twice by double-clicking an destktop-icon twice.
 

j4n

Member
try:

this-procedure:file-name
and than just move with this-procedure:next-sibling till there is no next :awink:
 
There is a startup parameter which will force you to only have one Progress session on the PC.

-wss - Windows Single Session in the startup for each client may be what you are looking for.
 

arekp

New Member
this-procedure:file-name is almost the same like PROGRAM-NAME(...) and will work only in the same PROGRESS session.

Arek

j4n said:
try:

this-procedure:file-name
and than just move with this-procedure:next-sibling till there is no next :awink:
 

Crittar

Member
One suggestion (although not particularly elegant) is to create a table somewhere and update that table with program name and user id as soon as the program starts unless the program name user id combination is already on the table in which case issue a message and then exit.

Make the final action of the program a deletion of the specified record.
 

bendaluz2

Member
To do this I make use of a windows api that registers each instance of the program with windows. You can find information about it on

http://www.global-shared.com

Click on Win32-API and then do a search for mutex

You will also need to download an include file called mutex.i to use this functionality.

Bennie H. said:
How can i avoid a user starting the same program more than once? Is there a parameter to check this or do I have to program this myself? Do you have a suggestion?

Many thanks, Bennie
 

vdennis

Member
What I do

In my windows enviroment I am able to control this if the program is running persistent. If it is, when the person clicks on the trigger for that program it simplys drops them back into the program. There are problems with this approach as you need to be sure that when you 'drop' into that program it shows on top of the stack. (Usually a problem when Outlook or Office is running.)

The way I do this is as follows:

1. I have a table with all the program-names with security access levels, so when a user hits a trigger it first looks at my SECURITYACCESS procedure for access rights and to check if this program is running or not. Remember, this only work for persistent programs.

Here is the code that checks that, (def vars have been left out.)

IF Z-Pro.RunPersistent = YES THEN DO: /*from the db table */
ASSIGN knockout = NO. /*Cant remember what this is for*/
IF z-pro.acc-lev <= nlss-per THEN DO: /*access level for user */
ASSIGN h_ProcedureHandle = SESSION:FIRST-PROCEDURE.
DO WHILE VALID-HANDLE(h_ProcedureHandle):
IF h_ProcedureHandle:FILE-NAME = Z-Pro.RndCmd THEN LEAVE.
ASSIGN h_ProcedureHandle = h_ProcedureHandle:NEXT-SIBLING.
END.
IF VALID-HANDLE(h_ProcedureHandle) THEN DO:
MESSAGE "This program is already running".
ASSIGN knockout = YES.
RUN ComeBack IN h_ProcedureHandle. /* takes you back */
END.
ELSE DO:
RUN VALUE(Z-Pro.RndCmd) PERSISTENT SET h_ProcedureHandle. /*program was not running, so now it can*/
END.
END.
ELSE DO:
MESSAGE "Sorry, you do not have the authority." view-as alert-box.
END.
END.

Hope this helps.

-Dennis-

Bennie H. said:
How can i avoid a user starting the same program more than once? Is there a parameter to check this or do I have to program this myself? Do you have a suggestion?

Many thanks, Bennie
 
Top