I like the method of getting the data into a data area. I can't recall where I found my example, but it is not nearly as easy to read or to modify.
Thanks Scott for the continuing education!!
From: Scott Klement midrange-l@xxxxxxxxxxxxxxxx
Date: Thu, 17 Sep 2009 13:47:55 -0500
To: Midrange Systems Technical Discussion midrange-l@xxxxxxxxxxxx
Subject: Re: Scanning a STMF for a string
Somewhere, buried in the stream file of arbitrary length, there may or
may not be a string of the form
foo="<block of 20 characters>"
This is very similar to what Dennis Lovelady just posted... ack, I'm too
slow... but mine does have some differences from his, so I'm posting it
CRTDTAARA DTAARA(TESTAREA) TYPE(*CHAR) LEN(20)
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) REPLACE(*YES) +
ADDENVVAR ENVVAR(STMF) REPLACE(*YES) +
ADDENVVAR ENVVAR(DTAARA) REPLACE(*YES) +
QSH CMD('cat $STMF | +
sed -n ''s/.*foo="\(....................\)".*/\1/p'' | +
datarea -wl $DTAARA.dtaara')
Differences between mine & Dennis:
a) Mine assumes the foo= can appear in the middle of other text. (I'm
actually assuming you're trying to grab this out of an XML file)
b) Mine assumes data between quotes is always 20 chars, period. Dennis
solution will take any length... (maybe I took you too literally)
c) Mine writes the output to a data area, his wrote it to an environment
variable inside Qshell.
d) If there's more than one foo= string in the file, mine will only take
the first one. Dennis' will take them all (but store them all together
in one variable.)
So... mine is very similar, in some ways better, in some ways worse than
Dennis'... but I thought it might be worth posting anyway.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives