Presentation is loading. Please wait.

Presentation is loading. Please wait.

EMEA Natural Programmers User Group Manipulating the Natural Source Area Ralph Zbrog LEN C ONSULTING LLC June 2004.

Similar presentations


Presentation on theme: "EMEA Natural Programmers User Group Manipulating the Natural Source Area Ralph Zbrog LEN C ONSULTING LLC June 2004."— Presentation transcript:

1 EMEA Natural Programmers User Group Manipulating the Natural Source Area Ralph Zbrog LEN C ONSULTING LLC June 2004

2 2 Uses of the Source Work Area SAG user exits Manipulating the Natural Source Area Overview

3 3 Editing Natural objects On-line debugging Debugging NATRJE Uses of the Source Work Area Utility customization As a temp file

4 4 Write trace data within an on-line module Printer (0) for production report INPUT/REINPUT Uses of the Source Work Area On-line Debugging Appends to current contents of SWA Potential NAT0886 ESIZE overflow error

5 5 Sample code Uses of the Source Work Area On-line Debugging > run > + Program NC-SW-01 Lib ZZUTILS All Mode Structured DEFINE DATA LOCAL #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS= DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END Current Source Size: 209 Char. Free: S 13 L 1

6 6 Report Uses of the Source Work Area On-line Debugging Page 1 05/02/04 14:26:43 Start End NEXT e LIB=ZZUTILS

7 7 Result Uses of the Source Work Area On-line Debugging > > + Program NC-SW-01 Lib ZZUTILS All Mode Structured DEFINE DATA LOCAL #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS= DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 Page 1 05/02/04 14:27: AbCdEf AbCdEf AbCdEf AbCdEf Current Source Size: 380 Char. Free: S 20 L 1

8 8 After ENTER Uses of the Source Work Area On-line Debugging > > + Program NC-SW-01 Lib ZZUTILS All >>> Source has been updated <<<..+.Mode Structured DEFINE DATA LOCAL #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS= DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 PAGE 1 05/02/04 14:27: ABCDEF ABCDEF ABCDEF ABCDEF Current Source Size: 376 Char. Free: S 19 L 1

9 9 SET TYPE T; EX NC-SW-01 Uses of the Source Work Area On-line Debugging > > + Text Lib ZZUTILS All Mode Structured */ 0000 Page 1 05/02/04 14:28: AbCdEf AbCdEf AbCdEf AbCdEf Current Source Size: 171 Char. Free: S 7 L 1

10 10 Save results for comparison or later review Allows scan and page-up/page-down Doesn’t interfere with production output or logic Uses of the Source Work Area On-line Debugging

11 11 Uses of the Source Work Area Questions?

12 12 JCL submitted to internal reader via NATRJE Some errors result in no JES listings Invalid JOB card Uses of the Source Work Area Debugging NATRJE Invalid password Invalid account codes

13 13 ZZTDOC Uses of the Source Work Area Debugging NATRJE ZZTDOC LEN Consulting LLC 05/02/ :52 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: _ Library: ________ Member: ________ Type: _ PDS: ____________________________________________ New: Env: _ Library: ________ Member: ________ PDS: ____________________________________________ Set: Library: ________ Member: ________ Listing: Compare: _ Context: __ Delta: _ Summary: _ Ada Cmd: _ ILRC: _ Type: _ Print: ID: ________ Class: _ Hold: _ Copies: _ Sysout: _ File: Disp: _ Name: ______________________________________________________ Job: Suffix: _ Account: ________ Info: ____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area

14 14 ZZTDOC Uses of the Source Work Area Debugging NATRJE > > + Text Lib ZZUTILS Top Mode Structured //RGZTDOC JOB (abcdef,abcd,RGZ),'TDOC: XXCUSTOM', 0020 // MSGLEVEL=(1,1), 0030 // USER=STRGZ,PASSWORD=$JPSWD$, 0040 // MSGCLASS=N,NOTIFY=RGZ 0050 //*MAIN JOBAFF=MPM,CLASS=X 0060 //FORM OUTPUT FORMS=LASER 0070 * 0080 * 0090 //******** NATURAL OLD SOURCE ******** 0100 //NATOLDP0 EXEC NATBT, 0110 // TIME=50,SYSOUT=X, 0120 // PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0' 0130 //CMPRINT DD SYSOUT=X,OUTPUT=*.FORM 0140 //CMWKF01 DD DSN=&&OLDLST0,DISP=(NEW,PASS,DELETE), 0150 // UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5)) 0160 //SYSIN DD * 0170 %* 0180 LOGON ZZUTILS 0190 %U 0200 %D Current Source Size: 1254 Char. Free: S 57 L 1

