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 RGZbrog@ZZUtils.com 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....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0140 0150 0160 0170 0180 0190 0200....+..Current Source Size: 209 Char. Free: 223600...+... 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....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 Page 1 05/02/04 14:27:14 0000 0000 AbCdEf 1 0000 AbCdEf 2 0000 AbCdEf 3 0000 AbCdEf 4....+..Current Source Size: 380 Char. Free: 223429...+... S 20 L 1

8 8 After ENTER Uses of the Source Work Area On-line Debugging > > + Program NC-SW-01 Lib ZZUTILS All....+....1....+....>>> Source has been updated <<<..+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 PAGE 1 05/02/04 14:27:14 0000 ABCDEF 1 0000 ABCDEF 2 0000 ABCDEF 3 0000 ABCDEF 4 0010....+..Current Source Size: 376 Char. Free: 223433...+... 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....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0000 */ 0000 Page 1 05/02/04 14:28:50 0000 0000 AbCdEf 1 0000 AbCdEf 2 0000 AbCdEf 3 0000 AbCdEf 4 0010 0020 0030 0040 0050 0060 0070 0080 0090 0100 0110 0120 0130....+..Current Source Size: 171 Char. Free: 223638...+... 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/2004 17: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....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 //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: 222267..+... S 57 L 1

15 15 ZZTDOC Uses of the Source Work Area Debugging NATRJE > > + Text Lib ZZUTILS....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0210 %Q 0220 ZZPUNCH ZZUTIL,ZZCUSTOM,ZZCUSTOM,N,N,N,N 0230 %K03 0240 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: 222267..+... S 57 L 21

16 16 ZZTDOC Uses of the Source Work Area Utility Customization ZZTDOC LEN Consulting LLC 05/02/2004 17: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/2004 17: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: 123456__ 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/2004 18: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: 123456__ 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....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 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 10 0160 Delta N 0170 Summary N 0180 Adacmd Y 0190 ILRC Y 0200 Xref N....+..Current Source Size: 1254 Char. Free: 222267..+... S 57 L 1

20 20 ZZTDPROF Uses of the Source Work Area Utility Customization > > + Text ZZTDPROF Lib ZZUTILS....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0210 Copycode N 0220 Printer LASER 0230 Copies 1 0240 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 123456 0320 Info 1234 0330 * 0340 Old Copybook 01 0350 Old Copybook 02 0360 Old Copybook 03 0370 Old Copybook 04 0380 Old Copybook 05 0390 Old Copybook 06 0400 Old Copybook 07....+..Current Source Size: 1254 Char. Free: 222267..+... S 57 L 21

