Groups search result 8 for apmt os/2 |
/* rexx In article <4p1ohg$108@castle.nando.net> you wrote:
: I need some help with a problem and I figure a rexx script would
: help me with it.
: This is my problem:
: We have and OS/2 application program that only opens as a new window
: and as a result, these public workstations will sometimes end up having
: 10 or more sessions of the same program.
*=*=*
^^^^^^^ Does this mean you can't just set the desktop settings to
"open existing window" ??? (see window page in desktop settings)
: What I need:
: I need some way to determine if the program is running and if it is
: make it active, if not open new session.
clint,
This is the perfect use for Rexx and rexx extension APMT
(stands for "A PM automation Tool", Employee Written Software [EWS]
from IBM and it's free).
1) Get the file: APMTST.ZIP, you can
find it on all sorts of os/2 cdroms like the hobbes archive disk.
Or you can get it in the EWS area on hobbes.nmsu.edu.
Anyway, get the file, unzip it in a directory where you want
rexx things to go, I use f:\rexx\dll and I chuck all the dll's
and .exes needed for my rexx extensions in there.
2)
Now, if you will use this a lot, go to your bootable partition,
and if you have a \startup.cmd file, load it to the editor.
This simplifies other rexx programs calling it and it ensures
that all os/2 sessions can access apmt functions.
Enter this to your startup.cmd file to register the apmt functions:
(note: exact capitalization may not be needed, I just think it
looks better):
============== start of file excerpt, cut ========== */
/* rexx startup.cmd file */
call RxFuncAdd "APMTLoadFuncs", "apmtext","APMTLoadFuncs"
call APMTLoadFuncs
/* ------------------- end of file, cut -------
Now save that file and go create a new rexx program file in a
directory that will be handy.... maybe \rexx\prog
============================== cut here, start of rexx ====== */
/* rexx startprog.cmd */
rc = INIT_SESSION() /* initializes an apmt session */
if rc \= 0 then
do
say "problem with init_session()"
say APMTMSG /* says apmt canned error msg */
exit
end
/* the below will try to select your program, if it fails we
assume this is because the program was never started (this
could be wrong but that would be a problem outside the scope
of what you're doing, apmt failure codes (rc) are anything
not = 0. So when it fails, it calls start_program to start.
prog_name is the name of the program,---- this should
be what you see on the window title bar on the window when
you start this program ---- , if you like you can
use wildcards with apmt in that first name field but
be careful, apmt functions can be very picky about
the spelling and case of the input, see below for
my examples, I was testing this thing with TE/2 */
title = "TE/2*" /* note use of wildcard */
prog_name = "te2td.exe" /* enter your program name here */
work_dir = "f:\os2\te2" /* put directory name where prog is */
command_parms = "" /* put command line arguments if any
remove from START_PROGRAM if none
exist, (ie don't leave in my example!)
put in "" in START_PROGRAM for 2nd place */
rc = SELECT_WINDOW(title);
say "select_window says:" rc
if (rc \= 0) then /* program not running, start it */
do
rc = START_PROGRAM(prog_name, command_parms, work_dir)
select
when (rc == 5) then /* ---> directory wrong */
do
say "Directory" work_dir "is incorrect"
say APMTMSG
say ".....quitting"
exit
end
when (rc == 6) then /* prog failed to start ok */
do
say "Program startup failed for Prog:" prog_name
if length(command_parms) \= 0 then
say "parameters:" command_parms
say APMTMSG
say ".....quitting"
exit
end
otherwise nop; /* success */
end /* end select */
end
else /* program is running already, quit */
do
rc = END_SESSION();
if rc \= 0 then say "end_session() error"
exit
end
/*================ cut, end of rexx prg ========
Mark,
ps good luck. Read the apmt .inf file in the package, it's helpful.
I have several other neat rexx programs that uses apmt's features. If
anyone is interested I'll post/mail them to them.*/
©2002 Google