I do something similar, although rarely. When I need to load a table and it
seems to make sense that the data be hardcoded in the code -- which after
all is pretty seldom -- sometimes I do this:
/* TBLBGN <tablename> (usually at the end of the program):
name1 value1
name2 value2
name3 value3
TBLEND */
During initialization I can have one or more statements to CALL TBLLOAD
<tablename>, which does something like this:
/* Load a table. */
LoadTbl: procedure expose tbl.
parse arg tblname
ftbl=0
do vl=1 to sourceline()
vs=sourceline(vl)
select;
when pos('TBLBGN' tblname,space(vs))>0 then ftbl=1
when pos('TBLEND',vs)>0 then leave
when ftbl then do
parse var vs 1 key +10 val
tbl.tblname.key=val; end
otherwise nop; end; end;
return
I can go years without using this, because normally the data would be simple
enough to be in a single string (eg "profiles='<str> <str> <str>...'") or
I'd use an external dataset. But once in a while...
---
Bob Bridges, [email protected], cell 336 382-7313
/* Cooking tip: If you cook your kale with a little coconut oil, it makes it
easier to scrape it into the garbage. -YS @NYinLS2121 */
-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of
Jeremy Nicoll
Sent: Sunday, June 20, 2021 15:25
....What I actually did was placed in each stem that the program used a list
of subscript names, eg from the initial comment where I noted how I was
going to use a "fld." stem:
/* Create a table containing field data layout information:
/*
/* fld.0 - the number of defined fields
/*
/* fld.0.1 - list of !xxxx values shared by mainline code and
functions, eg "!pp !qq !rr !ss"
/*
/* fld.n.!xxxx: - properties of the n'th defined field, where "xxxx" can
be:
/* !name - before data file is inspected: anticipated name
of field
/* !minw - before data file is inspected: anticipated
minimum width
/* !maxw - before data file is inspected: anticipated
maximum width
/* !strt - in the data file, the starting column
/* !wdth - in the data file, the actual width
then in the mainline code
fld. = 0
fld.0.1 = "!name !minw !maxw !strt !wdth"
do ff = 1 to words(fld.0.1) /* assign values 1, 2, 3... to vars named in
"fld.0.1" */
ffthvnam = word(fld.0.1,ff)
waste = value(ffthvnam,ff)
end
then in a procedure that uses that stem, the whole stem is exposed, and
right after that I repeat the same loop as I had in the mainline code.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN