[comp.lang.rexx] Something useful with AREXX

murphy@pur-phy (William J. Murphy) (12/15/89)

Yesterday, I had the misfortune of crashing in the middle of an editing
session in DME without having saved during the last hour. >-(  Well, that
got me to thinking, "why couldn't AREXX fire up a program which starts
up every 5 minutes or so and tells DME to save whatever it is working on?"

So my question is this, "What would be the best approach to getting AREXX
to put a program to sleep for 5 minutes and then sending DME a message to 
save all files to a temporary space?"  Would it be better if there were
two programs, one in C and the second in AREXX?  The C program could be a
more general purpose chron program with an AREXX port which calls AREXX
to call DME. 

Has anyone done this sort of thing?  Please share it if you can/will.

Thanks,
-- 
 Bill Murphy        murphy@newton.physics.purdue.edu

mks@cbmvax.commodore.com (Michael Sinz - CATS) (12/15/89)

In article <2897@pur-phy> murphy@newton.physics.purdue.edu.UUCP (William J. Murphy) writes:
>
>Yesterday, I had the misfortune of crashing in the middle of an editing
>session in DME without having saved during the last hour. >-(  Well, that
>got me to thinking, "why couldn't AREXX fire up a program which starts
>up every 5 minutes or so and tells DME to save whatever it is working on?"
>
>So my question is this, "What would be the best approach to getting AREXX
>to put a program to sleep for 5 minutes and then sending DME a message to 
>save all files to a temporary space?"  Would it be better if there were
>two programs, one in C and the second in AREXX?  The C program could be a
>more general purpose chron program with an AREXX port which calls AREXX
>to call DME. 
>
>Has anyone done this sort of thing?  Please share it if you can/will.

That is easy of DME has an AREXX port.  Just have a simple AREXX program
that contains something like this:  (This is not REAL code...)

     address command; "Wait 5 minutes"   /* Use th CLI wait command */
     check if DME is still around and exit if not...
     address DME; "do the save command"  /* I don't have DME */
     /* Now loop back and wait again... */

>
>Thanks,
>-- 
> Bill Murphy        murphy@newton.physics.purdue.edu

/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          When people are free to do as they please,            |
| \XX/                they usually imitate each other.                 |
\----------------------------------------------------------------------/

new@udel.edu (Darren New) (12/16/89)

DME does have an AREXX port capability, but it is a little limited.
Basically (from reading the code) it creates a port when you
issue a rexx command from within DME, it ignores (mostly) the
keyboard until the command comes back, and then it tosses
the port.  Therefore, you cannot run rexx and dme asyncronously
and have them talk.  Again, this is from an inspection of the
code for the version of DME that I have, so I may be wrong.
		      -- Darren

davewt@NCoast.ORG (David Wright) (12/16/89)

In article <2897@pur-phy> murphy@newton.physics.purdue.edu.UUCP (William J. Murphy) writes:
>
>two programs, one in C and the second in AREXX?  The C program could be a
>more general purpose chron program with an AREXX port which calls AREXX
>to call DME. 
>
>Has anyone done this sort of thing?  Please share it if you can/will.

	I have seen 2 versions of Cron that have ARexx ports to send
messages at certain times. You could also just use a normal Cron-type
program and have it execute an ARexx script.

			Dave

kim@uts.amdahl.com (Kim DeVaughn) (12/16/89)

In article <9031@cbmvax.commodore.com>, mks@cbmvax.commodore.com (Michael Sinz - CATS) writes:
> 
> That is easy of DME has an AREXX port.  Just have a simple AREXX program
> that contains something like this:  (This is not REAL code...)
> 
>      address command; "Wait 5 minutes"   /* Use th CLI wait command */
>      check if DME is still around and exit if not...
>      address DME; "do the save command"  /* I don't have DME */
>      /* Now loop back and wait again... */

Wellllll ... yes and no.

I was the one who added the initial ARexx support to DME, and as I said in the
documentation, it was a *minimal* implementation of that facility.  Far as I
know, it hasn't been extended ... if it has, I would certainly like to know
about it.

What's "minimal"?  If you give DME a command that it doesn't recognize as a
builtin, it'll hand it off to ARexx.  As long as that macro does exist, and
while it is still execution, it's reply port will indeed be around, so some-
thing like the above *may* work (I've not tried to do that).  I think what'll
happen though is that DME will appear to hang, as (if memory serves) DME will
not process any further commands (except from the macro, which may also be
other macro calls) until the macro finishes and returns with a completion code.

Also DME is not setup to respond to unsolicited msgs coming in ... currently,
the interaction must be initiated from the editor itself.


I would like to get back to this project, and do a full implementation, but
aside from the demands on my time for other things, there are some fundemental
problems that would need to be fixed in DME which would be rather extensive.

Biggest problem is the limited amount of error handling/reporting that DME
does.  As it stands, it is *very* difficult for the ARexx macro to know when
a command it issued to DME completed or failed, etc.  Also, there are a number
of parameters that need to be "broken out" so they can be passed to the macro
(insert/overstrike mode, current line/col, cursor position, etc, etc.)


Maybe one of these days ...


Sorry to ramble on so about something that is more about a particular editor,
than the REXX language per se, but I think some explanation was called for.


/kim


P.S.  Give Michael's scheme a try, but don't expect too much.  I'd be delighted
      if it works.  If so, please post/email me about it.

-- 
UUCP:  kim@amdahl.amdahl.com
  or:  {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim
DDD:   408-746-8462
USPS:  Amdahl Corp.  M/S 249,  1250 E. Arques Av,  Sunnyvale, CA 94086
BIX:   kdevaughn     GEnie:   K.DEVAUGHN     CIS:   76535,25

rsingh1@dahlia.waterloo.edu (12/16/89)

EAT ME
 
I'm not familiar with how DME interfaces arexx, but the simplest
solution, although not the most elegent is to do something simple like:
 
/* MEGAdealy MegaDME MegaMegaSave Mega Program V0.0 */
arg fred
Do Forever
  Call Delay 50*fred  /* the argument fred is the # of seconds to wait */
  If Find(Show('P'),"DME") >1 Then Address DME 'whatever commands you want
    dme to do'
End

That little blurb of junk will wait 'fred' seconds (you supply that when
you invoke it (cli argument).  Then it will look for the port name
DME (if it's not called DME, change it).  If it is somewhere in the
ports list, it will address dme, and send it whatever commands you like.
 
If you quit DME for a while, it won't barf all over you (just keep delaying).
 
Embelish it to your satisfaction.  It should work.  I suggest you look into
CygnusEd.  It's got autosaving, and lots of other teriffic junk.
 
BTW, you can 'run' this arexx program for your convienience.  Invoke it
by doing something like:
 
run rx megadelay 20000000 (system will wait 20000000 seconds before the first
message to DME (over five thousand five hundred hours! (231.48 days!)
 
Later

 
               /Paul Anton Sop (Esquire?).  rsingh1@dahila.waterloo.edu/
              /Graphic Designer 4 Spaghetti Western Words and Images  /
             /100 Kinzie Ave, Kitchener, Ontario, Canada, N2A 2J5    /
            /(519) 578-8525/742-0372 (if seriously really desparate)/

kim@uts.amdahl.com (Kim DeVaughn) (12/16/89)

In article <19326@watdragon.waterloo.edu>, rsingh1@dahlia.waterloo.edu writes:
>  
> I'm not familiar with how DME interfaces arexx, but the simplest
> solution, although not the most elegent is to do something simple like:
>  
> /* MEGAdealy MegaDME MegaMegaSave Mega Program V0.0 */
> arg fred
> Do Forever
>   Call Delay 50*fred  /* the argument fred is the # of seconds to wait */
>   If Find(Show('P'),"DME") >1 Then Address DME 'whatever commands you want
>     dme to do'
> End

Won't work in the current implementation.  DME is not setup to receive arbitrary
unsolicited messages; only to invoke a REXX macro on it's own behalf.

One other little "gotcha" ... a port that is setup to do what you want would
likely not have quite such a simple name.  You might easily have several copies
of DME running, and they each would need their own unique port (and port name),
so you'd have to do some searching.  And then how do you tell when you've found
the correct DME's port ...?


> That little blurb of junk will wait 'fred' seconds (you supply that when
> you invoke it (cli argument).  Then it will look for the port name
> DME (if it's not called DME, change it).  If it is somewhere in the
> ports list, it will address dme, and send it whatever commands you like.

The DME port used for the REXX macro to issue commands back to the editor only
exists while  that macro invocation is in progress.  There isn't one just 
"hanging around".


Hopefull, I can get back to this project one of these days, and do the full
implementation ...


/kim

-- 
UUCP:  kim@amdahl.amdahl.com
  or:  {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim
DDD:   408-746-8462
USPS:  Amdahl Corp.  M/S 249,  1250 E. Arques Av,  Sunnyvale, CA 94086
BIX:   kdevaughn     GEnie:   K.DEVAUGHN     CIS:   76535,25