21 21 ZZTDPROF Uses of the Source Work Area Utility Customization > > + Text ZZTDPROF Lib ZZUTILS Bot....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0410 Old Copybook 08 0420 Old Copybook 09 0430 Old Copybook 10 0440 New Copybook 01 0450 New Copybook 02 0460 New Copybook 03 0470 New Copybook 04 0480 New Copybook 05 0490 New Copybook 06 0500 New Copybook 07 0510 New Copybook 08 0520 New Copybook 09 0530 New Copybook 10 0540 * 0550 Updated by RALPH 0560 Updated on 10/25/2003 0570 Updated at 17:31:58 0580 0590 0600....+..Current Source Size: 1266 Char. Free: 222255..+... 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/2004 17: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: 123456__ 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 ZZ2019 2 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 0070 1 #MAINFRAME (A16) CONST 0080 1 #USR1057 (A8) CONST 0090 1 #REAL 0100 2 #MACHINE-CLASS (A16) INIT 0110 * 0120 1 #PLIB (A8) INIT 0130 1 #PMOD (A8) INIT 0140 * 0150 1 #SET-UPPER (L) 0160 1 #I (I4) 0170 END-DEFINE 0180 * 0190 FORMAT PS=23 LS=80 0200 *

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 = 2 0260 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 = 72 0320 * 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) 0420 10T 'LEN Consulting LLC' (CD=TU) 0430 64T *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 = 1006 0600 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: http:\\listserv.uark.edu/archives/sag-l.html 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 0060 1 C-SCRMAX (I01) CONST /* Maximum number of lines 0070 1 C-SCRLEN (I01) CONST /* Length of data area 0080 1 C-PRFLEN (I01) CONST /* Length of prefix area 0090 1 SHOW-PREFIX-AREA (L) CONST 0100 LOCAL 0110 1 CONTROL-BLOCK 0120 2 ED-SESNUM (B02) /* Number of session (0-50) 0130 2 ED-LOGFLAG (A01) /* Logical name in use 0140 2 ED-LOGNAME (A08) /* Logical name of the session 0150 2 ED-REQUEST (A04) /* Editor request 0160 2 ED-LIBRARY (A08) /* Unused 0170 2 ED-MEMBER (A08) /* Unused 0180 2 ED-RECLEN (B02) /* Maximum length of each line 0190 2 ED-PRFLEN (B02) /* Length of a prefix line on screen 0200 2 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 0210 2 ED-SCRNUM (B02) /* Number of lines on screen 0220 2 ED-SCRMAX (B02) /* Maximum number of lines on screen 0230 2 ED-RENUM (B01) /* Unused 0240 /* 0250 2 ED-MCMND (A50) /* Main command: command line 0260 2 ED-SCMND (A08) /* Secondary command: PF-key 0270 2 ED-CAREA (B02) /* Cursor area 0280 2 ED-CROW (B02) /* Cursor row 0290 2 ED-CCLM (B02) /* Cursor column 0300 /* 0310 2 ED-RECTOP (B02) /* Unused 0320 2 ED-NEW-RECTOP (B04) /* Line number of new first line on screen 0330 2 ED-RECNUM (B02) /* Unused 0340 2 ED-NEW-RECNUM (B04) /* Number of lines in the source area 0350 2 ED-FILECHG (B01) /* Indicator if source area has been mod. 0360 2 ED-SRAUSED (B04) /* Used source area in bytes 0370 2 ED-SRAFREE (B04) /* Unused source area in bytes 0380 2 ED-FLINE (A80) /* Message test. Explanation for 0390 /* ED-MSGNUM or ED-ERRNUM 0400 2 ED-MSGNUM (B02) /* Message number

42 42 NC-SW-04 Uses of the Source Work Area As a Temp File 0410 2 ED-ERRNUM (B02) /* Error number 0420 2 ED-DUMMY (A32) /* Used for enhancements 0430 2 REDEFINE ED-DUMMY 0440 3 ED-DSTYPE (A01) /* Type of session 0450 3 ED-RECMAX (B02) /* Target session for CSES request 0460 /* 0470 1 CB-ALIN /* Attributes of prefix area 0480 2 CB-ALIN-V (N01/1:C-SCRMAX) 0490 1 L-PREFIXES /* Prefix area 0500 2 L-PREFIX-MAX (1:C-SCRMAX) 0510 3 L-PREFIX (A06) /* Length must be equal C-PRFLEN 0520 3 REDEFINE L-PREFIX 0530 4 L-PREFIX-A1 (A01/1:C-PRFLEN) 0540 /* 0550 1 CB-ADAT /* Attributes of data lines 0560 2 CB-ADAT-V (N01/1:C-SCRMAX) 0570 1 L-DATA-LINES /* Data lines 0580 2 L-DATA-MAX (1:C-SCRMAX) 0590 3 L-DATA (A72) /* Length must be equal C-SCRLEN 0600 3 REDEFINE L-DATA

43 43 NC-SW-04 Uses of the Source Work Area As a Temp File 0610 4 L-DATA-A1 (A01/1:C-SCRLEN) 0620 * 0630 LOCAL 0640 1 C-SESNUM (B2) 0650 1 ERROR-NUMBER (N4) 0660 * --------------------------------------------------------------------- 0670 1 #I (I4) 0680 1 #ED-SCRNUM (I4) 0690 1 #RECNUM (I4) 0700 1 #LINES (P7) 0710 1 #WORK (A72) 1 REDEFINE #WORK /* WORK record 0720 2 #W (A2) 0730 2 FILLER 1X 0740 2 #ALPHA (A69) 0750 1 #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=72 0800 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 = 100 0900 ASSIGN ED-SCRMAX = 10 0910 ASSIGN ED-SCRNUM = 10 0920 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 <> 0 0990 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... 1120 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 ---- ----- -------------------------------------------------- 1 */ 2 09 The quick brown fox jumps over the lazy dog. 3 07 A penny saved is a penny earned. 4 06 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 RGZbrog@ZZUtils.com 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