No, awk functions do NOT need to be declared in the BEGIN rule. Functions can be defined anywhere including between rules, before the first BEGIN rule, after the END rule, or after the last rule in the input if there is no END rule.
Some time ago I wrote quite a complex set of awk programs that I used at home for managing my personal finance information (not trading, just banking and budgeting). I used @include quite frequently in those programs. My major reason for using PDSE members is lack of good support for non-3270 telnet connections to my employer's systems. 3270 screen access is all I have that is reliable and easy to use. No NFS access either, only ftp. Not that I much like the z/OS shell implementation, but I could learn to use it effectively if I had reliable access. I was recently introduced to the zowe cli and the zowe VSCode interface on the IBM student site zXplore. Great tools. Now if only I could convince the Powers that we need it. One can dream. Peter -----Original Message----- From: IBM Mainframe Discussion List <[email protected]> On Behalf Of Paul Gilmartin Sent: Tuesday, December 21, 2021 8:40 PM To: [email protected] Subject: Re: AWK ? - Re: Top 8 Reasons for using Python instead of REXX for z/OS On Wed, 22 Dec 2021 00:20:19 +0000, Farley, Peter x23353 wrote: >I keep various awk "function packages" in separate members in the PDS. Each >one has functions I may use in the real program, which is always the last one >in the concatenation. > ... >Also, z/OS awk does not (I think) support the gawk "@include" functionality >that allows one to keep such function packages in separate files but not have >to mention them on the awk command line (multiple "-f" parameters and file >names on the awk command line does effectively the same thing as the >concatenated DD I use). > Do awk functions need to be declared in the BEGIN rule? I've always done so. I've never written awk so complex that I felt need for "@include". If I did I think I'd just wrap the awk in a shell script and embed the functions with "$( ... )". What advantage do you see in PDSE members over UNIX directory members which I find more natural and portable to my desktop. For Rexx I've used DD concatenation and copied the result to a temp PDS(E) with IEBGENER or REPRO in an IKJ* driver. It's convenient that each function can contain a test driver which is bypassed by the RETURN in the main program which is often a SYSIN. Again, I find UNIX members more convenient because I can test each function-member with a single command; no JCL or SDSF needed. > ... Typical JCL example: > >//AWKSPLIT EXEC PGM=BPXBATSL,MEMLIMIT=256M, >// PARM='PGM /bin/awk --f //DD:SCRIPT //DD:TEXTIN' >//STDOUT DD DISP=(NEW,CATLG,CATLG), >// DSN=output.qsam.file,.name, >// UNIT=TEST,SPACE=(CYL,(1,1),RLSE), >// DSORG=PS,RECFM=VB,LRECL=8004,BLKSIZE=0,BUFNO=31 >//STDERR DD SYSOUT=* >//SCRIPT DD DISP=SHR,DSN=TSOUSER.TEST.AWK(CSVSPLIT) >// DD DISP=SHR,DSN=TSOUSER.TEST.AWK(STRFUNCS) >// DD DISP=SHR,DSN=TSOUSER.TEST.AWK(STRFTIME) >// DD DISP=SHR,DSN=TSOUSER.TEST.AWK(MKTIME) >// DD DISP=SHR,DSN=TSOUSER.TEST.AWK(NEWTESTS) >//TEXTIN DD DISP=SHR,DSN=input.qsam.or.pds.with.member.name, >// BUFNO=31 >//STDIN DD DUMMY >// > >My awk scripts are kept in a normal PDSE created using the IBM1047 code page >(ISPF terminal type 28, 3278L1). Thanks, gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