15 15 ZZTDOC Uses of the Source Work Area Debugging NATRJE > > + Text Lib ZZUTILS Mode Structured %Q 0220 ZZPUNCH ZZUTIL,ZZCUSTOM,ZZCUSTOM,N,N,N,N 0230 %K FIN 0250 /* 0260 //* 0270 //* 0280 //******** NATURAL NEW SOURCE ******** 0290 //NATNEWP0 EXEC NATBT, 0300 // TIME=50,SYSOUT=X, 0310 // PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0' 0320 //CMPRINT DD SYSOUT=X,OUTPUT=*.FORM 0330 //CMWKF01 DD DSN=&&NEWLST0,DISP=(NEW,PASS,DELETE), 0340 // UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5)) 0350 //SYSIN DD * 0360 %* 0370 LOGON ZZUTILS 0380 %U 0390 %D 0400 %Q Current Source Size: 1254 Char. Free: S 57 L 21

16 16 ZZTDOC Uses of the Source Work Area Utility Customization ZZTDOC LEN Consulting LLC 05/02/ :52 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: _ Library: ________ Member: ________ Type: _ PDS: ____________________________________________ New: Env: _ Library: ________ Member: ________ PDS: ____________________________________________ Set: Library: ________ Member: ________ Listing: Compare: _ Context: __ Delta: _ Summary: _ Ada Cmd: _ ILRC: _ Type: _ Print: ID: ________ Class: _ Hold: _ Copies: _ Sysout: _ File: Disp: _ Name: ______________________________________________________ Job: Suffix: _ Account: ________ Info: ____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area

17 17 ZZTDOC Uses of the Source Work Area Utility Customization ZZTDOC LEN Consulting LLC 05/02/ :54 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: P Library: ZZUTIL__ Member: ________ Type: N PDS: RALPH.PROD.JCL______________________________ New: Env: D Library: ZZUTIL__ Member: ________ PDS: RALPH.DEVL.JCL______________________________ Set: Library: ________ Member: ________ Listing: Compare: C Context: 10 Delta: N Summary: N Ada Cmd: Y ILRC: Y Type: L Print: ID: LASER___ Class: X Hold: Y Copies: 1 Sysout: N File: Disp: O Name: RALPH.TDOCLIST________________________________________ Job: Suffix: T Account: __ Info: 1234 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area

18 18 ZZTDPMNT Uses of the Source Work Area Utility Customization ZZTDPMNT LEN Consulting LLC 05/02/ :03 Natural Utilities ZZUtils v2.1 Technical Walkthrough Documentation - Profile Maintenance *** Profile maintenance will overwrite the Natural source work area *** Action: U (A,I,R,U,.) Library: ZZUTIL__ Profile: RALPH___ Module Type: N Default: ZZUTIL RALPH Old: Nat Lib: ZZUTIL__ Environment: P (DIUP) 3GL PDS: RALPH.PROD.JCL______________________________ New: Nat Lib: ZZUTIL__ Environment: D (DIUP) 3GL PDS: RALPH.DEVL.JCL______________________________ List: Compare: C (F|C) Context: 10 Delta: N Summary: N Adacmd: Y ILRC: Y Src/Cmpl: L (C|L|S) Print: ID: LASER___ Copies: 1 Class: 2 Hold: Y Sysout: N File: Disp: O DSN: RALPH.TDOCLIST________________________________________ (N|O|X) Job: Class: X Suffix: T Account: __ Info: 1234____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Actn Help Auth Exit

19 19 ZZTDPROF Uses of the Source Work Area Utility Customization > > + Text ZZTDPROF Lib ZZUTILS Top Mode Structured ZZTDOC Profile 0020 Profile ZZTDPROF 0030 Library ZZUTIL 0040 * 0050 Module Type N 0060 Old Environment P 0070 New Environment D 0080 Old Library PRODLIB 0090 New Library DEVLLIB 0100 Old 3GL PDS PROD.APP.JCL 0110 New 3GL PDS DEVL.APP.JCL 0120 List Type L 0130 Compile Type DAC 0140 Compare Type F 0150 Context Delta N 0170 Summary N 0180 Adacmd Y 0190 ILRC Y 0200 Xref N Current Source Size: 1254 Char. Free: S 57 L 1

20 20 ZZTDPROF Uses of the Source Work Area Utility Customization > > + Text ZZTDPROF Lib ZZUTILS Mode Structured Copycode N 0220 Printer LASER 0230 Copies Output Class X 0250 Hold Y 0260 Sysout N 0270 File Disposition N 0280 DSN 0290 Job Class X 0300 Job Suffix T 0310 Account Info * 0340 Old Copybook Old Copybook Old Copybook Old Copybook Old Copybook Old Copybook Old Copybook Current Source Size: 1254 Char. Free: S 57 L 21

21 21 ZZTDPROF Uses of the Source Work Area Utility Customization > > + Text ZZTDPROF Lib ZZUTILS Bot Mode Structured Old Copybook Old Copybook Old Copybook New Copybook New Copybook New Copybook New Copybook New Copybook New Copybook New Copybook New Copybook New Copybook New Copybook * 0550 Updated by RALPH 0560 Updated on 10/25/ Updated at 17:31: Current Source Size: 1266 Char. Free: S 60 L 41

22 22 Retrieve text member into arrayUSR1057N Parse array entries into keyword/value Present values to user Uses of the Source Work Area Utility Customization Validate new values Write keywords/values to SWA Store SWA as text memberUSR2019N “Replace” option

23 23 ZZTDOC Uses of the Source Work Area Utility Customization ZZTDOC LEN Consulting LLC 05/02/ :54 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: P Library: ZZUTIL__ Member: ________ Type: N PDS: RALPH.PROD.JCL______________________________ New: Env: D Library: ZZUTIL__ Member: ________ PDS: RALPH.DEVL.JCL______________________________ Set: Library: ________ Member: ________ Listing: Compare: C Context: 10 Delta: N Summary: N Ada Cmd: Y ILRC: Y Type: L Print: ID: LASER___ Class: X Hold: Y Copies: 1 Sysout: N File: Disp: O Name: RALPH.TDOCLIST________________________________________ Job: Suffix: T Account: __ Info: 1234 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area

24 24 ZZL1057 Uses of the Source Work Area Simple Code Example: Modify a Source Module S 1 ZZ1057 S 2 OBJECT-KEY 3 LIBRARYA8 3 OBJECT-NAMEA32 3 OBJECT-TYPEA2 2 INPUTS 3 OPT-ACCESSA1 3 OPT-UNUSED-1L 3 OPT-UNUSED-2A1 3 OPT-LINE-NUMA1 3 OPT-UNUSED-3L 3 OPT-REDEF-DIRL 3 OPT-UNUSED-4A1 3 OPT-AMOUNTI2 3 OPT-LINESIZEI2 2 INPUT-OUTPUTS 3 INT-HANDLEI4 3 NEXT-SEQI4 3 NEXT-NUMI2

25 25 ZZL1057 Uses of the Source Work Area Simple Code Example 2 OUTPUTS 3 RETURNEDI2 3 SRC-NUMI2(1:60) 3 SRC-TEXTA1(1:60,1:72) R 3 SRC-TEXT 4 DIR-OBJNAMEA32 4 DIR-LIBRARYA8 4 DIR-OBJTYPEA2 4 DIR-OBJKINDA1 4 DIR-DBIDA5 4 DIR-FNRA5 4 DIR-DATNA8 4 DIR-TIMNA7 4 DIR-USERIDA8 4 DIR-PROGMODEA1 4 DIR-SRCSIZEA10 4 DIR-GPSIZEA10 4 DIR-UNIQUE-IDA32 4 DIR-DDM-DBIDA5 4 DIR-DDM-FNRA5

26 26 ZZL1057 Uses of the Source Work Area Simple Code Example 4 DIR-NATVERSA4 4 DIR-NATSMA2 4 DIR-INIT-USERA8 4 DIR-TIDA8 4 DIR-TRANS-NAMEA8 4 DIR-OPSYSA8 4 DIR-TPSYSA8 4 DIR-USED-GDAA8 R 3 SRC-TEXT 4 SRC-GROUP(1:60) 5 SRC-LINEA72 3 SRC-SEQI4(1:60) 3 SRC-LONGA1(1:60)

27 27 ZZL1057 Uses of the Source Work Area Simple Code Example 2 USR1057N 3 EXTENDED-DATAA1(1:28) R 3 EXTENDED-DATA 4 VERSIONI1 4 V1-NSC-CKECKA1 4 V2-DBIDN5 4 V2-FNRN4 4 V2-PSWA8 4 V2-CIPN8 4 V2-SYSFILEA1

28 28 ZZL2019 Uses of the Source Work Area Simple Code Example 1 ZZ SYSTEM-FILEA1 2 DBID N5 2 FNR N5 2 PASSWORDA8 2 CIPHERCODEN8 2 OBJECT-CLASSI1 2 LIBRARY A8 2 OBJECT-NAMEA32 2 OBJECT-TYPEA2 2 OBJECT-KINDA1 2 OPT-ACCESSA1 2 OPT-ET L 2 OPT-REPLACEA1 2 OPT-SESNUMB2 2 OPT-BUFFNAMEA8 2 OPT-NSC-CHECKA1 2 EDIT-MODEA1 2 EXTENDED-DATAA1(1:2) INIT

29 29 NC-SW-02 Uses of the Source Work Area Simple Code Example 0010 DEFINE DATA 0020 LOCAL USING ZZL1057 /* Retrieve source 0030 LOCAL USING ZZL2019 /* Save source 0040 LOCAL USING USR-MSG /* Data for message exchange 0050 LOCAL USING USR-FLD /* Description of the field in error 0060 LOCAL #MAINFRAME (A16) CONST #USR1057 (A8) CONST #REAL #MACHINE-CLASS (A16) INIT 0110 * #PLIB (A8) INIT #PMOD (A8) INIT 0140 * #SET-UPPER (L) #I (I4) 0170 END-DEFINE 0180 * 0190 FORMAT PS=23 LS= *

30 30 NC-SW-02 Uses of the Source Work Area Simple Code Example 0210 DEFINE PRINTER (1) OUTPUT 'SOURCE' 0220 * 0230 * 0240 RESET ZZ1057.USR1057N 0250 ASSIGN ZZ1057.VERSION = ASSIGN ZZ1057.V2-SYSFILE = 'U' /* FUSER 0270 ASSIGN ZZ1057.OBJECT-TYPE = 'T' /* Text 0280 ASSIGN ZZ1057.OPT-LINE-NUM = 'Y' 0290 ASSIGN ZZ1057.OPT-REDEF-DIR = FALSE 0300 ASSIGN ZZ1057.OPT-AMOUNT = 60 /* Source block 0310 ASSIGN ZZ1057.OPT-LINESIZE = * 0330 ASSIGN ZZ2019.SYSTEM-FILE = 'U' /* FUSER 0340 ASSIGN ZZ2019.OBJECT-TYPE = 'T' /* Text 0350 ASSIGN ZZ2019.OPT-ACCESS = 'W' /* Write 0360 ASSIGN ZZ2019.OPT-REPLACE = 'Y' 0370 ASSIGN ZZ2019.OPT-NSC-CHECK = 'N' 0380 *

31 31 NC-SW-02 Uses of the Source Work Area Simple Code Example 0390 REPEAT 0400 INPUT (AD=MDLT'_' IP=F SG=F ZP=F) 0410 *PROGRAM (CD=NE) T 'LEN Consulting LLC' (CD=TU) T *DAT4I (AD=O) 0440 *TIME (AL=5) 0450 / 10T 'Read/Edit/Update FUSER' 0460 /// 5X 'Library:' #PLIB 0470 // 5X ' Module:' #PMOD 0480 /* 0490 IF #PLIB = '.' 0500 OR #PMOD = '.' 0510 THEN 0520 STOP 0530 END-IF 0540 /* 0550 ASSIGN ZZ1057.LIBRARY = #PLIB 0560 ASSIGN ZZ1057.OBJECT-NAME = #PMOD 0570 ASSIGN ZZ1057.OPT-ACCESS = 'O' /* Open FUSER module 0580 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD

32 32 NC-SW-02 Uses of the Source Work Area Simple Code Example 0590 IF NAD-MSG.MSG-NR = THEN 0610 REINPUT 'Module not found' MARK *#PMOD 0620 END-IF 0630 ASSIGN ZZ1057.OPT-ACCESS = 'R' /* Read into array 0640 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD 0650 /* Update 0660 SET CONTROL 'Z' /* Clear Work area 0670 FOR #I = 1 ZZ1057.RETURNED 0680 IF ZZ1057.SRC-LINE (#I) = '*/' 0690 THEN 0700 ESCAPE TOP 0710 END-IF 0720 IF ZZ1057.SRC-LINE (#I) = 'UPPER CASE' 0730 THEN 0740 WRITE (1) NOTITLE 0750 'lower case' 0760 RESET #SET-UPPER 0770 ESCAPE TOP 0780 END-IF

