home *** CD-ROM | disk | FTP | other *** search
- /*
- ** AREXX $VER: Start_Web.ced 2.0 (25.10.1993)
- **
- ** DESCRIPTION: This AREXX script saves and weaves or tangles the current
- ** CED Pro 3 view (it is very easy to use it with CED Pro 2).
- ** Then it loads the resulting `.tex' or `.c' file into a
- ** new view. If a changefile is present to the webfile in
- ** the current view, i.e., a file with extension `.ch' instead
- ** of `.w' (or `.web'), it will be taken into account. To use
- ** this script, install two calls in the DOS/ARexx interface
- ** of Cygnus Ed of the form
- **
- ** CWeb:ARexx/Start_Web CTangle
- ** CWeb:ARexx/Start_Web CWeave
- **
- ** DATE: 11.09.1992 (V0.1 and V0.2)
- ** AUTHOR: Andreas Scherer
- ** Abt-Wolf-Straße 17
- ** 96215 Lichtenfels
- ** Germany
- **
- ** CHANGES: 25.10.1992: `change file' included (V0.3)
- ** 28.02.1993: `.web' extension allowed (V0.4)
- ** Options `+a +g' are default in my CWEAVE version.
- ** 19.03.1993: Absolute path name from WEB file taken into
- ** account due to CWEB 2.7 (V0.5)
- ** 31.08.1993: CWeb 2.7 [p6b] now returns RC=[0,5,10,20];
- ** give appropriate messages in CED (V0.6)
- ** 07.09.1993: Rely on system path to find CTANGLE/CWEAVE (V0.7)
- ** 03.10.1993: Refinement of program call for Cygnus Ed 3.5:
- ** ARexx<-->CED window isn't temporary anymore;
- ** output of CTANGLE/CWEAVE will be redirected
- ** to the log file `T:web.log'. This file is loaded
- ** in case of an error (V0.8)
- ** 06.10.1993: Single script for both CTANGLE and CWEAVE (V1.0)
- ** 07.10.1993: Localization of all requester texts for German
- ** and English users. Catalog with the English
- ** translation provided. These features work for
- ** WorkBench 2.1 and higher; the script works with
- ** lower versions too (V1.1)
- ** 09.10.1993: Updated for CWeb 2.8 (V1.2)
- ** 20.10.1993: Allow special device name "RAM DISK:" (V1.3)
- ** 25.10.1993: Updated for CWeb 3.0 (V2.0)
- **
- ** COPYRIGHT: (c) 1993 Andreas Scherer
- **
- ** Permission is granted to make and distribute verbatim copies of this
- ** document provided that the copyright notice and this permission notice
- ** are preserved on all copies.
- **
- ** Permission is granted to copy and distribute modified versions of this
- ** document under the conditions for verbatim copying, provided that the
- ** entire resulting derived work is distributed under the terms of a
- ** permission notice identical to this one.
- */
-
- Options FailAt 21
- Options Results
-
- /*
- ** The pre-1.0 version of this script actually consisted of two
- ** separate scripts for CTANGLE and CWEAVE. To facilitate further
- ** improvements, the name of the program we want to call is passed
- ** as a single argument on startup. It should be one of the
- ** strings `CTangle' or `CWeave'.
- */
- Parse Arg PROG_NAME
-
- /*
- ** Since CTANGLE either has the same command line options as CWEAVE
- ** or ignores the others it is save to have a common specification
- ** of activated or deactivated switches. According to the CWeb user
- ** manual options are activated by `+' and deactivated by `-'.
- ** The current implementation of the programs understand the following
- ** list of command line options:
- **
- ** a - Amiga-defined identifiers are keywords [+] (W)
- ** b - Print a banner line [+] (TW)
- ** f - Force line breaks [+] (W)
- ** g - Use German macros `gcwebmac.tex' [+] (W)
- ** h - Print a happy message [+] (TW)
- ** i - Indent parameter declarations [+] (W)
- ** p - Give progress report [+] (TW)
- ** s - Show statistics [-] (TW)
- ** x - Include indexes and table of contents [+] (W)
- **
- ** The hard-wired defaults are in brackets. A `T' or `W' in
- ** braces indicates that CTANGLE or CWEAVE acknowledges the option.
- **
- ** For the purposes of this script we set the default language
- ** to English and request that the statistics be written to the
- ** log file as explained below. Also I prefer that parameter
- ** declarations be not indented.
- */
- WEB_OPTS = "-gi +s"
-
- /*
- ** WorkBench 2.1/3.0 users are provided with localized messages in
- ** their system default language. This may be either German or English.
- ** (Other languages are welcome!) Default in this script, in case the
- ** catalogs can not be used, is the German version for all arguments
- ** to the `GetCatalogStr' function. (You will have to edit these strings
- ** by hand if you don't have WorkBench 2.1/3.0, so go get the latest
- ** version of the best!)
- */
- If 38 <= MyGetEnv("WORKBENCH") Then
- If ~Show('Libraries','locale.library') Then
- Call AddLib('locale.library',0,-30)
-
- LOCALE_FOUND = Show('Libraries','locale.library')
-
- If 1 = LOCALE_FOUND Then Do
- catalog = OpenCatalog("cweb.catalog","deutsch",0);
-
- /*
- ** Give a little progress message to the Cygnus Ed 3.5 user. Comment
- ** this out if you use Cygnus Ed 2.12.
- */
- If 'CTangle' = PROG_NAME Then
- DM "CTangle V3.0 [p8d] Copyright © 1993 Andreas Scherer"
- Else
- DM "CWeave V3.0 [p8d] Copyright © 1993 Andreas Scherer"
-
- /*
- ** Get the full filename from CED.
- */
- Status FileName /* 19 */
- FULLNAME = RESULT
-
- /*
- ** Make "RAM DISK:" a special case.
- */
- if "RAM DISK:" = Upper(Left(FULLNAME,9)) Then
- FULLNAME = "RAM:" || SubStr(FULLNAME,10)
-
- /*
- ** Error messages and warnings of CTANGLE and CWEAVE will be written
- ** to a temporary log file, which can be loaded for debugging. It will
- ** contain the complete screen output of CTANGLE/CWEAVE.
- */
- LOGFILE = "T:web.log"
-
- /*
- ** We need an absolute file name.
- */
- IVOL = Index(FULLNAME,":")
- IDIRS = LastPos("/",SubStr(FULLNAME,1+IVOL))
- FILEONLY = SubStr(FULLNAME,IVOL+1+IDIRS)
- IBASE = LastPos(".",FILEONLY)
-
- If 0 = IBASE Then
- IBASE = Length(FILEONLY)
- Else
- IBASE = IBASE - 1
-
- /*
- ** CWeb files normally have a `.w' extension.
- */
- If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | "W" ~= Upper(Right(FULLNAME,1)) Then Do
-
- /*
- ** But you may also use the `.web' form.
- */
- If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | "WEB" ~= Upper(Right(FULLNAME,3)) Then Do
- If 1 = LOCALE_FOUND Then
- Okay1 GetCatalogStr(catalog,0,"Fehler, die Datei muß eine Endung `.w' oder `.web' haben.")
- Else
- Okay1 "Fehler, die Datei muß eine Endung `.w' oder `.web' haben."
-
- Call EndGame
- End
- End
-
- If 0 = IVOL Then Do
- DIREC = Pragma('d')
- If '/' ~= Right(DIREC,1) & ':' ~= Right(DIREC,1) Then
- DIREC = DIREC||'/'
- FULLNAME = DIREC||FULLNAME
- Drop DIREC
- End
-
- /*
- ** In case there is a `change file', it has a `.ch' extension.
- */
- CHANGEFILE = Left(FULLNAME,IVOL+IDIRS+IBASE)||'.ch'
-
- /*
- ** This file will hopefully be created by CTANGLE/CWEAVE.
- */
- If 'CTangle' = PROG_NAME Then
- RESULTFILE = Left(FULLNAME,IVOL+IDIRS+IBASE)||'.c'
- If 'CWeave' = PROG_NAME Then
- RESULTFILE = Left(FULLNAME,IVOL+IDIRS+IBASE)||'.tex'
-
- /*
- ** Remember the path name of the WEB file.
- */
- PATHNAME = Left(FULLNAME,IVOL+IDIRS)
-
- Drop IVOL IDIRS IBASE
-
- /*
- ** Save only if the file has been modified.
- ** So get the number of changes to the file.
- */
- Status NumChanges /* 18 */
- If 0 < RESULT Then
- Save
-
- /*
- ** Change the current directory first.
- */
- Pragma('Directory',PATHNAME)
-
- /*
- ** Now call the CTANGLE or the CWEAVE program. We don't change the
- ** host address, because there may be more than one Cygnus Ed running,
- ** each having its own ARexx port name.
- */
- If Exists(CHANGEFILE) Then
- Address COMMAND PROG_NAME WEB_OPTS FULLNAME CHANGEFILE ">"LOGFILE
- Else
- Address COMMAND PROG_NAME WEB_OPTS FULLNAME ">"LOGFILE
-
- /*
- ** Patch level [p6b] of `common.w' now returns error and warning codes
- ** as defined for the AMIGA system. Take appropriate actions.
- */
- If 20 = RC Then Do
- If 1 = LOCALE_FOUND Then
- Okay1 PROG_NAME || " " || GetCatalogStr(catalog,1,"mit fatalem Fehler abgebrochen! Keine Ausgabe!")
- Else
- Okay1 PROG_NAME || " " || "mit fatalem Fehler abgebrochen! Keine Ausgabe!"
- OW LOGFILE
- Call EndGame
- End; Else If 10 = RC Then Do
- If 1 = LOCALE_FOUND Then
- Okay1 PROG_NAME || " " || GetCatalogStr(catalog,2,"beendet mit Fehler! Ausgabe fehlerhaft!")
- Else
- Okay1 PROG_NAME || " " || "beendet mit Fehler! Ausgabe fehlerhaft!"
- OW LOGFILE
- Call EndGame
- End; Else If 5 = RC Then Do
- If 1 = LOCALE_FOUND Then
- Okay2 PROG_NAME || " " || GetCatalogStr(catalog,3,"beendet mit Warnung!" || '0A'X || "Ausgabe wahrscheinlich korrekt.")
- Else
- Okay2 PROG_NAME || " " || "beendet mit Warnung!" || '0A'X || "Ausgabe wahrscheinlich korrekt."
-
- If 0 = RESULT Then Do
- OW LOGFILE
- Call EndGame
- End
- End
-
- /*
- ** Now load the resulting `.tex' or `.c' file into a new CED view.
- */
- If Exists(RESULTFILE) Then Do
- 'jump to file "'RESULTFILE'"'
-
- /*
- ** The `.tex'- or `.c'-file is already in a CED view. Leave it, then
- ** load it again. Is there a better way to do this?
- */
- If 0 ~= RESULT Then
- Quit
-
- Open new
- Open RESULTFILE
- End; Else
- If 1 = LOCALE_FOUND Then
- Okay1 GetCatalogStr(catalog,4,"Fehler bei") || " " || PROG_NAME
- Else
- Okay1 "Fehler bei" || " " || PROG_NAME
-
- EndGame:
- If 1 = LOCALE_FOUND Then
- CloseCatalog(catalog);
- DM
- Exit
- Return
-
- /*
- ** When will ARexx supply GetEnv/SetEnv?
- */
- MyGetEnv: Procedure
- Parse Arg NAME
-
- If Open(TEMPFILE,"ENV:"||NAME,'r') Then Do
- GIVES = Readln(TEMPFILE)
- Call Close TEMPFILE
- End; Else GIVES = 37
-
- Return GIVES
-