Natural Conference 2002

Download Report

Transcript Natural Conference 2002

EMEA Natural Programmers User Group
Manipulating the Natural
Source Area
Ralph Zbrog
LEN CONSULTING LLC
[email protected]
June 2004
Manipulating the Natural Source Area
Overview
• Uses of the Source Work Area
• SAG user exits
2
Uses of the Source Work Area
• Editing Natural objects
• On-line debugging
• Debugging NATRJE
• Utility customization
• As a temp file
3
Uses of the Source Work Area
On-line Debugging
• Write trace data within an on-line module
• Printer (0) for production report
• INPUT/REINPUT
• Appends to current contents of SWA
• Potential NAT0886 ESIZE overflow error
4
Uses of the Source Work Area
On-line Debugging
• Sample code
> run
All
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
> + Program
NC-SW-01 Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
DEFINE DATA LOCAL
1 #I (I4)
END-DEFINE
*
FORMAT (3) LS=70
DEFINE PRINTER (3) OUTPUT 'SOURCE'
*
WRITE 'Start'
FOR #I = 1 4
WRITE (3) 'AbCdEf' #I
END-FOR
WRITE 'End'
END
....+..Current Source Size: 209 Char. Free: 223600 ...+... S 13
5
L 1
Uses of the Source Work Area
On-line Debugging
• Report
Page
1
05/02/04
14:26:43
Start
End
NEXT e
LIB=ZZUTILS
6
Uses of the Source Work Area
On-line Debugging
• Result
>
All
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0000
0000
0000
0000
0000
0000
0000
> + Program
NC-SW-01 Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
DEFINE DATA LOCAL
1 #I (I4)
END-DEFINE
*
FORMAT (3) LS=70
DEFINE PRINTER (3) OUTPUT 'SOURCE'
*
WRITE 'Start'
FOR #I = 1 4
WRITE (3) 'AbCdEf' #I
END-FOR
WRITE 'End'
END
*/
Page
1
05/02/04 14:27:14
AbCdEf
1
AbCdEf
2
AbCdEf
3
AbCdEf
4
....+..Current Source Size: 380 Char. Free: 223429 ...+... S 20
7
L 1
Uses of the Source Work Area
On-line Debugging
• After ENTER
>
All
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0000
0000
0000
0000
0000
0000
0010
> + Program
....+....1....+....>>> Source has been updated
DEFINE DATA LOCAL
1 #I (I4)
END-DEFINE
*
FORMAT (3) LS=70
DEFINE PRINTER (3) OUTPUT 'SOURCE'
*
WRITE 'Start'
FOR #I = 1 4
WRITE (3) 'AbCdEf' #I
END-FOR
WRITE 'End'
END
*/
PAGE
1
ABCDEF
1
ABCDEF
2
ABCDEF
3
ABCDEF
4
NC-SW-01 Lib ZZUTILS
<<<..+.Mode Structured.
05/02/04
14:27:14
....+..Current Source Size: 376 Char. Free: 223433 ...+... S 19
8
L 1
Uses of the Source Work Area
On-line Debugging
• SET TYPE T; EX NC-SW-01
>
All
0000
0000
0000
0000
0000
0000
0000
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
> + Text
Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
*/
Page
1
05/02/04 14:28:50
AbCdEf
AbCdEf
AbCdEf
AbCdEf
1
2
3
4
....+..Current Source Size: 171 Char. Free: 223638 ...+... S 7
9
L 1
Uses of the Source Work Area
On-line Debugging
• Save results for comparison or later review
• Allows scan and page-up/page-down
• Doesn’t interfere with production output or logic
10
Uses of the Source Work Area
Questions?
11
Uses of the Source Work Area
Debugging NATRJE
• JCL submitted to internal reader via NATRJE
• Some errors result in no JES listings
• Invalid JOB card
• Invalid password
• Invalid account codes
12
Uses of the Source Work Area
Debugging NATRJE
• ZZTDOC
ZZTDOC
LEN Consulting LLC
Natural Utilities
Generate Code Walkthrough Document
Old: Env:
PDS:
New: Env:
PDS:
Set:
_
Library: ________
Member: ________
____________________________________________
_
Library: ________
Member: ________
____________________________________________
Library: ________
Listing: Compare: _
Delta: _
Type: _
Print:
05/02/2004 17:52
ZZUtils v2.1
Profile: ZZUTIL/RALPH
Context: __
Summary: _
ID: ________
Hold: _
Type: _
Member: ________
Ada Cmd: _
Class: _
Copies: _
ILRC: _
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
13
Uses of the Source Work Area
Debugging NATRJE
• ZZTDOC
>
Top
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
> + Text
Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
//RGZTDOC JOB (abcdef,abcd,RGZ),'TDOC: XXCUSTOM',
//
MSGLEVEL=(1,1),
//
USER=STRGZ,PASSWORD=$JPSWD$,
//
MSGCLASS=N,NOTIFY=RGZ
//*MAIN
JOBAFF=MPM,CLASS=X
//FORM
OUTPUT FORMS=LASER
*
*
//******** NATURAL OLD SOURCE ********
//NATOLDP0 EXEC NATBT,
//
TIME=50,SYSOUT=X,
//
PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0'
//CMPRINT
DD SYSOUT=X,OUTPUT=*.FORM
//CMWKF01
DD DSN=&&OLDLST0,DISP=(NEW,PASS,DELETE),
//
UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5))
//SYSIN
DD *
%*
LOGON ZZUTILS
%U
%D
....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57
L 1
14
Uses of the Source Work Area
Debugging NATRJE
• ZZTDOC
>
0210
0220
0230
0240
0250
0260
0270
0280
0290
0300
0310
0320
0330
0340
0350
0360
0370
0380
0390
0400
> + Text
Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
%Q
ZZPUNCH ZZUTIL,ZZCUSTOM,ZZCUSTOM,N,N,N,N
%K03
FIN
/*
//*
//*
//******** NATURAL NEW SOURCE ********
//NATNEWP0 EXEC NATBT,
//
TIME=50,SYSOUT=X,
//
PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0'
//CMPRINT
DD SYSOUT=X,OUTPUT=*.FORM
//CMWKF01
DD DSN=&&NEWLST0,DISP=(NEW,PASS,DELETE),
//
UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5))
//SYSIN
DD *
%*
LOGON ZZUTILS
%U
%D
%Q
....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57
L 21
15
Uses of the Source Work Area
Utility Customization
• ZZTDOC
ZZTDOC
LEN Consulting LLC
Natural Utilities
Generate Code Walkthrough Document
Old: Env:
PDS:
New: Env:
PDS:
Set:
_
Library: ________
Member: ________
____________________________________________
_
Library: ________
Member: ________
____________________________________________
Library: ________
Listing: Compare: _
Delta: _
Type: _
Print:
05/02/2004 17:52
ZZUtils v2.1
Profile: ZZUTIL/RALPH
Context: __
Summary: _
ID: ________
Hold: _
Type: _
Member: ________
Ada Cmd: _
Class: _
Copies: _
ILRC: _
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
16
Uses of the Source Work Area
Utility Customization
• ZZTDOC
ZZTDOC
LEN Consulting LLC
Natural Utilities
Generate Code Walkthrough Document
Old: Env:
PDS:
New: Env:
PDS:
Set:
P
Library: ZZUTIL__
Member: ________
RALPH.PROD.JCL______________________________
D
Library: ZZUTIL__
Member: ________
RALPH.DEVL.JCL______________________________
Library: ________
Listing: Compare: C
Delta: N
Type: L
Print:
05/02/2004 17:54
ZZUtils v2.1
Profile: ZZUTIL/RALPH
Context: 10
Summary: N
ID: LASER___
Hold: Y
Type: N
Member: ________
Ada Cmd: Y
Class: X
Copies: 1
ILRC: Y
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
17
Uses of the Source Work Area
Utility Customization
• ZZTDPMNT
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:
New:
List:
Nat
3GL
Nat
3GL
Lib:
PDS:
Lib:
PDS:
Compare:
Delta:
Src/Cmpl:
Print:
ID:
Class:
ZZUTIL__
Environment: P (DIUP)
RALPH.PROD.JCL______________________________
ZZUTIL__
Environment: D (DIUP)
RALPH.DEVL.JCL______________________________
C (F|C)
Context: 10
N
Summary: N
L (C|L|S)
LASER___
2
Hold: Y
File:
Adacmd: Y
ILRC: Y
Copies: 1
Sysout: N
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
18
Uses of the Source Work Area
Utility Customization
• ZZTDPROF
>
Top
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
> + Text
ZZTDPROF Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
ZZTDOC Profile
Profile
ZZTDPROF
Library
ZZUTIL
*
Module Type
N
Old Environment
P
New Environment
D
Old Library
PRODLIB
New Library
DEVLLIB
Old 3GL PDS
PROD.APP.JCL
New 3GL PDS
DEVL.APP.JCL
List Type
L
Compile Type
DAC
Compare Type
F
Context
10
Delta
N
Summary
N
Adacmd
Y
ILRC
Y
Xref
N
....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57
L 1
19
Uses of the Source Work Area
Utility Customization
• ZZTDPROF
>
0210
0220
0230
0240
0250
0260
0270
0280
0290
0300
0310
0320
0330
0340
0350
0360
0370
0380
0390
0400
> + Text
ZZTDPROF Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
Copycode
N
Printer
LASER
Copies
1
Output Class
X
Hold
Y
Sysout
N
File Disposition N
DSN
Job Class
X
Job Suffix
T
Account
123456
Info
1234
*
Old Copybook 01
Old Copybook 02
Old Copybook 03
Old Copybook 04
Old Copybook 05
Old Copybook 06
Old Copybook 07
....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57
L 21
20
Uses of the Source Work Area
Utility Customization
• ZZTDPROF
>
Bot
0410
0420
0430
0440
0450
0460
0470
0480
0490
0500
0510
0520
0530
0540
0550
0560
0570
0580
0590
0600
> + Text
ZZTDPROF Lib ZZUTILS
....+....1....+....2....+....3....+....4....+....5....+.Mode Structured.
Old Copybook 08
Old Copybook 09
Old Copybook 10
New Copybook 01
New Copybook 02
New Copybook 03
New Copybook 04
New Copybook 05
New Copybook 06
New Copybook 07
New Copybook 08
New Copybook 09
New Copybook 10
*
Updated by
RALPH
Updated on
10/25/2003
Updated at
17:31:58
....+..Current Source Size: 1266 Char. Free: 222255 ..+... S 60
21
L 41
Uses of the Source Work Area
Utility Customization
• Retrieve text member into array
USR1057N
• Parse array entries into keyword/value
• Present values to user
• Validate new values
• Write keywords/values to SWA
• Store SWA as text member
• “Replace” option
22
USR2019N
Uses of the Source Work Area
Utility Customization
• ZZTDOC
ZZTDOC
LEN Consulting LLC
Natural Utilities
Generate Code Walkthrough Document
Old: Env:
PDS:
New: Env:
PDS:
Set:
P
Library: ZZUTIL__
Member: ________
RALPH.PROD.JCL______________________________
D
Library: ZZUTIL__
Member: ________
RALPH.DEVL.JCL______________________________
Library: ________
Listing: Compare: C
Delta: N
Type: L
Print:
05/02/2004 17:54
ZZUtils v2.1
Profile: ZZUTIL/RALPH
Context: 10
Summary: N
ID: LASER___
Hold: Y
Type: N
Member: ________
Ada Cmd: Y
Class: X
Copies: 1
ILRC: Y
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
23
Uses of the Source Work Area
Simple Code Example: Modify a Source Module
• ZZL1057
S
S
1
2
3
3
3
2
3
3
3
3
3
3
3
3
3
2
3
3
3
ZZ1057
OBJECT-KEY
LIBRARY
OBJECT-NAME
OBJECT-TYPE
INPUTS
OPT-ACCESS
OPT-UNUSED-1
OPT-UNUSED-2
OPT-LINE-NUM
OPT-UNUSED-3
OPT-REDEF-DIR
OPT-UNUSED-4
OPT-AMOUNT
OPT-LINESIZE
INPUT-OUTPUTS
INT-HANDLE
NEXT-SEQ
NEXT-NUM
A8
A32
A2
A1
L
A1
A1
L
L
A1
I2
I2
I4
I4
I2
24
Uses of the Source Work Area
Simple Code Example
• ZZL1057
R
2
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
OUTPUTS
RETURNED
SRC-NUM
SRC-TEXT
SRC-TEXT
DIR-OBJNAME
DIR-LIBRARY
DIR-OBJTYPE
DIR-OBJKIND
DIR-DBID
DIR-FNR
DIR-DATN
DIR-TIMN
DIR-USERID
DIR-PROGMODE
DIR-SRCSIZE
DIR-GPSIZE
DIR-UNIQUE-ID
DIR-DDM-DBID
DIR-DDM-FNR
I2
I2
A1
(1:60)
(1:60,1:72)
A32
A8
A2
A1
A5
A5
A8
A7
A8
A1
A10
A10
A32
A5
A5
25
Uses of the Source Work Area
Simple Code Example
• ZZL1057
R
4
4
4
4
4
4
4
4
3
4
5
3
3
DIR-NATVERS
DIR-NATSM
DIR-INIT-USER
DIR-TID
DIR-TRANS-NAME
DIR-OPSYS
DIR-TPSYS
DIR-USED-GDA
SRC-TEXT
SRC-GROUP
SRC-LINE
SRC-SEQ
SRC-LONG
A4
A2
A8
A8
A8
A8
A8
A8
(1:60)
A72
I4
A1
(1:60)
(1:60)
26
Uses of the Source Work Area
Simple Code Example
• ZZL1057
R
2
3
3
4
4
4
4
4
4
4
USR1057N
EXTENDED-DATA
EXTENDED-DATA
VERSION
V1-NSC-CKECK
V2-DBID
V2-FNR
V2-PSW
V2-CIP
V2-SYSFILE
A1
(1:28)
I1
A1
N5
N4
A8
N8
A1
27
Uses of the Source Work Area
Simple Code Example
• ZZL2019
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
ZZ2019
SYSTEM-FILE
DBID
FNR
PASSWORD
CIPHERCODE
OBJECT-CLASS
LIBRARY
OBJECT-NAME
OBJECT-TYPE
OBJECT-KIND
OPT-ACCESS
OPT-ET
OPT-REPLACE
OPT-SESNUM
OPT-BUFFNAME
OPT-NSC-CHECK
EDIT-MODE
EXTENDED-DATA
A1
N5
N5
A8
N8
I1
A8
A32
A2
A1
A1
L
A1
B2
A8
A1
A1
A1
(1:2)
INIT <H'02', 'Y'>
28
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
DEFINE DATA
LOCAL USING ZZL1057
/* Retrieve source
LOCAL USING ZZL2019
/* Save source
LOCAL USING USR-MSG
/* Data for message exchange
LOCAL USING USR-FLD
/* Description of the field in error
LOCAL
1 #MAINFRAME (A16) CONST <'MAINFRAME'>
1 #USR1057 (A8)
CONST <'USR1057N'>
1 #REAL
2 #MACHINE-CLASS (A16)
INIT <*MACHINE-CLASS>
*
1 #PLIB (A8)
INIT <'BOSTON'>
1 #PMOD (A8)
INIT <‘NC-SW-03'>
*
1 #SET-UPPER (L)
1 #I (I4)
END-DEFINE
*
FORMAT PS=23 LS=80
*
29
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
0210
0220
0230
0240
0250
0260
0270
0280
0290
0300
0310
0320
0330
0340
0350
0360
0370
0380
DEFINE
*
*
RESET
ASSIGN
ASSIGN
ASSIGN
ASSIGN
ASSIGN
ASSIGN
ASSIGN
*
ASSIGN
ASSIGN
ASSIGN
ASSIGN
ASSIGN
*
PRINTER (1) OUTPUT 'SOURCE'
ZZ1057.USR1057N
ZZ1057.VERSION
ZZ1057.V2-SYSFILE
ZZ1057.OBJECT-TYPE
ZZ1057.OPT-LINE-NUM
ZZ1057.OPT-REDEF-DIR
ZZ1057.OPT-AMOUNT
ZZ1057.OPT-LINESIZE
=
=
=
=
=
=
=
2
'U'
'T'
'Y'
FALSE
60
72
ZZ2019.SYSTEM-FILE
ZZ2019.OBJECT-TYPE
ZZ2019.OPT-ACCESS
ZZ2019.OPT-REPLACE
ZZ2019.OPT-NSC-CHECK
=
=
=
=
=
'U'
'T'
'W'
'Y'
'N'
/* FUSER
/* Text
/* Source block
/* FUSER
/* Text
/* Write
30
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
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
31
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
0590
0600
0610
0620
0630
0640
0650
0660
0670
0680
0690
0700
0710
0720
0730
0740
0750
0760
0770
0780
IF
NAD-MSG.MSG-NR = 1006
THEN
REINPUT 'Module not found' MARK *#PMOD
END-IF
ASSIGN ZZ1057.OPT-ACCESS = 'R'
/* Read into array
CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD
/*
Update
SET CONTROL 'Z'
/* Clear Work area
FOR #I = 1 ZZ1057.RETURNED
IF ZZ1057.SRC-LINE (#I) = '*/'
THEN
ESCAPE TOP
END-IF
IF ZZ1057.SRC-LINE (#I) = 'UPPER CASE'
THEN
WRITE (1) NOTITLE
'lower case'
RESET #SET-UPPER
ESCAPE TOP
END-IF
32
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
0790
0800
0810
0820
0830
0840
0850
0860
0870
0880
0890
0900
0910
0920
0930
0940
0950
0960
IF
ZZ1057.SRC-LINE (#I) = 'lower case'
THEN
WRITE (1) NOTITLE
'UPPER CASE'
ASSIGN #SET-UPPER = TRUE
ESCAPE TOP
END-IF
IF #SET-UPPER
THEN
EXAMINE SRC-LINE (#I) TRANSLATE INTO UPPER CASE
ELSE
EXAMINE SRC-LINE (#I) TRANSLATE INTO LOWER CASE
END-IF
WRITE (1) NOTITLE
ZZ1057.SRC-LINE (#I)
WRITE
ZZ1057.SRC-LINE (#I)
END-FOR
33
Uses of the Source Work Area
Simple Code Example
• NC-SW-02
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
34
Uses of the Source Work Area
Simple Code Example
• NC-SW-03 before
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
UPPER CASE
*
RAINING CATS AND DOGS
GIVE HIM THE BOOT
FACE THE MUSIC
DRESSED TO THE NINES
PUT TWO AND TWO TOGETHER
HE LAID AN EGG
WALK ON EGG SHELLS
I SMELL A RAT
CAT GOT YOUR TONGUE?
LET THE CAT OUT OF THE BAG
SPILL THE BEANS
YOU SAY POTATO, I SAY POTATO
35
Uses of the Source Work Area
Simple Code Example
• NC-SW-03 after
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
*/
lower case
*
raining cats and dogs
give him the boot
face the music
dressed to the nines
put two and two together
he laid an egg
walk on egg shells
i smell a rat
cat got your tongue?
let the cat out of the bag
spill the beans
you say potato, i say potato
36
Manipulating the Natural Source Area
Questions?
37
Uses of the Source Work Area
Editing Natural Objects
• Build your own editor based on SAG editor API
• Custom edit commands
• Dynamic code generation
• Load prototype from text member
• Execute editing commands
• Stow and execute
• SAG-L archive:
http:\\listserv.uark.edu/archives/sag-l.html
38
Uses of the Source Work Area
As a Temp File
• Load SWA via WRITE or user exit
• Read line by line
USR2014N
39
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – USR2014N control block
0010
0020
0030
0040
0050
0060
0070
0080
0090
0100
0110
0120
0130
0140
0150
0160
0170
0180
0190
0200
* Use SWA as a TEMP file
*
*
Data definitions as in USR2014P:
*
DEFINE DATA LOCAL
1 C-SCRMAX
(I01)
CONST <10>
/* Maximum number of lines
1 C-SCRLEN
(I01)
CONST <72>
/* Length of data area
1 C-PRFLEN
(I01)
CONST <06>
/* Length of prefix area
1 SHOW-PREFIX-AREA
(L)
CONST <FALSE>
LOCAL
1 CONTROL-BLOCK
2 ED-SESNUM
(B02)
/* Number of session (0-50)
2 ED-LOGFLAG
(A01)
/* Logical name in use
2 ED-LOGNAME
(A08)
/* Logical name of the session
2 ED-REQUEST
(A04)
/* Editor request
2 ED-LIBRARY
(A08)
/* Unused
2 ED-MEMBER
(A08)
/* Unused
2 ED-RECLEN
(B02)
/* Maximum length of each line
2 ED-PRFLEN
(B02)
/* Length of a prefix line on screen
2 ED-SCRLEN
(B02)
/* Length of a single line on screen
40
Uses of the Source Work Area
As a Temp File
• NC-SW-04
0210
0220
0230
0240
0250
0260
0270
0280
0290
0300
0310
0320
0330
0340
0350
0360
0370
0380
0390
0400
2 ED-SCRNUM
2 ED-SCRMAX
2 ED-RENUM
/*
2 ED-MCMND
2 ED-SCMND
2 ED-CAREA
2 ED-CROW
2 ED-CCLM
/*
2 ED-RECTOP
2 ED-NEW-RECTOP
2 ED-RECNUM
2 ED-NEW-RECNUM
2 ED-FILECHG
2 ED-SRAUSED
2 ED-SRAFREE
2 ED-FLINE
(B02)
(B02)
(B01)
/* Number of lines on screen
/* Maximum number of lines on screen
/* Unused
(A50)
(A08)
(B02)
(B02)
(B02)
/*
/*
/*
/*
/*
Main command: command line
Secondary command: PF-key
Cursor area
Cursor row
Cursor column
(B02)
(B04)
(B02)
(B04)
(B01)
(B04)
(B04)
(A80)
2 ED-MSGNUM
(B02)
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
Unused
Line number of new first line on screen
Unused
Number of lines in the source area
Indicator if source area has been mod.
Used source area in bytes
Unused source area in bytes
Message test. Explanation for
ED-MSGNUM or ED-ERRNUM
Message number
41
Uses of the Source Work Area
As a Temp File
• NC-SW-04
0410
0420
0430
0440
0450
0460
0470
0480
0490
0500
0510
0520
0530
0540
0550
0560
0570
0580
0590
0600
2 ED-ERRNUM
(B02)
2 ED-DUMMY
(A32)
2 REDEFINE ED-DUMMY
3 ED-DSTYPE
(A01)
3 ED-RECMAX
(B02)
/* Error number
/* Used for enhancements
/* Type of session
/* Target session for CSES request
/*
1 CB-ALIN
/* Attributes of prefix area
2 CB-ALIN-V
(N01/1:C-SCRMAX)
1 L-PREFIXES
/* Prefix area
2 L-PREFIX-MAX
(1:C-SCRMAX)
3 L-PREFIX
(A06)
/* Length must be equal C-PRFLEN
3 REDEFINE L-PREFIX
4 L-PREFIX-A1 (A01/1:C-PRFLEN)
/*
1 CB-ADAT
/* Attributes of data lines
2 CB-ADAT-V
(N01/1:C-SCRMAX)
1 L-DATA-LINES
/* Data lines
2 L-DATA-MAX
(1:C-SCRMAX)
3 L-DATA
(A72)
/* Length must be equal C-SCRLEN
3 REDEFINE L-DATA
42
Uses of the Source Work Area
As a Temp File
• NC-SW-04
0610
0620
0630
0640
0650
0660
0670
0680
0690
0700
0710
0720
0730
0740
0750
0760
4 L-DATA-A1
(A01/1:C-SCRLEN)
*
LOCAL
1 C-SESNUM (B2)
1 ERROR-NUMBER (N4)
* --------------------------------------------------------------------1 #I (I4)
1 #ED-SCRNUM (I4)
1 #RECNUM (I4)
1 #LINES (P7)
1 #WORK (A72)
1 REDEFINE #WORK
/* WORK record
2 #W (A2)
2 FILLER 1X
2 #ALPHA (A69)
1 #WORDS (P7)
END-DEFINE
43
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – populate SWA
0770
0780
0790
0800
0810
0820
0830
0840
0850
0860
0870
0880
0890
0900
0910
0920
0930
0940
*
Initialize the SWA
SET CONTROL 'Z'
/* Clear SWA
FORMAT (3) LS=72
DEFINE PRINTER (3) OUTPUT 'SOURCE'
WRITE (3) NOTITLE '09 The quick brown fox jumps over the lazy dog.'
WRITE (3) NOTITLE '07 A penny saved is a penny earned.'
WRITE (3) NOTITLE '06 That"s all water under the bridge.'
*
*
ASSIGN ED-SESNUM = 0
/* Open a free session
ASSIGN ED-LOGFLAG = 'N'
ASSIGN ED-DSTYPE = 'N'
/* NATURAL SWA
ASSIGN ED-RECLEN = 100
ASSIGN ED-SCRMAX = 10
ASSIGN ED-SCRNUM = 10
ASSIGN ED-SCRLEN = C-SCRLEN
ASSIGN ED-PRFLEN = C-PRFLEN
*
44
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – open
0950
0960
0970
0980
0990
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090
ASSIGN ED-REQUEST = 'OPEN'
/* Open session
CALLNAT 'USR2014N'
CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*)
IF ED-ERRNUM <> 0
THEN
ERROR-NUMBER := ED-ERRNUM
/* Error number in decimal form
WRITE 'Error occurred during OPEN processing:' (I)
/ '=' ERROR-NUMBER
/ '=' ED-FLINE (AL=65)
STOP
END-IF
ASSIGN C-SESNUM = ED-SESNUM
/* Session number returned from OPEN
ASSIGN #RECNUM = ED-NEW-RECNUM
/* Number of lines in SWA
*
*
45
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – “READ WORK”
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
ASSIGN ED-REQUEST = 'GETL'
/* Get lines
FOR #I = 1 #RECNUM
/* READ WORK ...
ASSIGN ED-NEW-RECTOP = #I
CALLNAT 'USR2014N'
CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*)
ASSIGN #WORK = L-DATA (1)
DISPLAY
'SWA/Line' #I (EM=ZZ9)
'/Words'
#W
'/Line'
#ALPHA (AL=50)
IF #W IS (N2)
THEN
ADD 1 TO #LINES
ADD VAL (#W) TO #WORDS
END-IF
END-FOR
*
*
46
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – “end-of-data” & “CLOSE WORK”
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
WRITE
/// #RECNUM (SG=F NL=3) 'source lines'
// #LINES (SG=F NL=3) 'lines processed'
/ #WORDS (SG=F NL=3) 'words'
*
ASSIGN ED-REQUEST = 'CLSS'
/* Close session
CALLNAT 'USR2014N'
CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*)
SET CONTROL 'Z'
/* Clear SWA
END
47
Uses of the Source Work Area
As a Temp File
• NC-SW-04 – report
Page
1
05/02/04
SWA
Line Words
Line
---- ----- -------------------------------------------------1
2
3
4
*/
09
07
06
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
48
14:28:50
Uses of the Source Work Area
Questions?
49
SAG User Exits
• Storing Natural source
• Retrieving Natural source
• Editing the SWA
• Miscellaneous
50
SAG User Exits
Storing Natural Source
• USR0210N save/cat/stow source into FUSER
• USR2019N save source into FUSER
51
SAG User Exits
Retrieving Natural Source
• USR1057N read from FUSER into an array
• USR2019N read from FUSER into SWA
52
SAG User Exits
Editing the SWA
• USR2014N SAG editor
• USR1036N maintain user profile
• USR1035N edit SWA contents
53
SAG User Exits
Miscellaneous
• USR0008N determine/set content type/name
• USR0330N FUSER directory
• USR1054N find libraries containing module name
• USR1055N find modules in a library
• USR2014N read source as a temp file
54
Manipulating the Natural Source Area
Questions?
55
EMEA Natural Programmers User Group
Manipulating the Natural
Source Area
Ralph Zbrog
LEN CONSULTING LLC
[email protected]
June 2004