This is NOT my code, and I can't locate the original author. Tom Cone suggested posting it here to make it available to others and so I do so with my deepest apologies to the original author.
'put this in the autoexec code (at the beginning) prevent user from opening
'multiple sessions. this is before the other autoexec command lines i.e. window.title= and any other items in the autoexec
id_list=upper(Sys_id_enum())
recs=occurs(crlf(),id_list)+1
dim progs[recs] as c
dim opens as n
dim win_name as c
win_name=a5.window_title
'(the title is set in the autoexec file)opens=0
'sets the opens value to 0 on startup, then increases is to 1
progs.initialize(id_list)
for i=1 to recs
if *any(alltrim(upper(progs[i])),alltrim(upper(win_name)))
'this checks for the window title, and if already
'produces the erroropens=opens + 1
end if
next
if opens > 1
'this checks the opens value to be 1 if it is greater than 1'the error is produced and the program uses a5.close()ui_msg_box("Error"," The Program Is Already Open but Minimized!" + crlf(2)\
+ "This Second Copy of the Application Will Now Abort ",16)
'the spaces above are for appearance
'note that sys_focus_put is removed - otherwise
'it closes the already open window - now it closes this the 2nd attempt window a5.close()
end
end if
'end chk session code
AN EXAMPLE
'Date Created: 14-Mar-2008 08:35:49 PM
'Last Updated: 14-Mar-2008 08:35:49 PM
'Created By : john
'Updated By : john
'Date Created: 05-Aug-2002 12:35:01 AM
'Last Updated: 12-Mar-2008 08:22:03 AM
'Created By : DMSI
'Updated By : John Lemisch
'checksession()
'this would call the function rather than use the code to
'make editing it out easierid_list=upper(Sys_id_enum())
recs=occurs(crlf(),id_list)+1
dim progs[recs] as c
dim opens as n
dim win_name as c
win_name=a5.window_title
opens=0
progs.initialize(id_list)
for i=1 to recs
if *any(alltrim(upper(progs[i])),alltrim(upper(win_name)))
opens=opens + 1
end if
next
if opens > 1
ui_msg_box("Error"," The Program Is Already Open but Minimized!" + crlf(2)\
+ "This Second Copy of the Application Will Now Abort ",16)
'the spaces above are for appearance
�note that sys_focus_put is removed - otherwise
'it closes the already open window - now it closes this
'the 2nd attempt window
a5.close()
end
end if
A5.window_title="Data Management Solutions"
script_play("MYINFO")
'put this in the autoexec code (at the beginning) prevent user from opening
'multiple sessions. this is before the other autoexec command lines i.e. window.title= and any other items in the autoexec
id_list=upper(Sys_id_enum())
recs=occurs(crlf(),id_list)+1
dim progs[recs] as c
dim opens as n
dim win_name as c
win_name=a5.window_title
'(the title is set in the autoexec file)opens=0
'sets the opens value to 0 on startup, then increases is to 1
progs.initialize(id_list)
for i=1 to recs
if *any(alltrim(upper(progs[i])),alltrim(upper(win_name)))
'this checks for the window title, and if already
'produces the erroropens=opens + 1
end if
next
if opens > 1
'this checks the opens value to be 1 if it is greater than 1'the error is produced and the program uses a5.close()ui_msg_box("Error"," The Program Is Already Open but Minimized!" + crlf(2)\
+ "This Second Copy of the Application Will Now Abort ",16)
'the spaces above are for appearance
'note that sys_focus_put is removed - otherwise
'it closes the already open window - now it closes this the 2nd attempt window a5.close()
end
end if
'end chk session code
AN EXAMPLE
'Date Created: 14-Mar-2008 08:35:49 PM
'Last Updated: 14-Mar-2008 08:35:49 PM
'Created By : john
'Updated By : john
'Date Created: 05-Aug-2002 12:35:01 AM
'Last Updated: 12-Mar-2008 08:22:03 AM
'Created By : DMSI
'Updated By : John Lemisch
'checksession()
'this would call the function rather than use the code to
'make editing it out easierid_list=upper(Sys_id_enum())
recs=occurs(crlf(),id_list)+1
dim progs[recs] as c
dim opens as n
dim win_name as c
win_name=a5.window_title
opens=0
progs.initialize(id_list)
for i=1 to recs
if *any(alltrim(upper(progs[i])),alltrim(upper(win_name)))
opens=opens + 1
end if
next
if opens > 1
ui_msg_box("Error"," The Program Is Already Open but Minimized!" + crlf(2)\
+ "This Second Copy of the Application Will Now Abort ",16)
'the spaces above are for appearance
�note that sys_focus_put is removed - otherwise
'it closes the already open window - now it closes this
'the 2nd attempt window
a5.close()
end
end if
A5.window_title="Data Management Solutions"
script_play("MYINFO")
Comment