home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- * $VER: FrexxFrontEd v2.3 (20.2.95) - by Daniel Stenberg & Michiel Willems
- *
- * Arexx script for FrexxEd as replacement for Ed used with Ced
- *
- * Altered by Nicolas Dade to be more general. last changed (18.2.95)
- *
- * NEW FEATURES:
- * (5.2.95)
- * o correctly handles relative paths in Filename.
- * o handles multiple filenames.
- * o cleaned up STICKY code.
- * (18.2.95)
- * o STICKY can appear anywhere in the arguments
- * BUGS:
- * o opening more than one new file at once does not work!
- * (20.2.95)
- * o [Daniel/Kjell] Added the iconfy-stuff!
- *
- *
- * USAGE/DESCRIPTION:
- *
- * Arguments: rx FrexxEdStart.rx {Filenames} [STICKY]
- * Example : rx FrexxEdStart S:Startup-Sequence S:User-Startup
- *
- ****************************************************************************/
-
- OPTIONS RESULTS
-
- IF ~SHOW('L', "rexxsupport.library") THEN DO
- IF ~ADDLIB('rexxsupport.library', 0, -30, 0)
- THEN DO
- SAY "couldn't open rexxsupport.library!"
- EXIT 10
- END
- END
-
- PARSE ARG CMDLINE
-
- IF CMDLINE = "" THEN
- NOARGS = 1
- ELSE
- NOARGS = 0
-
- NUMARGS = 0
- STICKY = 0
- DO UNTIL CMDLINE = ""
- CMDLINE = STRIP(CMDLINE)
- IF LEFT(CMDLINE,1) = '"' THEN DO
- NUMARGS = NUMARGS + 1
- PARSE VAR CMDLINE '"' NAME.NUMARGS '"' CMDLINE
- END
- ELSE DO
- NUMARGS = NUMARGS + 1
- PARSE VAR CMDLINE NAME.NUMARGS CMDLINE
- END
- IF NAME.NUMARGS="" THEN
- NUMARGS = NUMARGS - 1 /* ignore empty arguments */
- IF UPPER(NAME.NUMARGS) = "STICKY" & STICKY = 0 THEN DO /* if sticky appears twice then the second time it refers to a file */
- STICKY = 1
- NUMARGS = NUMARGS - 1
- END
- END
-
- /* if we are going to be sticky then setup a port for us to use */
- OURPORT="ED_FREXXED.no port"
- IF STICKY THEN DO
- i = 1
- cont = 0
- DO while i<100 /* no more than 100 simultaneous startups! */
- IF ~SHOW("P", "ED_FREXXED."i) THEN DO
- OURPORT = "ED_FREXXED."i
- cont = OPENPORT(OURPORT)
- IF cont THEN i = 100 /* we might not get the port if someone else creates it between the SHOW() and the OPENPORT() */
- END
- i = i + 1
- END
- IF ~cont THEN DO
- SAY "We found no free port to use!"
- EXIT(5)
- END
- END
-
- /* process each filename */
- DO n=0 TO NUMARGS
- FILE = NAME.n
-
- /* if FILE does not contain an absolute path then prepend the current dir to it */
- IF FILE~="" & POS(":",FILE)=0 THEN DO
- CDIR = PRAGMA("D")
- IF RIGHT(CDIR,1)~=":" THEN CDIR=CDIR"/"
- FILE = CDIR||FILE
- END
-
- PortName = 'FREXXED.1'
-
- IF ~SHOW(P, PortName) THEN DO
- ADDRESS COMMAND "RUN <NIL: >NIL: Fred"
- ADDRESS COMMAND "WaitForPort " || PortName
- END
- ADDRESS VALUE PortName
- 'int ID = Open (ARexxRead("FILE"));
- if(ID && atoi(ARexxRead("STICKY"))) {
- ReadInfo("_notifyport");
- if(GetErrNo())
- ExecuteFile("KillNotify.FPL");
- SetInfo(ID, "_notifyport", ARexxRead("OURPORT"));
- SetInfo(ID, "_iconify_when_quit", ReadInfo("iconify"));
- }
- else {
- ARexxSet("STICKY", "0");
- }
- Deiconify();
- WindowToFront();
- '
- END
-
- /* if STICKY then wait for NUMARGS kill notifications to show up in OURPORT */
- IF STICKY THEN DO
- DO n=1 TO NUMARGS
- DO WHILE ~WAITPKT(OURPORT) /* wait for NUMARGS messages that tell
- us that the NUMARGS previously opened
- buffer are killed */
- END
- packet = GETPKT(OURPORT) /* get package, but ignore contents! */
- CALL REPLY(packet,0) /* return OK! */
- END
- END
-
- /*************************************/
-