Re: Can someone post a brexx file i/o example ? (for Sixpack Rexx)
"Robert O'Hara" <rohara-h1UBTB8qgA32lB8bt/G8DwC/[email protected]>
| Newsgroups | gmane.comp.emulators.hercules390.vm |
|---|---|
| Message-ID | <[email protected]> |
Mike,
This is an example of part of what you want, reading a file.
Bob
-------------
/**************************************************************************************************/
/* Display a file in hexadecimal. */
/* */
/* Robert O'Hara, Lotus Development Corporation, October 1987. */
/* Updated for VM/370 CMS, Redmond Washington, July 2010. */
/**************************************************************************************************/
ARG fn ft fm here .
IF fn = "" | ft = "" THEN CALL Tell
IF fm = "" THEN DO
fm = "A"
here = 1
END
ELSE IF Datatype(fm) = "NUM" THEN DO
here = fm
fm = "A"
END
ELSE IF here = "" THEN here = 1
IF Datatype(here) <> "NUM" THEN CALL Tell
file = fn ft fm
bytes = Xrange("00"x, "FF"x)
CALL LineIn(file, here, 0)
good = Copies(".", 64)||Xrange("40"x, "FA"x)||"....." /* displayable characters, more or less */
DO record = here BY 1 WHILE Lines(file) > 0 /* loop through the entire file */
line = LineIn(file)
DO WHILE line <> "" /* loop through this line */
PARSE VAR line chunk 17 line /* get the first 16 bytes */
hex = C2x(chunk)
ebcdic = Translate(chunk, good, bytes, ".")
out1 = Substr(hex, 1, 8) Substr(hex, 9, 8) Substr(hex, 17, 8) Substr(hex, 25, 8)
out2 = Substr(ebcdic, 1, 4) Substr(ebcdic, 5, 4) Substr(ebcdic, 9, 4) Substr(ebcdic, 13, 4)
SAY Right(record, 5, "0") out1 out2
END
END
CALL LineOut file
EXIT
Tell:
SAY "HEXTYPE fn ft [fm | A] [record | 1]"
SAY "Displays 'fn ft fm' in hex dump format, starting at 'record'."
EXIT 100
-------------
--- In [email protected], Mike Stramba <mikestramba@...> wrote:
>
> What I'd like to know is how to :
>
> 1) Open a file for reading (a text/ascii (ok EBCDIC) .. ie. like an EXEC file
>
> 1a) Open/create another file for writing
>
> 2) read lines till EOF
>
> 3) scan for an identifer in the line that was read
>
> 4) Write to the second file until that same identifier is found
> again, at that point, a new file is opened
>
> The actual app is to convert a MACLIB from VM/sp5 to VM sixpack.
>
> I've done a punch of the maclib from the VM/sp5 system, and have read
> the file from the reader, it results in a file like below.
>
> So I need to scan for ":READ" ... write the lines to "GCMD MACRO A",
> until the next ":READ" is found
>
>
> :READ GCMD MEMBER B1 NOSHAD 08/05/10 19:25:27
> MACRO GMA00010
> &LAB GCMD &A GMA00020
> CNOP 0,4 GMA00030
> &LAB LA 1,&A GMA00040
> LR 0,1 GMA00050
> IC 1,*+22 GMA00060
> ST 0,*+18 GMA00070
> STC 1,*+14 GMA00080
> LA 1,*+6 GMA00090
> SVC 11 GMA00100
> DC CL4'COMD' GMA00110
> DC AL1(L'&A) GMA00120
> DC AL3(0) GMA00130
> MEND GMA00140
> :READ GSTOP MEMBER B1 NOSHAD 08/05/10 19:25:27
> MACRO GMA00210
> &LAB GSTOP GMA00220
> CNOP 2,4 GMA00230
> &LAB LA 1,*+6 GMA00240
> SVC 11 GMA00250
> DC CL4'STOP' GMA00260
> DC A(0) GMA00270
> MEND GMA00280
>