33 33 NC-SW-02 Uses of the Source Work Area Simple Code Example 0790 IF ZZ1057.SRC-LINE (#I) = 'lower case' 0800 THEN 0810 WRITE (1) NOTITLE 0820 'UPPER CASE' 0830 ASSIGN #SET-UPPER = TRUE 0840 ESCAPE TOP 0850 END-IF 0860 IF #SET-UPPER 0870 THEN 0880 EXAMINE SRC-LINE (#I) TRANSLATE INTO UPPER CASE 0890 ELSE 0900 EXAMINE SRC-LINE (#I) TRANSLATE INTO LOWER CASE 0910 END-IF 0920 WRITE (1) NOTITLE 0930 ZZ1057.SRC-LINE (#I) 0940 WRITE 0950 ZZ1057.SRC-LINE (#I) 0960 END-FOR

34 34 NC-SW-02 Uses of the Source Work Area Simple Code Example 0970 IF #REAL.#MACHINE-CLASS <> #MAINFRAME 0980 THEN 0990 ASSIGN ZZ1057.OPT-ACCESS = 'C' /* Close 1000 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD 1010 END-IF 1020 /* 1030 ASSIGN ZZ2019.LIBRARY = #PLIB 1040 ASSIGN ZZ2019.OBJECT-NAME = #PMOD 1050 CALLNAT 'USR2019N' ZZ2019 NAD-MSG NAD-FLD /* Save source 1060 END-REPEAT 1070 END

35 35 NC-SW-03 before Uses of the Source Work Area Simple Code Example 0010 UPPER CASE 0020 * 0030 RAINING CATS AND DOGS 0040 GIVE HIM THE BOOT 0050 FACE THE MUSIC 0060 DRESSED TO THE NINES 0070 PUT TWO AND TWO TOGETHER 0080 HE LAID AN EGG 0090 WALK ON EGG SHELLS 0100 I SMELL A RAT 0110 CAT GOT YOUR TONGUE? 0120 LET THE CAT OUT OF THE BAG 0130 SPILL THE BEANS 0140 YOU SAY POTATO, I SAY POTATO

36 36 NC-SW-03 after Uses of the Source Work Area Simple Code Example 0010 */ 0020 lower case 0030 * 0040 raining cats and dogs 0050 give him the boot 0060 face the music 0070 dressed to the nines 0080 put two and two together 0090 he laid an egg 0100 walk on egg shells 0110 i smell a rat 0120 cat got your tongue? 0130 let the cat out of the bag 0140 spill the beans 0150 you say potato, i say potato

37 37 Manipulating the Natural Source Area Questions?

38 38 Build your own editor based on SAG editor API Load prototype from text member SAG-L archive: Uses of the Source Work Area Editing Natural Objects Execute editing commands Stow and execute Dynamic code generation Custom edit commands

39 39 Load SWA via WRITE or user exit Read line by lineUSR2014N Uses of the Source Work Area As a Temp File

40 40 NC-SW-04 – USR2014N control block Uses of the Source Work Area As a Temp File 0010 * Use SWA as a TEMP file 0020 * 0030 * Data definitions as in USR2014P: 0040 * 0050 DEFINE DATA LOCAL C-SCRMAX (I01) CONST /* Maximum number of lines C-SCRLEN (I01) CONST /* Length of data area C-PRFLEN (I01) CONST /* Length of prefix area SHOW-PREFIX-AREA (L) CONST 0100 LOCAL CONTROL-BLOCK ED-SESNUM (B02) /* Number of session (0-50) ED-LOGFLAG (A01) /* Logical name in use ED-LOGNAME (A08) /* Logical name of the session ED-REQUEST (A04) /* Editor request ED-LIBRARY (A08) /* Unused ED-MEMBER (A08) /* Unused ED-RECLEN (B02) /* Maximum length of each line ED-PRFLEN (B02) /* Length of a prefix line on screen ED-SCRLEN (B02) /* Length of a single line on screen

41 41 NC-SW-04 Uses of the Source Work Area As a Temp File ED-SCRNUM (B02) /* Number of lines on screen ED-SCRMAX (B02) /* Maximum number of lines on screen ED-RENUM (B01) /* Unused 0240 /* ED-MCMND (A50) /* Main command: command line ED-SCMND (A08) /* Secondary command: PF-key ED-CAREA (B02) /* Cursor area ED-CROW (B02) /* Cursor row ED-CCLM (B02) /* Cursor column 0300 /* ED-RECTOP (B02) /* Unused ED-NEW-RECTOP (B04) /* Line number of new first line on screen ED-RECNUM (B02) /* Unused ED-NEW-RECNUM (B04) /* Number of lines in the source area ED-FILECHG (B01) /* Indicator if source area has been mod ED-SRAUSED (B04) /* Used source area in bytes ED-SRAFREE (B04) /* Unused source area in bytes ED-FLINE (A80) /* Message test. Explanation for 0390 /* ED-MSGNUM or ED-ERRNUM ED-MSGNUM (B02) /* Message number

42 42 NC-SW-04 Uses of the Source Work Area As a Temp File ED-ERRNUM (B02) /* Error number ED-DUMMY (A32) /* Used for enhancements REDEFINE ED-DUMMY ED-DSTYPE (A01) /* Type of session ED-RECMAX (B02) /* Target session for CSES request 0460 /* CB-ALIN /* Attributes of prefix area CB-ALIN-V (N01/1:C-SCRMAX) L-PREFIXES /* Prefix area L-PREFIX-MAX (1:C-SCRMAX) L-PREFIX (A06) /* Length must be equal C-PRFLEN REDEFINE L-PREFIX L-PREFIX-A1 (A01/1:C-PRFLEN) 0540 /* CB-ADAT /* Attributes of data lines CB-ADAT-V (N01/1:C-SCRMAX) L-DATA-LINES /* Data lines L-DATA-MAX (1:C-SCRMAX) L-DATA (A72) /* Length must be equal C-SCRLEN REDEFINE L-DATA

43 43 NC-SW-04 Uses of the Source Work Area As a Temp File L-DATA-A1 (A01/1:C-SCRLEN) 0620 * 0630 LOCAL C-SESNUM (B2) ERROR-NUMBER (N4) 0660 * #I (I4) #ED-SCRNUM (I4) #RECNUM (I4) #LINES (P7) #WORK (A72) 1 REDEFINE #WORK /* WORK record #W (A2) FILLER 1X #ALPHA (A69) #WORDS (P7) 0760 END-DEFINE

44 44 NC-SW-04 – populate SWA Uses of the Source Work Area As a Temp File 0770 * Initialize the SWA 0780 SET CONTROL 'Z' /* Clear SWA 0790 FORMAT (3) LS= DEFINE PRINTER (3) OUTPUT 'SOURCE' 0810 WRITE (3) NOTITLE '09 The quick brown fox jumps over the lazy dog.' 0820 WRITE (3) NOTITLE '07 A penny saved is a penny earned.' 0830 WRITE (3) NOTITLE '06 That"s all water under the bridge.' 0840 * 0850 * 0860 ASSIGN ED-SESNUM = 0 /* Open a free session 0870 ASSIGN ED-LOGFLAG = 'N' 0880 ASSIGN ED-DSTYPE = 'N' /* NATURAL SWA 0890 ASSIGN ED-RECLEN = ASSIGN ED-SCRMAX = ASSIGN ED-SCRNUM = ASSIGN ED-SCRLEN = C-SCRLEN 0930 ASSIGN ED-PRFLEN = C-PRFLEN 0940 *

45 45 NC-SW-04 – open Uses of the Source Work Area As a Temp File 0950 ASSIGN ED-REQUEST = 'OPEN' /* Open session 0960 CALLNAT 'USR2014N' 0970 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 0980 IF ED-ERRNUM <> THEN 1000 ERROR-NUMBER := ED-ERRNUM /* Error number in decimal form 1010 WRITE 'Error occurred during OPEN processing:' (I) 1020 / '=' ERROR-NUMBER 1030 / '=' ED-FLINE (AL=65) 1040 STOP 1050 END-IF 1060 ASSIGN C-SESNUM = ED-SESNUM /* Session number returned from OPEN 1070 ASSIGN #RECNUM = ED-NEW-RECNUM /* Number of lines in SWA 1080 * 1090 *

46 46 NC-SW-04 – “READ WORK” Uses of the Source Work Area As a Temp File 1100 ASSIGN ED-REQUEST = 'GETL' /* Get lines 1110 FOR #I = 1 #RECNUM /* READ WORK ASSIGN ED-NEW-RECTOP = #I 1130 CALLNAT 'USR2014N' 1140 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 1150 ASSIGN #WORK = L-DATA (1) 1160 DISPLAY 1170 'SWA/Line' #I (EM=ZZ9) 1180 '/Words' #W 1190 '/Line' #ALPHA (AL=50) 1200 IF #W IS (N2) 1210 THEN 1220 ADD 1 TO #LINES 1230 ADD VAL (#W) TO #WORDS 1240 END-IF 1250 END-FOR 1260 * 1270 *

47 47 NC-SW-04 – “end-of-data” & “CLOSE WORK” Uses of the Source Work Area As a Temp File 1280 WRITE 1290 /// #RECNUM (SG=F NL=3) 'source lines' 1300 // #LINES (SG=F NL=3) 'lines processed' 1310 / #WORDS (SG=F NL=3) 'words' 1320 * 1330 ASSIGN ED-REQUEST = 'CLSS' /* Close session 1340 CALLNAT 'USR2014N' 1350 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 1360 SET CONTROL 'Z' /* Clear SWA 1370 END

48 48 NC-SW-04 – report Uses of the Source Work Area As a Temp File Page 1 05/02/04 14:28:50 SWA Line Words Line */ 2 09 The quick brown fox jumps over the lazy dog A penny saved is a penny earned That’s all water under the bridge. 4 source lines 3 lines processed 22 words

49 49 Uses of the Source Work Area Questions?

50 50 Retrieving Natural source Editing the SWA Miscellaneous Storing Natural source SAG User Exits

51 51 USR2019Nsave source into FUSER USR0210Nsave/cat/stow source into FUSER SAG User Exits Storing Natural Source

52 52 USR2019Nread from FUSER into SWA USR1057Nread from FUSER into an array SAG User Exits Retrieving Natural Source

53 53 USR1036Nmaintain user profile USR1035Nedit SWA contents USR2014NSAG editor SAG User Exits Editing the SWA

54 54 USR0330NFUSER directory USR1054Nfind libraries containing module name USR1055Nfind modules in a library USR0008Ndetermine/set content type/name SAG User Exits Miscellaneous USR2014Nread source as a temp file

55 55 Manipulating the Natural Source Area Questions?

56 EMEA Natural Programmers User Group Manipulating the Natural Source Area Ralph Zbrog LEN C ONSULTING LLC June 2004


Download ppt "EMEA Natural Programmers User Group Manipulating the Natural Source Area Ralph Zbrog LEN C ONSULTING LLC June 2004."

Similar presentations


Ads by Google