add - add op2 data to op1 data & store result in op1 - 28 anc - ANd Character (erase bits in op1 with corresponding 0 bits in op- 17 bal - branch & link to a subroutine - 77 bcr - Branch on Condition & Return - 80 bcr example - testbcr1 test/demo job for bcr instruction - 81 cat - concatenate op2 data onto op1 data (within op1 limits) - 13 can - cancel the uvcopy job - 75 chx - convert character representation of hex to true hex data - 86 clr - clear the op1 area to the op2 byte value - 14 cls - close a file - or all files that are open if op1 = 'all' - 43 cmc - compare and set internal condition code for following skp - 35 cmn - compare numeric & set condition code for following skp - 37 cnt - count the number of op2 patterns in the op1 area -118 ctr - center data within the op1 area -120 data type codes - data type & sign codes in op1/op2 lengths - 22 dat - convert dates between: calendar,julian,& days-since-1900 -127 del - delete a record in an Indexed file - 70 div - divide the op1 data by the op2 data & store result in op1 - 31 dlm - convert Fixed-Field to "delimited","format" -124 edt - edit op2 data into op1 area controlled by op3 mask - 15 env - get value for any specified environmental variable -138 eoj - end the job - 75 evt - get & table the values for all environmental variables -139 fix - convert variable field format to fixed length fields -121 fxt - add a uvcopy instruction to the execution table -137 get - next record from a sequential file & store in the op2 area - 44 hxc - convert hex data to hex character representation - 86 ins - insert op2 data prior to op1 data -119 lck - lock a D-ISAM Indexed file - 71 lok - look-up a table of data (op1) for match to argument (op2) -133 mpy - multiply op1 data by op2 data & store result in op1 - 30 msg - display a msg (1 or 2 lines) on stdout - 72 msgw - display message & wait for reply (option "w" of msg) - 73 mvc - move character data from op2 to op1 for op1 length - 8 mvf - move op2 to op1 for lth op2 & fill excess op1 with op3 char - 9 mvr - move data from op2 to op1 right adjusted, left filled with op3 - 11 mvp - move op2 to op1, if all EBCDIC blanks, convert to ASCII blanks - 12 mvn - move numeric data depending on op1/op2 types & lengths - 21 mvu - move op2 data to op1 area until the op3 pattern detected - 98 opn - open a file - or all files declared if op1 = 'all' - 42 orc OR Character - set 1 bits in op1 with corresponding 1 bits in op2 - 18 pac - pack the op2 data into the op1 area - 32 pop - process option string into process/user option storage -136 put - a record to a sequential file - 49 rel - set file pointer (relative record# or relative byte#) - 55 red - read a record from an indexed file - 64 ret - return from a subroutine (to the instruction following the bal) - 79 rep - scan op1 replacing all op2 patterns with the op3 data - 96 rpt - replace by table -103 rtb - read a table of data into the op1 area (at run time) - 57 rts - scan a table for a pattern & replace with an alternate -109 rtt - replace patterns in data table via search/replace table -112 scn - scan op1 area for op2 pattern & set cc equal if found - 89 sct - scan by table -101
Return to first page of: this document this library (librefs) UV Software Home-Page
set - set key of reference & file pointer in an Indexed file - 63 shf - shift data a specified number of bits left or right - 20 skeleton1 - template job to copy, rename,& modify as required - 5 skp - skip to a tag (or number of instrns) if condition code matches - 38 sort (external) - sxo, sxp, sxs, sxg, sxc -147 sqz - squeeze out occurrences of the op2 character from op1 -115 sqf - squeeze multiple contiguous fields & blank fill at the end -117 srt - internal sort (tables, record arrays, etc) -145 sts - scan a table for a character string -107 sub - subtract the op2 data from the op1 data & store result in op1 - 29 subrtn example - cymd compare 6 digit dates for Year 2000 - 78 swp - swap left & right sides of data in op1 based on op2 separator -126 sys - issue system commands - call the shell to execute op1 string -130 table instruction overview table formats - supplied formats available (f1-f12) -162 table entry layout - dumped by tbd (unedited) -165 tbl - build tables in memory to be dumped at end of job -154 tbf - declare formats to be used when editing tables to output files -156 tbh - declare table column (field) headings -157 tbp - print (edit) the table entries into a file (usually at eoj) -158 tbd - dump (unedited) the table entries into a file (usually at eoj) -160 tim - get current date & time & store in area y for user access - 76 tra - translate to ASCII (from EBCDIC) - 82 tre - translate to EBCDIC (from ASCII) - 82 trl - translate to lower case (any UPPER case present) - 83 tru - translate to UPPER case (any lower case present) - 83 trt - translate via user specified (or modified) translate table - 84 trs - translate/search command - 85 tst - test each op1 sub-field for match to any op2 sub-field - 39 tsb - test 1 byte of data for any match to the bits in the 1 byte op2 - 41 ulk - unlock a D-ISAM Indexed file - 71 unp - unpack the op2 data into the op1 area - 33 und - convert "delimited","format" to Fixed-Field -125 update_rel reldemo1 - update in place - 55 upd - update a record in an Indexed file - 67 upw - update/write record depending on key present/absent - 69 var - convert multi fixed length fields to a variable length string -123 vhx - convert data to vertical hexadecimal representation - 87 vnf - Verify Numeric Field -140 wat - wait a specified number of seconds - 76 wrt - write a new record into an Indexed file - 66 wtb - write a table of data from the op1 area (at run time) - 61 xft - crossfoot multiple op2 fields & store the result in op1 - 34 xor - eXclusive OR (bit manipulation) - 19 xxa - call user subfunction (written in C & linked to uvcopy) -143
The above index was created automatically by the uvcopy 'uvindex3' job (which is documented in section UVjobs2.doc)
uvcopy uvindex3,fili1=doc/uvcopy3.doc,filo1=tmp/uvcopy3_index
=============================================================
Return to first page of: this document this library (librefs) UV Software Home-Page
Functions are declarations (not executed as are instructions). Functions are processed once only at setup time. '@run' separates Functions from Instructions.
initial: prm,opr,rop,uop,was
arguments: arg1,arg2,...,arg9
file declaration: fil__,typ,rcs,isk
special functions: lod
begin instructions: @run
Work Areas - 26 work areas (a-z) $symbols - for registers, counters, system values (date,time,filenames,etc) Options - user options, run options, file type options Index Registers - explanations & examples Debugging - step thru program, display work areas, breakpoints, etc
Instructions follow the '@run' function & are stored in memory at 'setup time'. Instructions are executed at 'run time' (after validation at setup time). Instructions are usually executed repeatedly (eg: for each record in a file)
translations, edited reports, sorts, table lookups, convert tabs to blanks
convert fixed length fields to delimited (comma,pipe,etc), split files, Indexed file random access to update sequential files.
Probably the best place to start learning the Vancouver Utilities.
Return to first page of: this document this library (librefs) UV Software Home-Page
# skeleton1 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/demo/
# skeleton1 - uvcopy template job, copy, rename,& modify as required
# - be sure to update these lines with new name & job description
# - unmodified, this job copies any text file (max rcsz 256)
# - see 'skeleton2' (vs skeleton1) for fixed length records w/o LineFeeds
# Example - to copy tf/test100, with options to bypass/copy spcfd no of records
#
# uvcopy skeleton1,fili1=tf/test100,filo1=tmp/test100,rop=b20c10
# ==============================================================
# ',rop=b20c10' above bypasses 1st 20 records,copies next 10,& closes files
#
opr='$jobname - uvcopy skeleton1 job, copy, rename,& modify as required'
fili1=?tf/test100,typ=LST,rcs=256 # code filenames or leave ? for prompt
filo1=?tmp/$fili1,typ=LSTt,rcs=256 # output file same name, different subdir
@run
opn all open files
# begin loop to get & put records until EOF
loop get fili1,a0 get record into area 'a'
skp> eof (condition code set > at EOF)
#-----------------------------
mvc b0(256),a0 move input record to output area 'b'
# --- -----,----- ** add your instructions here **
#-----------------------------
put filo1,b0 write record to output file
skp loop return to get next record
#
eof cls all close files
eoj end job
The 'skeleton1' job shown above is provided for you as a starting point intended for you to copy, rename,& modify as required.
The following example suggests how you would use the uvcopy skeleton1 job, if you wished to create a new uvcopy job called 'fix1'.
#1. Login --> your homedir
#2. mkdir pf - make a sub-directory for your uvcopy jobs
======== (pf is already in PATH of supplied profiles)
#3. cp pf/skeleton1 pf/fix1 - copy skeleton1 to your sub-directory
====================== renaming as you wish (fix1 in this case)
#4. vi pf/fix1 - modify as required, inserting your instructions
========== - modifying file names, types,& record sizes
- change comment lines to new name & job description
#5. uvcopy pf/fix1 - execute uvcopy to interpret your job
==============
- - if errors - - - correct errors & rerun
Please see notes on the next page --->
Return to first page of: this document this library (librefs) UV Software Home-Page
When you want to make a new job, the following steps are recommended:
fili1=?tf/test100,typ=?LST,rcs=256
filo1=?$fili1,typ=?LSTt,rcs=256
#3a. You might as well hard-code your specific filenames, replacing
"?tf/test100 & ?$fili1". You could leave the "?" prefix if you
anticipate using the job with various files. The "?" causes an
an operator prompt for a new filename (null reply for default).
#3b. The file types default to 'LST' (variable-length LF Terminated).
Change to 'RST' if your records are fixed-length, LF Terminated,
or to 'RSF' if your records are fixed-length, without LineFeeds.
The 't' on 'typ=LSTt' is the option to truncate output records
after the last non-blank (vs 256 byte records + LF).
#3c. The record size defaults to 256, which is OK if your file types
are 'LST' & do not exceed 256.
For fixed-length records, you must change to the correct values.
(see complete details re 'typ' & 'rcs' in uvcopy1.doc)
#-----------------------------
mvc b0(256),a0 move record to output area 'b'
# --- -----,----- *** add your instructions here ***
#-----------------------------
If you did not change anything, all this skeleton1 job would do is copy text file records with no changes.
Return to first page of: this document this library (librefs) UV Software Home-Page
| given |
|
| required |
|
| solution |
|
#-----------------------------
# --- -----,----- ** add your instructions here **
add $ca1,10 count lines by 10
mvn b0(6),$ca1 insert new seq#
mvc b72(8),' ' clear cols 73-80
#-----------------------------
# cobol_cleanup1 - cleanup COBOL source code, resequence 1-6, clear 73-80
# - uvcopy job created by copy/rename from skeleton1
#
# uvcopy cobol_cleanup1,fili1=cbls/cobolprgmxx,filo1=tmp/cobolprgmxx
# ==================================================================
#
opr='$jobname - cleanup COBOL source code, resequence 1-6, clear 73-80'
fili1=?cbls/cobolprgmxx,typ=LST,rcs=256
filo1=?tmp/$fili1,typ=LSTt,rcs=256
@run
opn all open files
# begin loop to get & put records until EOF
loop get fili1,a0 get record into area 'a'
skp> eof (condition code set > at EOF)
#-----------------------------
mvc b0(256),a0 move input record to output area 'b'
# --- -----,----- ** add your instructions here **
add $ca1,10 increment line counter (by 10)
mvn b0(6),$ca1 insert sequence# in cols 1-6
clr b72(8),' ' clear cols 73-80
#-----------------------------
put filo1,b0 write record to output file
skp loop return to get next record
#
eof cls all close files
eoj end job
uvcopyx cobol_cleanup1 cbls tmp uop=q0i7 ======================================== - use 'uvcopyx' script to repeat cobol_cleanup1 for all files in directory - inspect outputs in tmp/... subdir, then copy back to cbls/...
Return to first page of: this document this library (librefs) UV Software Home-Page
mvc tobyte(lth),frombyte - instruction format
mvc op1dsp(op1lth),op2dsp - op2 may be an area address
mvc op1dsp(op1lth),'constant' or a constant
mvc b100(30),a0 - move from the 1st byte of area 'a'
to area b starting at byte #101
& proceeding for 30 bytes
mvc b130(07),'updated' - move the op2 constant to bytes
131-137 of area 'b'
mvc b137(02),x'0d0a' - move the hex constant 0d0a (CR/LF)
to bytes 138 & 139 of area b
The condition code is unchanged as of version 0005 may 2000. Some earlier versions set cc = if resulting op1 was all blank, but not changing cc allows code such as:
cmc ---,--- - set condition code
mvc ---,---
skp= xxx - test condition code
Note that operand 1 is the destination/receiving area & operand 2 is the origin/sending area. This follows the IBM 360+ assembler rules. The length is coded on operand 1 & may be omitted from operand 2 for instructions such as mvc where it is the same.
uvcopy is an 'interpretive assembler' - all the power of assembler, without the complexity of compiles, just modify the parameter file & rerun.
Return to first page of: this document this library (librefs) UV Software Home-Page
mvf b0(80),a20(60),' ' - move 21-80 of op2 to op1 1-60
then fill 61-80 of op1 with blank
mvft c0(10),$reply(10),x'00' - move reply data to 1-10 of c
| option 't' |
|
| option 't1' |
|
mvf h0(70),'---constants---' - op3 defaults to a blank if omitted
Use 'mvf' vs 'mvc' when storing long constants, because 'mvc' could pick up garbage if your constant is not long enough, but mvf will always fill any extra length with blanks.
option v1 - expand uvcopy internal $symbols
v5 - (v1+v4) controls expansion of $symbols
v1 (4 bit absent) - replacing data ended by 1st blank (or null)
v5 (4 bit present) - replacing data ended by 1st tilde (or null)
mvfv1 h0(70),'$jobname: date/time=$datetime user=${LOGNAME}'
| Note |
|
| condition code |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
"mvf" is very useful with special symbols that may be null terminated such as $fil_ names, which are 80 bytes & null filled on the right.
The following examples move the 80 byte filename to a 90 byte area:
#1. mvc b0(80),$fili1 - move (mvc) filename to area b
(80 bytes unchanged, still null filled)
#2. mvf b0(90),$fili1 - move (mvf) filename to area b & blank
fill remainder of op1 (see #2 above)
#2a. mvf b0(90),$fili1,' ' - same as above (blank fill default)
#3. mvft b0(90),$fili1 - option 't' causes an additional
backward blank fill of the result
until the right most significant data
is found (see #3 above)
#4. mvft1 b0(90),$fili1 - same as above but option 't1' fills
with nulls (see #4 above)
#4a. mvft b0(90),$fili1,x'00' - same as above
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
mvr op1adrs(op1lth),op2adrs(op2lth)[,op3fillchar] - format
mvr b0(20),a0(15) - move op2 to op1 6-20 (1-5 blanks)
mvr b0(10),a0(8),'0' - move op2 to op1 right adjusted
& zero left filled
| Note |
|
| condition code |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
mvp - same as mvc, but if field all EBCDIC blanks, set to ASCII blanks
- to assist conversion of mainframes to UNIX
- some COBOL programs expect unused table(occurs) group fields to
be all blanks, even if some items are packed fields.
mvp b50(5),a50 - move area a bytes 50-54 to area b 50-54
if all EBCDIC blanks, set to all ASCII blanks
cc set '=' if op1 was in fact converted to ASCII blanks
Return to first page of: this document this library (librefs) UV Software Home-Page
cata1 b0(80),a0(20) - append data in a to data in b
'cat' scans op1 from rt to left for last significant data > x'20', appends the op2 data, & then rescans op1 from right to left for last significant data > x'20'.
option b - inserts before op2 data appended (at end of op1 data)
b1 - 1 blank
b2 - 1 line-feed
b4 - 2nd line-feed
b8 - 1 NULL
| option c1 |
|
option a - inserts after op2 data appended (at end of op2 data)
a1,a2,a4,a8 - same as above
| register 'x' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
clr tobyte(lth),'constant' - instruction format (op2 constant)
clr tobyte(lth),frombyte (op2 address)
clr b0(500),' ' - blank out 1st 500 bytes of area 'b'
clr h100(100),x'ff' - fill 101-200 of area h to x'ff's
clr h100(100),g0 - fill 101-200 of area h with the
value from byte 1 of area 'g'
- op2 length always 1 byte
& need not be coded
Return to first page of: this document this library (librefs) UV Software Home-Page
edt b40(10),a20(4p),zz,zzz.99-'
The example above edits the 4 byte packed (7 digit) field in cols 21-24 of area 'a' into cols 41-50 of area 'b' controlled by the mask in op3.
Symbols allowed in edit mask:
z - digit position to be zero suppressed
9 - digit position NOT zero suppressed (1st '9' stops zero suppression)
- - minus sign, floating if on left, fixed position if on right
- replaced by blank if numeric field is positive
+ - sign indicator, shows '+' if positive, '-' if negative
- may specify on left for floating, on right for fixed
? - any other characters will be stored (unless zero suppress is still on)
The following are some examples of data, edit mask,& results:
edt b0(12),a0(8),'zz,zzz.99-'
================================
data a0(8) edit mask results b0(12)
1234567- zz,zzz.99- 12,345.67-
0000000- zz,zzz.99- .00
0000000- zz,zzz.zz-
0000567- zz,zzz.99-* 5.67-*
0000567- z.99- 5.67- (auto left z's supplied)
0000567- z.99+ 5.67+
0000567- -z.99 -5.67 (leading floating sign)
0000567- +z.99 +5.67
1234567+ zz,zzz.99- 12,345.67
0000000+ zz,zzz.99- .00
0000000+ zz,zzz.zz-
0000567+ zz,zzz.99-* 5.67 *
0000567+ z.99- 5.67 (auto left z's supplied)
0000567+ z.99+ 5.67+
0000567+ -z.99 5.67 (leading floating sign)
0000567+ +z.99 +5.67
edta1 b0(12),a0(8),'zz,zzz.99-'
================================
1234567- zz,zzz.99- 12,345.67-
0000567- z.99- 5.67- <-- option 'a1' left adjusts
Return to first page of: this document this library (librefs) UV Software Home-Page
edt b60(10),$date1(8),'9999/99/99' edit system date
edt b72(5),$date1+8(4),'99:99' edit system time
|
edt p30(13),$ca1,'z,zzz,zzz.99-'
edt p30(13),x200(4b),'z,zzz,zzz.99-'
|
edt p50(9),a20(7z),'zzzzz.99-'
edt p50(9),a20(7z),'z.99-'
|
edt p50(9),a20(7z),'-z.99'
|
edtx12 p10(10),a20(5p),'zzzz,zzz.99-'
===***================================
- edit 12 fields (each 5 bytes packed) cols 21-80 of area a
into area p starting at column 11 (10 bytes each)
| condition code |
|
| register 'w' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
"anc" erases bits in op1 whose corresponding bits in op2 are 0. (0 bits prevail)
ie: 0+0=0, 0+1=0, 1+0=0, 1+1=1
anc op1dsp(lth),'constant' (op2 usually a 1 byte constant)
anc b20(10),x'0f' - clear the zones of bytes 21-30 of area 'b'
anc b20(10),a10(1) - op2 could be an adrs & op2 lth
could be > 1 but unusual
ancm h20(3),x'0f0c0f' - mask 21-23 of area 'h' with 3 byte mask
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
"orc" inserts 1 bits in op1 for corresponding 1 bits in op2. (1 bits prevail)
ie: 0+0=0, 0+1=1, 1+0=1, 1+1=1
orc op1dsp(lth),'constant' (op2 usually a 1 byte constant)
orc b20(10),x'30' - set zones of 21-30 of area 'b' to 0x30
orc b20(10),a15(1) - op2 could be an adrs & op2 lth
could be > 1 but unusual
orcm h20(3),x'0f0c0f' - mask 3 bytes as shown
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
xor (exclusive OR) creates 1 bits in the op1 result, only when the corresponding bits add to exactly 1.
ie: 0+0=0, 0+1=1, 1+0=1, 1+1=0
'xor' - eXclusive OR character
xor op1dsp(lth),'constant' (op2 usually constant)
xor h20(10),x'FF' - xor all 1's reverses bits (complements)
xor h20(10),w15(10) - op2 could be an adrs & op1 lth
could be > 1 but unusual
| Note |
|
| Example |
|
mvc b30(30),b0 - copy 1st key to 2nd key area
xor b30(30),x'FF' - xor (complement bits in 2nd key)
- convert 1 bits to 0 bits,& 0 bits to 1 bits
Return to first page of: this document this library (librefs) UV Software Home-Page
shfr dsplcmnt(length),bits - shift right
shfl dsplcmnt(length),bits - shift left
shfr b20(5),4 - shift data in cols 21-25 4 bits right
- will zero the 4 bits on the left
sample input = x'1234567890' sample output = x'0123456789'
max length = 256 bytes
max no of shift bits = 8
Return to first page of: this document this library (librefs) UV Software Home-Page
mvn todsp(tolth/typ),fromdsp(fromlth/typ) mvn todsp(tolth/typ),numconstant
mvn b100(9),a20(7) - move 21-27 of area 'a' to 101-109 in 'b'
right adjusted, left zero filled
(defaults to zoned ascii numeric)
mvn h30(-9za),r30(9za-) - moves 31-39 input to 31-39 output
shifting sign trailing to leading
- negative indicated by '-' symbol
positive indicated by absence
(use '+' to show positive as '+')
mvn b200(4bs),r50(9za) - converts 51-59 from zoned ascii
to 201-204 binary long word
- 's' means switch bigend/littleend
mvn b160(5pa),235- - store constant neg 235 in 161-165
packed ascii (sign in zone)
mvnx12 b100(5p),0 - move zero to the 12 5 byte packed
fields that start at byte 101 of area b
mvnx6j10 b100(5p),0 - move zero to every 2nd field of the
12 5 byte packed fields that start
at byte 101 of area b (6 fields cleared)
mvn b80(9za),a20(5pe) - unpacks 21-25 of 'r' into 81-89 of 'h'
21-25 is packed EBCDIC
81-89 will be zoned ASCII (sign in zone)
mvn b80(9za),a80(9zx) - convert 81-89 zoned type 'x' (see below)
to zoned ASCII numeric
- type 'x' corrects zoned numeric signs
translated from EBCDIC to ASCII
before testing possible zoned signs
(see explanation next page)
mvn b0(10),a0(8f) - convert floating point double to numeric
mvn b0(10),a0(4f) - convert floating point single to numeric
mvn c0(8f),a0(4f) - convert floating point single to double
Return to first page of: this document this library (librefs) UV Software Home-Page
Data types & signs may be coded within the (length), for example:
mvn b100(-9za),a20(5p)
1st alpha letter defines the data type
| z |
|
| p |
|
| b |
|
| k |
|
| f |
|
2nd alpha letter defines the codeset (or indicates binary switch)
| a |
|
| e |
|
| s |
|
| x |
|
separate sign byte codes
"-" sign indicates a separate sign byte (vs zone of units digit)
('-' is coded if negative, else positive is assumed)
"+" sign indicates a separate sign byte, but code '+' for positive
as well as '-' for negative
"-" or '+' in the 1st byte of the length indicates a leading sign byte
else the sign byte will be trailing
Return to first page of: this document this library (librefs) UV Software Home-Page
data type code 'x' - ASCII zoned numeric translated from EBCDIC
---------------------------------------------------------------
Data type code 'x' is provided to correct the units position of numeric zoned (unpacked) fields that have been translated from EBCDIC to ASCII without allowing for possible zoned signs.
EBCDIC zone + sign is x'C0', + 0123456789 becomes {ABCDEFGHI
EBCDIC zone - sign is x'D0', - 0123456789 becomes }JKLMNOPQR
Code 'x' converts positive units digits to 0123456789 (numeric zones) but negative units digit depends on whether the uvcp/uvcopy/uvsort utility has been generated with D-ISAM for Microfocus COBOL or not since conventions are different for Microfocus COBOL & MBP COBOL
Microfocus zone - sign is x'70', - 0123456789 becomes pqrstuvwxy
MBP COBOL zoned - sign is x'40', - 0123456789 becomes @ABCDEFGHI
| Note |
|
| condition code |
|
mvn b20(8),$ca2 - store acum #2 in outrec & test zero ?
skp! 1
--- ----,---- - do something if zero ??
The following options also apply to mvn,add,sub,mpy,div,pac,unp,edt.
| option x# |
|
j# - alternate length to increment op1 (vs op1 lth coded)
- might use to process every 2nd field,etc
k# - alternate length to increment op2 (vs op2 lth coded)
Return to first page of: this document this library (librefs) UV Software Home-Page
option c - 1/2 byte alignment for field type 'k' (Burroughs 'comp' data)
(similar to packed, may have no sign, may be 1/2 byte aligned)
- fields may start &/or end on 1/2 byte boundaries
c0 - field is byte aligned on both left & right
c1 - field starts in low order 1/2 byte on the left
c2 - field ends in high order 1/2 byte on the right
c3 - both of above (c1 + c2 = c3)
| option i1 |
|
05 fldgrp AAA occurs 20 times.
scn a0(80),'occurs' <-- set rgstr 'x' to 'occurs'
mvn $ca1,ax7(4) <-- MoVe Numeric digits from $rx+7(4)
mvni1 $ca1,ax7(4) <-- use option 'i1' to prevent sign detect
|
| option i2 |
|
| option i3 |
|
| note |
|
| option s |
|
s0 - create packed sign output (op1) same as last input (op2)
also validate & if not C/F, create as x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0 (copy last input packed sign for next output)
but validation will create as x'_F' if invalid (not C/F)
s8 - leave packed sign as is (may be invalid)
s16- inhibit storing input sign from this instruction for next output
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
mvn a20(7z),a10(7z) - mvn zoned to zoned (default)
mvn a20(7),a10(7) - do not need to code the 'z' type
-input- -output- note results shown as op2,op1 (reversed)
a10(7) a20(7)
1234567 1234567 - all digits -> no change
123456w 123456w - sign in zone of units (w = -7)
1234 0001234 - digits right adjusted & left zero filled
1234- 000123t - signs may be '-' or units zone x'70'
123t 000123t - t is x'74' for -4 vs x'34' for +4
-1234 000123t - signs may be leading or trailing
1234 AB 001234r - any non-numerics are ignored
mvn a20(7-),a10(7) - trailing sign if '-' trailing in (..)
1234567 1234567
123456w 234567- - may lose data if out field not bigger
1234 0001234 - positive assumed if no sign
1234- 001234- - negative digits offset 1 left for sign
-1234 001234- - leading input sign converted to trailing
mvn a20(-7),a10(7) - leading sign if '-' leading in (..)
1234567 1234567
123456w -234567
1234 0001234
1234- -001234
-1234 -001234
mvn a20(+7),a10(7) - leading -/+ sign if '+' leading in (..)
1234567 +234567
123456w -234567
1234 +001234
1234- -001234
-1234 -001234
Return to first page of: this document this library (librefs) UV Software Home-Page
mvn a20(4p),a10(7z) - convert zoned op2 to packed op1
-input- - - - output - - -
packed hexadecimal
1234567 .4V| 1234567C
123456w .4V} 1234567D
1234 ..#L 0001234C
-1234 ..#M 0001234D
| Note |
|
option s - controls packed decimal sign creation
s0 - create packed sign output (op1) same as last input (op2)
also validate & if not C/F, create as x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0 (copy last input packed sign for next output)
but validation will create as x'_F' if invalid (not C/F)
s8 - leave packed sign as is (may be invalid)
s16- inhibit storing input sign from this instruction for next output
| Note |
|
mvn a20(4b),a10(7z) - convert zoned op2 to binary op1
-input- - - - output - - -
binary hexadecimal
1234567 .... 87D61200
123456w y).. 7929EDFF
1234 .... D2040000
-1234 .... 2EFBFFFF
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
mvn a20(4bs),a10(7z) - convert zoned op2 to binary switched
-input- - - - output - - -
binary hexadecimal
1234567 .... 0012D687
123456w ..)y FFED2979
1234 .... 000004D2
-1234 .... FFFFFB2E
| Note |
|
mvn b0(8f),a0(8)
-input- - - - output - - -
binary hexadecimal
00000000 ........ 0000000000000000
00000001 ........ 000000000000F03F
00000002 ........ 0000000000000040
00000004 ........ 0000000000001040
00000008 ........ 0000000000002040
00000256 ........ 0000000000007040
00004096 ........ 000000000000B040
00065536 ........ 000000000000F040
01048576 ........ 0000000000003041
16777216 ........ 0000000000007041
00000010 ........ 0000000000002440
00000100 ........ 0000000000005940
00001000 ........ 0000000000408F40
00010000 ........ 000000000088C340
00100000 ........ 00000000006AF840
01000000 ........ 0000000080842E41
10000000 ........ 00000000D0126341
99999999 ........ 000000FC83D79741
Return to first page of: this document this library (librefs) UV Software Home-Page
'add' will pack, unpack, convert to binary or decimal as required depending on the data type codes (in the length specification).
add op1dsplcmnt(length&type),op2dsplcmnt(length&type)
---OR---
add op1dsplcmnt(length&type),op2constant
add b100(9),a20(7) - add op2 (21-27 of area 'a') to op1 (101-109 of 'b')
& store result in op1 (101-109 of area 'b')
(data types default to zoned ascii numeric)
add h160(5pa),235- - adds constant neg 235 to 161-165
161-165 packed ascii (sign in zone)
| condition code |
|
| options x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
t1 - inhibit test for negative sign in units digit of zoned fields
- see explanation under the 'mvn' instruction
| option s |
|
s0 - create packed sign output (op1) same as last input (op2)
also validate & if not C/F, create as x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0 (copy last input packed sign for next output)
but validation will create as x'_F' if invalid (not C/F)
s8 - leave packed sign as is (may be invalid)
s16- inhibit storing input sign from this instruction for next output
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
sub todsp(tolth/typ),fromdsp(fromlth/typ) sub todsp(tolth/typ),numconstant
sub b80(9za),a20(5pe) - subtract 21-25 of 'a' from 81-89 of 'b'
21-25 of 'a' is packed EBCDIC
81-89 of 'b' is zoned ASCII (zoned sign)
sub b30(-9za),100 - subtract constant 100 from work area 'b'
leading '-' sign if neg,else zero
- negative indicated by '-' symbol
positive indicated by absence
(use '+' to show positive as '+')
sub h200(4bs),r50(9za) - subtract 51-59 from 201-204
51-59 is zoned ascii
201-204 is a binary long word
- 's' means switch bigend/littleend
on both retrieval & store result
| condition code |
|
| options x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
t1 - inhibit test for negative sign in units digit of zoned fields
- see explanation under the 'mvn' instruction
option s - controls packed decimal sign creation
s0 - (default) create packed sign output same as last input
- if packed sign not C/F, create x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0, but create sign x'_F' if not C/F
- see full explanation under the 'mvn' or 'add' instructions
Return to first page of: this document this library (librefs) UV Software Home-Page
mpy todsp(tolth/typ),fromdsp(fromlth/typ) mpy todsp(tolth/typ),numconstant
mpy b80(9za),a20(5pe) - multiply 81-89 of 'a' by 21-25 in 'b'
21-25 is packed EBCDIC
81-89 is zoned ASCII (zoned sign)
mpy b30(-9za),115 - multiply bytes 31-39 of work area 'b'
by constant 115
- negative indicated by '-' symbol
positive indicated by absence
(use '+' to show positive as '+')
mpy h200(4bs),r50(9za) - multiply 51-59 by 201-204
51-59 is zoned ascii
201-204 is a binary long word
- 's' means switch big-end/little-end
on both retrieval & store result
| condition code |
|
| options x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
t1 - inhibit test for negative sign in units digit of zoned fields
option s - controls packed decimal sign creation
s0 - (default) create packed sign output same as last input
- if packed sign not C/F, create x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0, but create sign x'_F' if not C/F
- see full explanation under the 'mvn' or 'add' instructions
Return to first page of: this document this library (librefs) UV Software Home-Page
div todsp(tolth/typ)fromdsp(fromlth/typ) div todsp(tolth/typ):constant
div b100(9),a20(7) - divide 101-109 by 21-27
& store result in 101-109 (op1)
(defaults to zoned ascii numeric)
op1 dflts to recout, op2 to recordin
div h160(5pa):235- - divs 161-165 by constant -235
161-165 packed ascii (sign in zone)
| condition code |
|
| options x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
t1 - inhibit test for negative sign in units digit of zoned fields
option s - controls packed decimal sign creation
s0 - (default) create packed sign output same as last input
- if packed sign not C/F, create x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0, but create sign x'_F' if not C/F
- see full explanation under the 'mvn' or 'add' instructions
| remainder |
|
div c50(9),24 divide hours by hrs/day
cmn $rem,12 remainder > or < 12 hrs ?
Return to first page of: this document this library (librefs) UV Software Home-Page
pac op1dsp(op1lth),op2dsp(op2lth) - instruction format
pac h100(5),r50(9) - pack bytes 51-59 of area r
into bytes 101-105 of area h
| options x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
| option s |
|
s0 - (default) switches nibbles in low order byte
- no sign verification
s1 - create packed decimal positive signs as x'_C'
- if neg x'4_' bit present, set sign to x'_D'
s2 - create packed decimal positive signs as x'_F'
- if neg x'4_' bit present, set sign to x'_D'
|
Return to first page of: this document this library (librefs) UV Software Home-Page
unp op1dsp(op1lth),op2dsp(op2lth) - instruction format
unp b100(9),a50(5) - unpack 51-55 of area a
into 101-109 of area b
| option x99 |
|
j9 - specify alternate length for the op1 increment
k9 - specify alternate length for the op1 increment
option s - for sign control in zone of units digit
s0 - default switches zone & digit with no test/conversion
s1 - if x'_D' set zone to x'4_', else set zone to x'3_'
(MBP COBOL compatible)
s2 - if x'_D' set zone to x'7_', else set zone to x'3_'
(Micro Focus COBOL compatible)
Return to first page of: this document this library (librefs) UV Software Home-Page
|
xft d0(4b),a100(5p),12 skp= allzero
|
xft $ca1,a100(5p),12
|
option s - controls packed decimal sign creation
s0 - (default) create packed sign output same as last input
- if packed sign not C/F, create x'_C'
s1 - create packed decimal signs as x'_C'
s2 - create packed decimal signs as x'_F'
s4 - same as s0, but create sign x'_F' if not C/F
- see full explanation under the 'mvn' or 'add' instructions
$ci1 = number of significant (non-zero) fields
Return to first page of: this document this library (librefs) UV Software Home-Page
cmc op1dsp(op1lth),op2dsp - instrn format (op2 area address)
cmc op1dsp(op1lth),'constant' (op2 constant)
cmc a0(2),'25' - compare cols 1-2 of area a to constant '25'
skp= 2 skip next 2 instrns if cc was set '='
cmc b50(5),b55 - compare cols 51-55 to 56-60 in area 'b'
skp> if cc was set '>' skip to label tagx
tagx --- - labelled target instrn for the skp above
tagx nop - may use a no-operation instruction when you
have nothing else to do at the target
cmc b0(100),' ' - 'ALL' assumed when op1 multi-byte & op2 1 byte
| option 'p' |
|
cmcp b70(6),'@#@#@#' - validate the Canadian postal code
skp= ok
| option 'p1' |
|
| option 'p9' |
|
cmcp1 a0(2),'##' <-- compare '#' in 1st byte + any digit 0-9 in 2nd
| option 'y' |
|
cmcy a20(6),b20 - compare 2 dates using windows option
cmcy a20(2),'97' - year > 1997 ?
skp> (skips on years 98-49)
| run option 'y' |
|
uvcopy xxx,rop=y30 - change window for all cmcy instructions
from 1950 default to 1930
See more details next page --->
Return to first page of: this document this library (librefs) UV Software Home-Page
| rop=y70 |
|
| rop=y70z1 |
|
cmcy a20(2),'97' ---> if rop=y70z1 & now 1998
skp> would skip on years 1998-1967
| register 'w' |
|
You might use to mark the 1st non-match between 2 areas, for example: (assuming you knew same number of records in each file)
test data for uvcopy job to mark mismatches between files * test data for uvcopy job to mark mis-matches between files
loop get fili1,a0(80) get record from file#1
get fili2,b0(80) get record from file#2
cmc a0(80),b0(80) area a = area b ?
skp= loop yes - return to get next pair
put filo1,a0(80) no - write line from 1st file
mvc cw0(1),'*' - mark 1st nonmatch in area c (blank)
putb filo1,c0(80) - write marker line & clear
put filo1,b0(80) - write line from 2nd file
put filo1,' ' - space between groups
skp loop - return to get next pair of recs
Return to first page of: this document this library (librefs) UV Software Home-Page
cmn op1dsp(op1lth),op2dsp(op2lth) - instrn format (op2 adrs)
cmn op1dsp(op1lth),numconstant (op2 numeric constant)
cmn a20(4b),25 - compare area a 21-24 binary to const 25
skp> 3 & skip 3 instrns if >
cmn a80(9za),a90(5pe) - compare 81-89 zoned ascii to 91-95
skp= tagx packed ebcdic & skip to tagx if '='
tagx --- - labelled target instrn for the skp above
| option 'y' |
|
cmny a20(6),b20(6) - compare 2 numeric dates using windows option
cmny a20(6z),b20(6z) - type 'z' is the default for 'cmn' compares
cmny a20(4p),970000 - year (in 4 packed bytes) => 1997 ?
skp> (skips on years 1997-2049)
| Note |
|
| rop=y70z1 |
|
cmny a20(4b),980000 ---> if rop=y70z1 & now 1998
skp> would skip on years 1998-1967
Return to first page of: this document this library (librefs) UV Software Home-Page
The skip is taken if the internal condition code (set by a prior instruction) matches the condition coded in the byte 4 (& 5 if required).
= > < ! <> => <= => <= . .. blank
The condition code would have been set by a preceding instruction (cmc,rep,scn,add,sub,mpy,div,etc).
skp?? 9 - skip a number of instrns (if cc matches)
- ?? may be any of above
skp?? tag - skip to a label/tag
| Note |
|
cmc a0(2),'25' - compare cols 1-2 to constant '25'
skp= 2 & skip next 2 instrns if cc was set '='
cmn b50(5p),b55(3p) - compare packed cols 51-55 to 56-58 in area 'b'
skp=> tagx & skip to tagx if 51-55 => 56-58
cmc a0(2),'25'
skp tag,c0(1) <--- op2 may contain the condition code
^ ^^^^^ <--- op2 present
^----------------<--- condition code on 'skp' absent
If op2 is present on the 'skp' instruction, it will be assumed to hold the condition code in 1 or 2 bytes (=, !, >=, <=)
| NOTE |
|
tag1 --- <-- valid tag
rt2 --- <-- INVALID label (only 2 alpha before numeric)
Return to first page of: this document this library (librefs) UV Software Home-Page
tst a0(1),'xyz' - test col 1 for x,y,or z
skp= hit cc set = if col1 is x,y,or z
tst r0(10),'abc' - test cols 1-10 for a,b,c
skp= all cc set = if all cols a,b,or c
skp> some cc set > if some cols match
skp< nomatch cc set < if no matches
tstl2 r0(10),'aabbcc' - test 5 x 2 byte subfields in 1-10
--- for matches to op2 2 byte subflds
| option 'l' |
|
| option 'i' |
|
condition code: = if all subflds in op1 have a match in op2
< if no matches
> if some but not all op1 subflds match an op2 subfld
instrn counter: $ci1 - counts the no of matching op1 subflds
$ci2 - counts the no of nonmatching op1 subflds
index register: x - will hold dsplcmnt of 1st match in op1 (else end op1)
y - will hold dsplcmnt of 1st match in op2 (else end op2)
u - will hold dsplcmnt of 1st nonmatch in op1 (else end op1)
'lottochk1' is listed below to illustrate using the 'tst' instruction. You can run it from /home/uvadm by entering just 'uvcopy lottochk1' & entering the 6 numbers when prompted. Or enter the 6 #s via arg1=... & take the defaults for the demo file. You might modify it for your lottery if they supply a csv file of all past winning#s.
uvcopy lottochk1,arg1=01:10:16:19:36:49 =======================================
Return to first page of: this document this library (librefs) UV Software Home-Page
# lottochk1 - check favorite#s to history file of winning#s (OT, Nov2009)
# - uvcopy job to demo the 'tst' instruction
#
# uvcopy lottochk1,fili1=tf/649.csv,filo1=tmp/649wins,arg1=01:10:16:19:36:49
# ==========================================================================
#
# "649",1,"1982-06-12",3,11,12,14,41,43,13 <-- 1st 3 lines of history win#s
# "649",2,"1982-06-19",8,33,36,37,39,41,9 - 7th # is Bonus (I ignore)
# "649",3,"1982-06-26",1,16,23,24,27,49,34 <-- my fav#s match 3 of these
#
# "649",3,"1982-06-26",1,16,23,24,27,49,19 03 <-- output if 3+ matches to arg1=
#
# field#s 4,5,6,7,8,9 are the 6 winning#s, 10th field is bonus# (I ignore)
# 'tst' - tests each op1 subfield for matches to any subfield in op2
# - sets cc = if all match, > if some match, < of no matches
# - also counts matches in $ci1 (we will use that)
# - would have been easier if win#s all zero filled 2 digits (but not)
# - we use 'fix' to split csv fields 20 bytes apart, longest is 10 (date)
# - then use 'clr' 21 bytes of area c to ':'s & 'mvn' to zero fill 2 byte#s
# - then we can 'tst' to our arg1=01:10:16:19:36:49
#
rop=r1 # Run OPtion r1 prompts for outfile disposition (reply vi,more,cat,etc)
fili1=?tf/649.csv,rcs=256,typ=LST #<-- input of BCLC win# history file
filo1=?tmp/649wins,rcs=256,typ=LSTt
@run
opn all
msga1cnw 'enter 6 2-digit#s separated by ":" colons'
mvc d0(18),$arg1 save $arg1 in area d for match
#
# begin loop to get/match/select 3+ matches to output file
man20 get fili1,a0
skp> man90
fix b0(20),a0(80),10,','
# ===
clr c0(21),':'
mvn c00(2),b060(2)
mvn c03(2),b080(2)
mvn c06(2),b100(2)
mvn c09(2),b120(2)
mvn c12(2),b140(2)
mvn c15(2),b160(2)
mvn c18(2),b180(2)
tstl3 c0(18),d0(18)
# =====
cmn $ci1,3 3+ matches ?
skp< man20
mvn a50(2),$ci1 store matches on right side
put filo1,a0
skp man20
#
# EOF - close files & end job
man90 cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
tsb data,mask - instruction format
skp= match cc set = if any bits match
tsb a0(1),x'01' - test 1st byte of area 'a' for x'01' bit
skp= odd (might be testing for an odd or even number)
"=" (equal) - if ALL bits in the mask are matched in the data byte ">" (greater than) - if SOME but not all bits in the mask match bits in data "<" (less than) - if NO bits in the mask are matched in the data byte
Return to first page of: this document this library (librefs) UV Software Home-Page
opn fili1 - open a specific file
opn all - open all files that have been declared
via the fil__, rcs,& typ functions
| register z |
|
| register u |
|
|
| register v |
|
$fstat - will store the file status structure in work area x2800(32)
(see area 'x' documentation in previous section)
- of interest only to UNIX gurus
| option e1 |
|
opne1 fili1 - open file & test if present ?
skp< nofile
Return to first page of: this document this library (librefs) UV Software Home-Page
"opn" - open file (continued)
Option 'v' for D-ISAM variable length records is specified on the file typ function, not here on the 'opn'. File 'typ' options are documented in uvcopy1.doc, but here is a brief review & example:
filo1=xxx,typ=ISFv5000,rcs=50,isk1=0(6)
This specifies max rcsz 5000 (option v on typ) & minimum rcsz 50 (on rcs=). The max rcsz option 'v' must be correct for output files but you can specify anything to indicate variable input files (v999).
After open INPUT variable length, register 'v' will hold the max rcsz.
cls fili1 - close a specific file
cls all - close all files that are open
Return to first page of: this document this library (librefs) UV Software Home-Page
get file,recordarea[,fillchar,altstopchar] - instruction format ===========================================
loop get fili1,a0(128) - example
skp> eof - cc set > at EOF
skp< locked - cc set < for ISAM locked records
--- - valid record retrieved
get fili1,a0 - record size may be omitted from get
^^^^^
record size - if omitted from the get (& put,etc), the record size
defaults from the 'rcs' parameter on the file declaration
- record size specified on the 'get' will override the 'rcs'.
- record size may depend upon file type
| LST |
|
| RSF/RST |
|
| ISF |
|
| DIR |
|
| RSV |
|
| IDX |
|
| fillchar |
|
| altstopchar |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
The condition code set greater than '>' at end of file. uvcopy also stores '~EOF' in the 1st 4 bytes & fills the rest to '~'s. This is not usually required, but sometimes useful for more complex jobs that still have processing to do at EOF.
The condition code is set '<' for locked records if option 'l4' is coded for ISAM files. You may also code option 'w' (wait, default w1, 1 second) & opion 'r' (retries, default r8, 8 times). These options more commonly used on the random read instruciton 'red'.
fili1=dat1/custmast,typ=ISFl4,rcs=256 #<-- must code option l4 on typ=ISFl4 =====================================
getr getl4w1r8 fili1,a0
skp= ok
skp> eof
# cc < (locked record) - prompt for retry
msgw 'locked record - enter to retry'
skp getr
fili1=dat1/custmast,typ=ISFl4,rcs=256 #<-- must code option l4 on typ=ISFl4 =====================================
| l4 (typ=ISFl4) |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
fili1=dat1/test100,typ=LST,rcs=80 #<-- following options apply to typ=LST =================================
get fili1,a0 <-- normal get instruction
===================== - options default as shown below
gete1s2 fili1,a0 <-- default options 'e1s2'
========****=========
| c1 |
|
| c2 |
|
| c4 |
|
| c4 |
|
| d1 |
|
| d2 |
|
| d4 |
|
| d8 |
|
| e1 |
|
| e2 |
|
| e4 |
|
| e8 |
|
| m1 |
|
| m2 |
|
| m0 |
|
| n1 |
|
| s1 |
|
| s2 |
|
| s4 |
|
| s8 |
|
| t1 |
|
| t2 |
|
| t4 |
|
| t8 |
|
| e1s2 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
There are also some related 'file options' specified on the file "typ" function. See file typ options in uvcopy1.doc or uvcopy2.doc.
Some examples of file typ options relevant to the 'get' are:
| typ=LSTm2000 |
|
| typ=RSFu |
|
Op3 is the record area pre-fill character (default blank usually OK). Used for more complex jobs such as 'unws2' (unwordstar) which reads the file as blocks of binary characters. unws2 specifies the fill character as x'00' which is squeezed out (would occur in short block at EOF)
Register 'z' & 'v' will hold the return code from the get instruction. This is usually the record size (or -1/0 on EOF/error) Register 'z' or 'v' might be used when processing a file as fixed blocks (vs linefeed terminated or fixed record size). For mag tape register 'z' or 'v' would be used to get size of partial block at EOF (for example see the 'unws1' job in UVjobs2).
Register 'v' will hold the record size of the record just read.
If you were copying variable length records, you would specify this value on the 'put' instruction, for example:
get fili1,a0(9999) - don't need to specify lth on get
# (but area a must be allocated big enough)
# - get stores rcsz in rgstr 'v'
put filo1,a0($rv9999) - rgstr v specifies size to be written
# (to maximum of 9999)
For variable length output, the last input record size will automatically be used if the output record size is omitted. This is most useful for typ=IDXf3v & typ=IDXf8v.
put filo1,a0 - op2 length omitted uses $rv
- probably from last get
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# recsizes1 - create summary table of record-sizes in a text file
# - by Owen Townsend, June 6, 2007
# - demonstrates uvcopy registers & instructions
# $rv - register 'v' holds record-size from last 'get' instruction
# tbl - build table in memory (summary count for each record-size)
# rbp - dumps table to output file at EOF
# rop=r1x2 - prompts for outfile disposition, default x2=more
#
# uvcopy recsizes1,fili1=dat1/customers,filo1=tmp/custrecsizes
# ============================================================
# ** sample report **
#
# recsizes1 2007/06/07_13:54:02 summary of record-sizes in: dat1/customers
# tbl#001 pg#001 -argument-
# line# count % record-size
# 1 1 3 0079
# 2 10 31 0086
# 3 2 6 0098
# 4 19 59 0102
# 32*100 *TOTAL*
#
rop=r1x2 # option r1=display outfile at EOJ, x2=more (default command)
was=a8192 # increase area 'a' to allow recsizes up to 8192 bytes
fili1=?infile,rcs=8192,typ=LST
filo1=?recsizesummary,rcs=128,typ=LSTt
@run
opn all
#
# begin loop to get records & table record-size, until EOF
# - 'get' instrn stores binary recsize in rgstr 'v' ($rv)
# - use 'mvn' to convert binary $rv to 4 numerics for table argument
man20 get fili1,a0(8192) get next record
skp> man80
mvn c0(4),$rv store recsize in digits
tblt1 c0(4),'record-size' build table of record-sizes
# =====
skp man20 return to get next record
#
# EOF - dump table to outfile, close files & end job
man80 tbpt1v1 filo1,'summary of record-sizes in: $fili1'
# =====
cls all
eoj
loop get fild1,d0(80) - get record from a directory
skp> eof - cc set > at EOF
skp< loop - cc set < if not an ordinary file
(probably a subdirectory)
--- - process ordinary file
skp= - cc set = on ordinary file
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
put file,recordarea[,fillchar][,altstopchar] - instruction format
=============================================
put filo1,b0(128) - write to output file #1 from area 'b'
- writes 128 bytes if file typ=RSF or RST
- max 128 bytes if typ=LST (depends on 1st LineFeed)
- if Indexed, record size depends on rcs=
put filo1,b0($rx128) - lth determined by rgstr x max 128
putb filo1,b0(80) - option 'b' to blank after
putl2 filo1,h0(128) - option 'l2' multi-line write in 1 put
- see options on the next page
putl1 filo1,x'0C' - write a formfeed control character
- illustrates op2 constant possible
& option l1 to prevent usual linefeed
put filo1,b0 - record size may be omitted from the 'put'
^^^^^
| Note |
|
| record size |
|
| RSF |
|
| RST |
|
| LST |
|
| ISF |
|
| RSV |
|
| IDX |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
put filo1,b0 <-- normal put instruction
================ - options default as shown below
putt2 filo1,a0
== <-- default options for UNIX
putt3 filo1,a0
== <-- default options for Windows/DOS
| b |
|
| b1 |
|
| b2 |
|
| c1 |
|
| c2 |
|
| c4 |
|
| c4 |
|
| l2 |
|
| m1 |
|
| n |
|
| s1 |
|
| s2 |
|
| s4 |
|
| s8 |
|
| t1 |
|
| t2 |
|
| t4 |
|
| t8 |
|
| t3 |
|
| Note |
|
| typ=LSTd1 |
|
| typ=LSTd2 |
|
| typ=LSTd3 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
There are also some related 'file options' specified on the file "typ" function. See file typ options in uvcopy1.doc or uvcopy2.doc
Some examples of file typ options relevant to the 'put' are:
| typ=LSTt |
|
| typ=LSTw2 |
|
| typ=LSTd1 |
|
| typ=LSTd2 |
|
| typ=LSTd3 |
|
| Note |
|
Register 'z' & 'v' will hold the return code from the put instruction. This is usually the record size, but would be -1 or less than rcsz if an error occurs.
Return to first page of: this document this library (librefs) UV Software Home-Page
| Note |
|
| IDXf1 |
|
| IDXf3 |
|
| IDXf8 |
|
| v9999 |
|
| x |
|
| x1 |
|
| x2 |
|
| y |
|
| y1 |
|
| y2 |
|
| y4 |
|
| y8 |
|
If output record size is explicitly specified on op2 of the 'put' instruction, then the variable length record will be written with that record size.
But if op2 of the 'put' is not specified, then the record size will be taken from register 'v' ($rv), which is probably the last input record size since the 'get' instruction stores the record length in $rv.
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
The 'put' instruction may specify the length of the variable length record to be written. This is usually done by a register in the length of operand 2 on the put instruction.
If you were copying variable length records, the 'get' instruction stores the length of the last record read in register 'v', so you might use the following coding:
get fili1,a0(9999) - don't need to specify lth on get
# (but area a must be allocated big enough)
# - get stores rcsz in rgstr 'v'
put filo1,a0($rv9999) - rgstr v specifies size to be written
# (to maximum of 9999)
As of May 2007, the last input record size will automatically be used if the output record size is omitted. This is most useful for IDXFORMAT3 & 8.
put filo1,a0 - op2 length omitted uses $rv
- probably from last get
Note that typ=ISF Variable length Indexed files are NOT commonly used. The more popular type of Variable length files is typ=RSV or typ=IDXf3/IDXf8 which are compatible with Micro Focus COBOL IDXFORMAT3/IDXFORMAT8 files.
See discussion & example on the next page --->
Return to first page of: this document this library (librefs) UV Software Home-Page
typ=RSV & typ=IDXf3/IDXf8 provide compatibility with Micro Focus COBOL Variable length files. Note that typ=IDX (Indexed Variable) is provided by an alternate version of uvcopy, 'uxcopy' which is linked with Micro Focus EXTFH. You should first study the detailed documentation for typ=RSV files on pages 'I1' to 'I3' of uvcp.doc to understand this file type.
# RSVtest2 - test Record Seqntl Variable (typ=RSV) file I/O Dec 2002
# - compatible with Micro Focus COBOL IDXFORMAT3
#
# typ=RSV can read an IDXFORMAT3 Indexed file in Sequential mode
# - can be used on uvcopy,uvsort,etc (vs uxcopy,uxsort,etc that support IDX)
# (IE - can be used at sites that don't have Micro Focus COBOL)
#
# On filo1 below, rcs=254 specifies max, v option of typ=RSVv64 specifies min
# - record size for each record is determined by scanning back for last
# nonblank & rounding up to multiple of 4 (considering the 2/4 byte rechdr).
#
fili1=?dat1/testIDXf3.dat,rcs=512,typ=RSV
filo1=?tmp/testrsv2,rcs=254,typ=RSVv64
# filo1=?tmp/testrsv2,rcs=254,typ=LSTt #<-- optional text file output
@run
opn all
#
# begin loop to get/put records until EOF
man20 get fili1,a0 get next record
skp> eof (cc set > at EOF)
mvc b0(512),a0 copy input area to output area
put filo1,b0 writes variable lth (see NOTE below)
skp man20
#
# EOF - close files & end job
eof cls all
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
for Unix type files - usually with fixed record sizes
(use the 'set' instrn for keyed Indexed files)
relr fili1,50 - set rel rec# 50 of fili1
relr fili2,r20(5z) - set rel rec# to the value in 21-25
relb fili4,68 - set to rel byte# 68 of fili4
# reldemo1 - demo 'rel' instruction to update in place by relative record#
# - by Owen Townsend, UV Software, May 22/2008
#
# Demo will update specified rec# with '*updated*' in bytes 70-78
# - will prompt for record# to be updated, for example:
# - enter n2 at the prompt to update rec#2 (3rd record since zero relative)
#
# 1. cp /home/uvadm/dat1/custmas1 tmp/ <-- copy demo file to tmp
# 2. uvcopy reldemo1,filr1=tmp/custmas1 <-- run demo job
# 2a. --> n2 <-- - enter n2 to update 3rd record in the file
# 3. uvhd tmp/cm1 r256 <-- examine results, browse forward
# - ensure specified record updated
# Relative record numbers are zero relative (not 1 as per COBOL)
# In code below:
# - 1st 'relr' sets fileptr & 'get' reads the record
# - 2nd 'relr' is REQUIRED to reset fileptr to spcfd record
# (since get advances fileptr to next record)
#
opr='$jobname - demo rel instrn to update randomly by record#'
opr='- using custmas1 demo file, 256 byte records'
opr='- will update specified record# with "*updated*" in bytes 70-78'
opr='uop=n0 - record# to update, n0 would update 1st record in file'
opr=' n10 - update rec#10(0 rel) rec#11(1 rel) (offset 10*256=2560)'
uop=q1n0 # option defaults
filr1=tmp/custmas1,rcs=256,typ=RSF
@run
opn filr1 open the file
relr filr1,$uopbn set file ptr to spcfd rec#
get filr1,a0(256) get the record into area 'a'
relr filr1,$uopbn re-set file ptr to spcfd rec#
mvc a70(9),'*updated*' update the record
put filr1,a0(256) re-write the record
cls filr1 close the file
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# copy1r - copy a fixed record size file from a specified record#
# - using the 'rel' instruction to set the file pointer
opr='$jobname - copy a fixed record size file from a specified record# '
opr='uop=q1r040b0c999999 - option defaults'
opr=' r040 - record size'
opr=' b0 - begin copy at record #0 (1st record by default)'
opr=' c999999 - copy 999999 records (all recs in file)'
uop=q1r40b0c999999 # declare option defaults
was=a8192b8192 # increase max I/O sizes areas a & b
fili1=?tf/test100,typ=RST,rcs=8192 # default input may be used for test
filo1=?tmp/$fili1,typ=?RST,rcs=8192 # default output will be tmp/test100
@run
mvn $fili1+224(4b),$uopbr store input file rcsz from option r
mvn $filo1+224(4b),$uopbr store output file rcsz from option r
opn all open files
#-------------------------------
relr fili1,$uopbb set begin copy relative record#
#-------------------------------
mvn $rr,$uopbr store rcsz in rgstr r for get/mvc/put
# begin loop to copy records until EOF
loop get fili1,a0($rr8192) get rec (rcsz in rgstr r max 8192)
skp> eof
mvc b0($rr8192),a0 move to out area lth rgstr r max 8192
put filo1,b0($rr8192) write record to output file
add $ca1,1 count records
cmn $ca1,$uopbc reached copy count ?
skp< loop
# reached end record# or EOF - close files & end job
eof cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
"rtb" reads a table of data into the op2 area from the op1 file (must execute after the files are opened).
rtb fili2,k0(80),k0(40) - read fili2 & store the 1st 40 bytes of record
in 1st 40 bytes of 80 byte table entries
(might later add other info on right ?)
- continues until end of file, or until
a record is found with '~~' col 1 & 2
skp< toobig - cc set < if area too small for file
skp> eof - cc set > if eof before col1 eod
rtb fili2,k0(80),k20(40),'~','~'
- store bytes 20-59 of each record in 1st 40 bytes
of each table entry
- illustrates the '~' defaults for op4/op5
(stop read & end table markers - see below)
| op1 |
|
| op2 |
|
| op3 |
|
| op4 |
|
| op5 |
|
The 'rtb' instruction is similar to the 'lod' function but since it is an instruction rather than a function it is executed at '@run' time vs setup time & may be executed several times rather than just once as are all functions.
The table data file usually has '~~' in col 1&2 of last record to mark the end of the table. The 'lok' lookup instrn is ended by 2 '~' tildes or by 2 x'00's in 1st 2 bytes of any entry.
"rtb" now (as of June99) respects the file type declared on the fili? fili1=xxx,rcs=80,typ=LST fili1=xxx,rcs=256,typ=RSF
Previously the file was assumed to be typ=LST. This change allows us to read fixed length records without LineFeeds, and to table just the 1st part of longer records.
Return to first page of: this document this library (librefs) UV Software Home-Page
| option b1 |
|
| option c1 |
|
| option c2 |
|
| option d |
|
| option e |
|
note - any existing '~~' record in the file ends table loading
but this record is not stored in the table
- A '~~' entry will then be generated unless you specify
option 'e' to exclude it
| option m1 |
|
option m2 - inhibit stop read on FormFeed (inhibit End of Line action)
m0 - default treats FormFeed like LineFeed (End of Line)
| option t1 |
|
instrn counter $ci1 - counts lines loaded into the op1 area
| registers |
|
|
rtbz2 fili1,bt0(20),bt0(20) - load area b with file #1
rtb fili2,bt0(20),bt0(20) - append data from file #2
- starting at displacement in rgstr t
|
|
Return to first page of: this document this library (librefs) UV Software Home-Page
We will demo 'rtb' by tabling a product master file & then looking it up by product code to extend a sales item file using the product master price & description.
product# Description unit-price ===================================== BBQ010 BAR-B-Q 0019500 CHR015 LAWN CHAIR 0004500 HAM010 CLAW HAMMER 0000950 HAM020 BALLPEEN HAMMER 0001200 HAM035 JACK HAMMER 0029500 SAW011 HAND SAW 0001975 SAW012 RIP SAW 0002500 SAW051 POWER SAW 0008500 TAB012 LAWN TABLE 000850W
cust# slsmn date invoice# product quantity ============================================ 130140 44 960802 IN111001 HAM010 000010 130140 44 960802 IN111001 CHR015 000020 139923 21 970802 IN111002 HAM020 000030 139923 21 970802 IN111002 TAB012 000040 139923 21 970807 CR5421 SAW051 000050 250825 44 980804 IN1122 HAM035 000060 250825 44 980804 IN1122 PLN012 000070 401210 21 990816 CR955 HAM010 000080 401210 21 990816 IN441 SAW011 000090
cust# slsmn date invoice# product quantity price amount product-dscrptn ================================================================================ # 130140 44 960802 IN111001 HAM010 000010 0000950 000009500 CLAW HAMMER # 130140 44 960802 IN111001 CHR015 000020 0004500 000090000 LAWN CHAIR # 139923 21 970802 IN111002 HAM020 000030 0001200 000036000 BALLPEEN HAMMER # 139923 21 970802 IN111002 TAB012 000040 0000850 000034000 LAWN TABLE # 139923 21 970807 CR5421 SAW051 000050 0008500 000425000 POWER SAW # 250825 44 980804 IN1122 HAM035 000060 0029500 001770000 JACK HAMMER # 250825 44 980804 IN1122 PLN012 000070 # 401210 21 990816 CR955 HAM010 000080 0000950 000076000 CLAW HAMMER # 401210 21 990816 IN441 SAW011 000090 0001975 000177750 HAND SAW
See the uvcopy job listed below:
Return to first page of: this document this library (librefs) UV Software Home-Page
# demortb1 - demonstrate 'rtb' instruction (May 27/2009)
# - load product master file into memory table at begin job
# - extend sales items by looking up product master for price & dscrptn
# - see doc & test file lists at www.uvsoftware.ca/uvcopy3.htm#rtb
# - you can run from /home/uvadm/ as follows:
#
# uvcopy demortb1,fili1=dat1/sales5,fili2=dat1/prodmas1,filo1=tmp/sales5x
# =======================================================================
# uvcopy demortb1 - same as above (files default as shown)
# ===============
#
rop=r1 # option to prompt for output file disposition (vi,cat,lp,etc)
was=p40000 # product table in area 'p' 1000 * 40 bytes/entry
fili1=dat1/sales5,rcs=80,typ=LST # sales item file
fili2=dat1/prodmas1,rcs=80,typ=LST # product master file
filo1=tmp/sales5x,rcs=80,typ=LSTt # output items extended w price/dscrptn
@run
opn all open all files
rtb fili2,p0(40),p0(40) read product master into memory area 'p'
# ===
# begin loop: read sales items, extending with price & dscrptn from table lookup
man20 get fili1,a0 read next sales item record
skp> man90 (cc set > at EOF)
mvc b0(80),a0 copy input to output area
lokz1 pp0(40),pp0(6),a30(6) lookup table by product code
# ===
skp! man30 (cc unequal if nomatch)
mvn b45(7),pp30(7) price from table
mvn b53(9),pp30(7) price to amount for extension
mpy b53(9),b38(6) master price * item qty = amount
mvc b63(16),pp9 product dscrptn from table
man30 put filo1,b0 write output
skp man20 return to get next record
# EOF - close files & end job (rop=r1 prompts to show output file)
man90 cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
Write a table of data out to a file (opposite of the 'rtb' instruction).
wtb filo1,b0(80),b0(80) - write op2 table to op1 file until an entry
is found whose 1st 2 bytes match the 1st byte
of op4 (which defaults to a '~')
or until x'00' found in 1st 2 bytes
wtbm1 filo2,m0(80),m20(60),x'0C' - write out 60 byte records from the 80
byte entries in area m until we find an
entry with x'0C' in 1st byte
- option m1 specifies just 1 op4 character
required to mark end of table
wtbm1 filo2,bb0(80),bc20(60) - write out entries from area 'b' offset
by the displacement in rgstr 'b', until
we reach a displacement > rgstr 'c'
| op1 |
|
| op2 |
|
| op3 |
|
| op4 |
|
| op5 |
|
| op6 |
|
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| option b1 |
|
| option d |
|
| option e |
|
| option m1 |
|
| option n1 |
|
| Instrn ctr $ci1 |
|
--- different possible file types ---
filo2=xxx,rcs=80,typ=LSTt <-- text file with LF after last nonblank
filo2=xxx,rcs=80,typ=LST <-- text file with blank fill to rcsz+LF
filo2=xxx,rcs=80,typ=RSF <-- fixed length records with NO LineFeeds
filo2=xxx,rcs=80,typ=RST <-- fixed length records with LF in last byte
wtb filo1,b0(80),b0(80)
As of June 99, wtb respects the file type & rcsz declared on the filo_. This replaces option 't1' which previously indicated text with LF after last nonblank.
Return to first page of: this document this library (librefs) UV Software Home-Page
mvc c60(6),'SMITH' - store key value desired
in proper position in record area
setk2m7 filr1,c0 - select key 2 & set ptr to rec whose
key is = or > than value stored
skp= found cc set = if record found & no err
skp! nofind cc set not= if no matching record found
setk3m0 filr1,d0 - select key 3 & set file ptr to the
beginning of file
set filr1,d0(200) - record size may be specified
set filr1,d0 - or omitted (recommended)
^^^^^
'set' will change the current record position (file pointer) to the key value stored in the record area. See option 'm' below which determines the comparison between the key value & the record position set.
The set instruction would usually be followed a 'redm7' (read => key value) instruction to read the record contents pointed to by the set. Or you might use a code loop of 'redm2' (read next) instructions to read a series of sequential records (the series might be ended by a change in the high part of the key such as customer#, etc)
option 'k' used to set key of reference (default 1).
option 'l' to set key on less than full key length.
setk3m7l3 filr1,d0 - would set key#3 => than 1st 3 bytes of
key value stored in area d
option 'm' (or cc) used to indicate file position desired
m0 - 1st record in file
m1 - last record in file
m5 - record whose key = key stored in record area
m6 - record whose key > key stored in record area
m7 - record whose key => key stored in record area (default)
option 'e1' - errmsg if 'set' instruction fails (for the specified key)
'e3' - also wait for reply (null to continue, or interupt to kill job)
- option e1/e3 can save having to test condition code after 'set'
Return to first page of: this document this library (librefs) UV Software Home-Page
mvc r10(6),c'123456' - store key of record to be read
in proper position in record area
redm7 filr1,r0 - read rec whose key => stored key
skp= found cc set = if record found & no err
skp! nofind cc set not= if no matching record found
redk2m5 filr1,r0 - set key#2 & read equal
skp= found cc set = if key= record found
--- ------- code here for key not found (cc not=)
redm2 filr1,r0(200) - read next record (sequentially)
(probably after redm7 read by key =>)
- record size (200) should be omitted
The record size should be omitted from I/O instructions. For Indexed files the record size is determined when the file is created.
A 'red' is often preceded by a 'set' as described on the previous page. The record read by the 'red' instruction depends on option 'm' as follows:
option 'm' - used to indicate type of read desired
m0 - 1st record in file
m1 - last record in file
m2 - next record (from current position)
m3 - previous record
m4 - current record (use after set by key)
m5 - record whose key = key stored in record area
m6 - record whose key > key stored in record area
m7 - record whose key => key stored in record area (default)
option 'k' - select key of reference
k1 - default
k2 - select key#2
..
k9 - select key#9
option 'e1' - errmsg if 'red' instruction fails (record not found for key)
'e3' - also wait for reply (null to continue, or interupt to kill job)
- option e1/e3 can save having to test the condition code after
the 'red' instruction (see skp= or skp! coding above)
Return to first page of: this document this library (librefs) UV Software Home-Page
filr1=dat1/custmast,typ=ISFl4,rcs=256 #<-- must code option l4 on 'typ=ISFl4' ===================================== - to allow record lock optns on 'red'
read redm5l4w1r8 filr1,c0
skp= ok
skp> eof
# cc < (locked record) - prompt for retry
msgw 'locked record - enter to retry'
skp read
| option l4 |
|
| option w# |
|
| option r# |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
wrt filr1,b0 - write record b0(rcsz) to filr1
skp= ok cc set = if no errors
skp! dup cc set not= if duplicate key
(record already exists)
wrt filr1,d0(200) - record size may be specified
set filr1,d0 - or omitted (recommended)
^^^^^ - defaults to rcs= on filr1= declaration
The data record to be added must be stored in the op2 area. The record will be added to file & all key indexes updated. uvcopy does not allow duplicates on the primary key and will display a warning, but allow you to continue (dropping the duplicate record).
The current record position in file is not changed; you could be sequentially processing 1 area of a file & perform a write by key anywhere else in the file & not lose your sequential position.
The record size should be omitted from I/O instructions. For Indexed files the record size is determined when the file is created.
option 'e1' - errmsg if 'set' instruction fails (if record already exists)
'e3' - also wait for reply (null to continue, or interupt to kill job)
- option e1/e3 can save having to test the condition code after
the 'wrt' instruction (see skp= or skp! coding above)
Return to first page of: this document this library (librefs) UV Software Home-Page
upd filr1,r0 - update record r0(rcsz) in filr1
skp= ok cc set = if no errors
skp! nofind cc set not= if record not found
The record to be updated must be stored in the op2 record area and must already exist. The primary key is used to access & rewrite the record. uvcopy does not allow duplicates on the primary key.
'upd' is often preceded by a 'red' to determine whether the keyed record is already onfile or not. If not onfile you could use a 'wrt' to add it. The following example assumes a detail file (fili1) is read sequentially into area 'a' & used to update a master file (filr2) using area 'b'.
The following example codes 'Record Lock' option 'l4' on 'redm5l4' & 'updl4', and is only required if there could be 2 jobs processing the same records at the same time. The 'filr2' ISAM must be declared as 'typ=ISFl4'.
fili1=dat1/cusupdts,typ=LST,rcs=128 #<-- updating records (test file)
#==================================
filr2=dat1/custmast,typ=ISFl4,rcs=256 #<-- ISAM file to be updated
#==================================== - must code option l4 on 'typ=ISFl4'
- to allow record lock optns on 'red'
loop get fili1,a0 might get updating records from a seqntl file
skp> eof ('fili1' vs 'filr2' below for ISAM file)
mvc b0(80),a0 store record with key (cust#, etc) to read
redm5l4 filr2,b0 read key=
skp= updt
wrt filr2,b0 write new record
skp loop
#
updt mvc b10(30),a10 modify master record (description, etc)
updl4 filr2,b0 update (rewrite) the updated record
skp loop
The 'red' before 'upd' is not necessary if there is no master data in the record that needs to be preserved (data not in the updating detail records). In this case, you can simply replace the entire record or insert if not already on file. The 'upw' instruction (see 3 pages ahead) makes this case easy since it combines the functions of 'upd' & 'wrt'.
The current record position in file is not changed; you could be sequentially processing 1 area of a file & perform an update by key anywhere else in the file & not lose your sequential position.
Area 'u' will hold the record image as it was before the update (in case it is of any value to the programmer).
option 'e1' - errmsg if 'upd' instruction fails (record not found for key)
'e3' - also wait for reply (null to continue, or interupt to kill job)
- option e1/e3 can save having to test the condition code after
the 'upd' instruction (see skp= or skp! coding above)
| option 'l4' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
Please see a separate section uvcopy6.htm that documents several uvcopy & uxcopy jobs to test/demo updating random Indexed files (illustrating: set, wrt, upd, upw, del).
uvcopy is used for typ=ISF Fixed length Indexed records (C-ISAM, IDXFORMAT1). uxcopy is used for typ=IDXf3/f8 Variable length Indexed MF COBOL IDXFORMAT3/8.
uvcopy6.doc uses a product master file & a product detail update file to illustrate the test/demo jobs. The test files are listed before & after updates. You are encouraged to run these jobs & verify your results.
| produpISF1 |
|
| produpIDX2 |
|
The following 2 jobs are provided to test manual record locking, using option 'l4' on filr1 typ=ISFl4, redl4,& updl4. See the 2 jobs documented & listed begining at 'uvcopy6.doc#Part_3'
| ISFlock1 |
|
| ISFlock2 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
upw filr1,r0 - update record r0(rcsz) in filr1
skp= updted cc set = if existing record updated
skp< inserted cc set < if new record inserted
skp> error cc set > if any other condition error
(or program may be aborted depending on err)
'upw' combines the functions of 'upd' & 'wrt'. upw will update the record if the key already exists, otherwise it will insert(write) a new record. 'upw' makes the coding simpler (can omit condition code testing), when you don't have to care whether the record is already present or not.
The record to be updated must be stored in the op2 record area and may or may not already exist. The primary key is used to access & rewrite the record. uvcopy does not allow duplicates on the primary key.
Note that 'upw' can be used only when the detail updating records contain all fields possible in the master records. 'upw' can not be used when the master file record contains fields which must be preserved. For example see job 'produpISF2' in 'uvcopy6.doc' where the master file contains YTD sales history fields & the updating detail records contain only the new product description & price (& the product# key of course).
The current record position in file is not changed; you could be sequentially processing 1 area of a file & perform an update by key anywhere else in the file & not lose your sequential position.
Area 'u' will hold the record image as it was before the update (in case it is of any value to the programmer).
Return to first page of: this document this library (librefs) UV Software Home-Page
del filr1,r0 - delete record r0(rcsz) in filr1
skp= ok cc set = if no errors
skp! nofind cc set not= if record not found
The key of the record to be deleted must be stored in its proper location in the op2 record area & the record must already exist. uvcopy does not allow duplicates on the primary key.
The current record position in file is not changed; you could be sequentially processing 1 area of a file & perform an delete by key anywhere else in the file & not lose your sequential position.
Area 'u' will hold the record image as it was before the delete (in case it is of any value to the programmer).
option 'e1' - errmsg if 'del' instruction fails (record not found for key)
'e3' - also wait for reply (null to continue, or interupt to kill job)
- option e1/e3 can save having to test the condition code after
the 'del' instruction (see skp= or skp! coding above)
Return to first page of: this document this library (librefs) UV Software Home-Page
lck fili1 - lock a D-ISAM file
lck filr1 (for input or random files)
| Note |
|
ulk fili1 - unlock a D-ISAM input/random file
Return to first page of: this document this library (librefs) UV Software Home-Page
msg 'constant' - constant format
msg op1dsp(op1lth) - area address format
msgw 'enter date' - option w wait for reply
msgl2 'error bad record',b0(80) - option l2 for 2 lines out
msgwy 'stopped beating wife y/n ?' - option y forces y/n resp
| option w |
|
| option y |
|
| option n |
|
| option b |
|
option l1 - insert 1 blank character before 2nd part of msg
l2 - insert 1 LF before part 2 (2 line msg)
l4 - insert a 2nd LF before part2 (double spaced msg)
l8 - insert a LF before 1st part (space before msg)
option t1 - terminate part2 with 1 blank character
t2 - terminate part2 with an LF (space after msg)
t4 - inhibit the default LF after part2
t8 - inhibit the NULL insert after last nonblank
| option j |
|
| option a |
|
| option c |
|
| option j1 |
|
| Note |
|
| register x |
|
condition code: "<" if null or blank reply made
"=" if 1st letter of reply is a 'y'
">" if any other nonblank reply
Return to first page of: this document this library (librefs) UV Software Home-Page
loop msgwa1 'enter your search pattern'
cmn $ch1,0 any data entered ? (including blanks)
skp= loop no - repeat request loop
mvc ----,$arg1 yes - store data entered
option 'a' specifies the area where the reply data will be stored
msgwa0 - reply data stored in $arg0 or y1000(100) & length in $ch0
(same as $reply)
msgwa1 - reply data stored in $arg1 or y1100(100) & length in $ch1
msgwa2 - reply data stored in $arg2 or y1200(100) & length in $ch2
-etc- - - - etc - - -
msgwa9 - reply data stored in $arg9 or y1900(100) & length in $ch9
| Note |
|
| Note |
|
uvcopy scan1d,fild1=cobols,arg1=xxx,arg2=yyy,arg3=zzz
=====================================================
The uvcopy job can test $arg1 or $ch1 to see if the operator had entered the data on the command line, & if not prompt for the data via the 'msgwa1' instruction. Option 'a1' means the data will be in the same place regardless of whether entered on the command line or in response to the msgwa1 prompt.
| option 'c' |
|
msgwa1c 'enter data ...'
^
Option 'c' tests the data length stored in the $arg area, & suppresses the prompt if non-zero. This saves you from having to code the following:
cmn $ch1,0 any data stored in the $arg1 area ?
skp> 1 yes - bypass the prompt for entry
msgwa1c 'enter data ...'
Return to first page of: this document this library (librefs) UV Software Home-Page
option x1 - convert line1 data to hex representation
x2 - convert line2 data to hex representation
x3 - convert both line1 & line 2 to hex rep ('x_' defaults to x3)
# testmsgx1x2 - test option x1/x2 convert to hex rep Sep10/08
@run
mvf a0(24),'testmsgx1x2'
msgx1 a0(24),'<--testmsgx1x2'
msgx2 'testmsgx1x2-->',a0(24)
mvn $ra,123456789
msgx2v1 'register a \$ra = $ra, hex value = ',x0(4b)
mvn $rb,513
msgx2v1 'register b \$rb = $rb, hex value = ',x4(4b)
eoj
uvcopy testmsgx1x2 <-- execute demo job (/home/uvadm/pf/adm/testmsgx1x2) ================== - observe output below:
746573746D736778317832<--testmsgx1x2
testmsgx1x2-->746573746D736778317832
register a \$ra = 123456789, hex value =15CD5B07
register b \$rb = 513, hex value =01020000
Return to first page of: this document this library (librefs) UV Software Home-Page
can 'error - program cancelled',99
'can' displays a msg to stdout if coded in op1. op2 is an optional exit code (dflt 99)
| option j |
|
| option v1 |
|
| Note |
|
'eoj' closes all files that are open & exit with users exit code (op1).
eoj [exitcode]
Return to first page of: this document this library (librefs) UV Software Home-Page
tim 0 - if no operands (or op1 0), tim gets the current
date/time & stores in $date2,$time2,& $datetime2
tim g0(4b) - if op1 is a 4 byte area, it is assumed to contain
a UNIX time, which will be stored in $time2
& converted into $date2 & $datetime2.
The 'tim' instruction stores the date & time in work area 'y' as follows: (use the $symbolic addresses but the actual locations are also given).
$date2 - y40(14) - yyyymmddhhmmss $time2 - y56(4b) - binary long (unix time - seconds since 1970) $datetime2 - y60(19) - yyyy/mm/dd_hh:mm:ss
Note that these areas are initially set to the uvcopy program startup time (even if no 'tim' instruction is executed). The uvcopy program startup time is always available in the folowing areas:
$date1 - y00(14) - yyyymmddhhmmss $time1 - y16(4b) - binary long (unix time - seconds since 1970) $datetime1 - y20(19) - yyyy/mm/dd_hh:mm:ss
Examples of using 'tim' & the stored values:
tim - get current date/time
msg $datetime2 - display date & time string ccyy/mm/dd:hh:mm:ss
tim a8(4b) - convert date/time stamp in TIPix JOURNAL file
mvc b64(19),$datetime2 - store result in the output record
- used by 'tipjrnx2' (see TIPjobs.doc vol 3)
wat 60 - wait 60 seconds
--- then proceed to next instruction
wat $ra - wait the number of seconds in register 'a'
Return to first page of: this document this library (librefs) UV Software Home-Page
bal subr3 - bal to subr3
--- - returns here via 'ret' instrn which
must be coded at end of subroutine
subr3 --- - the subroutine coded elsewhere (at end)
---
ret - return to instrn following the bal
| Notes |
|
If op2,op3,&/or op4 are coded, the data will be moved to work area 'w' for use by the subroutine & stored as follows:
op2 data (if <= 200) ----> stored at w0(200) & blank right filled op2 data (if > 200) ----> stored at w0(max 4000) op3 data (if declared) --> stored at w200(200) & blank right filled op4 data (if declared) --> stored at w400(200) & blank right filled
bal subr - bal op2/op3/op4 optional
work area 'w' unchanged if op2 omitted
bal subr,a0(80) - op2/op3/op4 may be area addresses
bal subr,'abc' - or constants
bal subr,a0(80),b0(50),'xxx' - or any combination
The effect of the instructions above is the same as if the bal instruction were preceded by 'mvf' instructions:
[ mvf w0(200),a0(80) ]
[ mvf w200(200),b0(50) ]
[ mvf w400(200),'xxx' ]
bal subr2
Also note that op2 may be up to 4000 bytes (op3 & op4 would be omitted)
[ mvf w0(4000),a0(4000) ]
bal subr2
Return to first page of: this document this library (librefs) UV Software Home-Page
Here is a practical example of a 'bal' subroutine. This could be useful for Year 2000 bridge programs where you need to compare 2 dates using the windows technique of inferring the century from the 2 digit year.
# cymd - uvcopy subrtn to compare 6 digit dates windowing at 1940
# - returns with cc set < = > for skp? testing by calling mainline
#
# bal cymd,a50(6),d0(6) - example of use
# skp< xxx - subrtn sets cc <=>
#
#note - bal instrn stores op2 & op3 at w0(max200) & w200(max200)
#
#logic- we will prefix 2 dates with '19'
# - then change to 20 if year is < '40'
#
cymd mvc w100(6),w0 move op2 to allow prefix
mvc w098(2),'19' prefix op2 with century 19
cmc w100(2),'40' check op2 for 19 or 20 century ?
skp=> 1
mvc w098(2),'20' change op2 century to 20
#
mvc w198(2),'19' prefix op3 with century 19
cmc w200(2),'40' check op3 for 19 or 20 century ?
skp=> 1
mvc w198(2),'20' change op3 century to 20
#
cmc w098(8),w198 compare dates & set cc for return
ret return with cc set < = >
| Note |
|
| Your assignment |
|
| NOTE |
|
cmcy a50(6),d0(6) - compare 2 dates using window 1950 default
Return to first page of: this document this library (librefs) UV Software Home-Page
Subroutines allow a group of instructions to be coded once & executed from several points in the prmfile (may be nested up to 10 deep).
bal subr3 - bal to subr3
--- - returns here via the 'ret' instrn
subr3 --- - the subroutine code (elsewhere in program)
---
ret - return to instrn following the bal
The 'ret' instruction may optionally specify the condition code which would tested in the calling subroutine. This is a convenient way of passing some information back to the caller.
ret< - would return with the condition code '<'
ret= - would return with the condition code '='
ret> - would return with the condition code '>'
ret - would return with the condition code unchanged
by the 'ret' instruction
- the condition code would remain as set by some
previous instruction.
Return to first page of: this document this library (librefs) UV Software Home-Page
'bcr' is similar to 'bal', but branches 'conditionally' vs unconditionally. It also offers an option of returning to a label (if op2 coded), vs always returning to the next instruction (following the 'bcr').
--- <-- preceding instruction to test something & set cc
bcr= sub1 <-- branch to sub1 if condition code '=' (or < > <= >=)
--- <-- returns here via 'ret' instrn (at end subrtn)
sub1 --- - the subroutine coded elsewhere
---
ret - return to instrn following the bcr
---
bcr< sub2,getr <-- branch to sub2 if cc <
return to op2 label vs next instr
--- <-- gets here only if branch not taken
getr --- <-- op2 label could be anywhere in program
---
bcr> sub3,,'ABC' <-- branch to sub3 cc >, 1st store 'ABC' in w0(3)
--- <-- return here (since op2 not coded)
If op3,&/or op4 are coded, the data will be moved to work area 'w' for use by the subroutine & stored as follows:
| op3 data |
|
| op4 data |
|
You may run the following 'bcr' demo jobs as shown below. No input files are required.
uvcopy testbcr1 <-- run demo#1, see listing on next page, with test output ===============
uvcopy testbcr2 <-- run demo#2, not shown here ===============
vi /home/uvadm/pf/adm/testbcr2 <-- can inspect demo#2 with 'vi' ==============================
Return to first page of: this document this library (librefs) UV Software Home-Page
# testbcr1 - new instrn March 19/2008
#
# uvcopy testbcr1
# ===================
@run
loop msg ' '
msg 'test "bcr" Branch on Condition & Return'
msg 'also demos "tsb" TeSt Bit (tests for bits 1,2,4)'
msgwa1 '--> enter 1 character ("q" to quit)'
mvc a0(1),$arg1(1)
cmc a0(1),'q' quit ?
skp= quit
tsb a0(1),x'01'
bcr= one
tsb a0(1),x'02'
bcr= two
tsb a0(1),x'04'
bcr= three
skp loop
#
one msg 'character has bit x"01"'
ret=
two msg 'character has bit x"02"'
ret=
three msg 'character has bit x"04"'
ret=
quit eoj
uvcopy testbcr1 ===============
test "bcr" Branch on Condition & Return also demos "tsb" TeSt Bit (tests for bits 1,2,4) --> enter 1 character ("q" to quit) 1 character has bit x"01" --> enter 1 character ("q" to quit) 2 character has bit x"02" --> enter 1 character ("q" to quit) 4 character has bit x"04" --> enter 1 character ("q" to quit) 7 character has bit x"01" character has bit x"02" character has bit x"04" --> enter 1 character ("q" to quit) q
Return to first page of: this document this library (librefs) UV Software Home-Page
tra op1dsp(lth) - instruction format
tra b0(100) - translate 1-100 of area 'b' to ASCII
tra b180(20) - translate 181-200
(bypassing packed 101-180 ?)
tre op1dsp(lth) - instruction format
tre b0(100) - translate area b 1-100 to EBCDIC
tre c180(20) - translate area c 181-200 to EBCDIC
Return to first page of: this document this library (librefs) UV Software Home-Page
trl op1dsp(lth) - instruction format
trl b20(60) - translate 21-80 of area 'b' to lower case
trlq3 b0(80) - translate 80 col rec to lower case
with 'q' optn to inhibit translation
within quotes single or double
option q1 - inhibit translation within single quotes
q2 - inhibit translation within double quotes
| option f1 |
|
tru op1dsp(lth) - instruction format
tru b20(60) - translate 21-80 of area 'b' to upper case
truq3 b0(80) - translate 80 col rec to upper case
with 'q' optn to inhibit translation
within quotes (single or double)
option q1 - inhibit translation within single quotes
q2 - inhibit translation within double quotes
Return to first page of: this document this library (librefs) UV Software Home-Page
trt b0(80),c0 - translate area b
using the translate table in area c
| Note |
|
| example |
|
mvc c0(256),$trt - copy neutral translate table to area c
clr c0(32),' ' - set low control characters to blanks
clr c128(128),' ' - set high control characters to blanks
trt b0(80),c0(256) - translate the data
- translates any ctl chars to blanks
- printable characters will be unchanged
In fact, the above translate table is provided as a '$' symbol and you can use it directly with only the 'trt' instruction:
trt b0(80),$trtchr - translate area b to printable characters
- translates any unprintables to blanks
trt b0(80),$trtper - translates any unprintables to periods
A special translate table '$trtsea' is provided for correcting signs in zoned numeric fields that have been translated from EBCDIC to ASCII with no special consideration. See examples in DATAcnv1.doc.
tra b0(64) - entire record translated to ASCII
without consideration for zoned
signed fields in cols 39-62
trt b38(24),$trtsea - correct the signs in the multiple
zoned numeric fields in cols 39-62
trt b38(24),$trtsae - the reverse correction is also
available for ASCII to EBCDIC
Return to first page of: this document this library (librefs) UV Software Home-Page
trs aa0(500),t0(256) translate/scan for desired bytes
===============================================================
"trs" translates op1 using a neutral translate table (previously modified to detect desired characters), stops on the first change, leaving the op1 index register pointing to the character in op1 whose value was modified in the translate table.
The translate table would have been created at program initialization by copying the neutral translate table ($trt) to a work area and modifying the desired character byte offset values.
In a neutral translate table, the value in each of the 256 bytes is equal to its offset, byte 0 has value 0, byte 255 has value 255, etc. An unmodified neutral table would not change any data if used by trt.
It does not matter what the modified value is since as long as it is different than the neutral value at that offset.
| example |
|
mvc t0(256),$trt copy neutral translate table to ws
mvc t13(1),'*' modify offset to detect x'0D' packed -0
mvc t208(1),'*' modify offset to detect x'D0' unpacked -0
...
trs aa0(500),t0(256) translate/scan for desired bytes
skp= hit cc set = if desired byte found
skp! endrec cc set ! if end data with nofind
| op1 |
|
| op2 |
|
option a# (trsa1,trsa2,etc) - increment op1 register by specified value
- would use to continue scan after a match (or mismatch actually)
option r1 (trsr1) - replace data byte with translate table byte (like trt)
The instruction ends on first op1 byte whose value offset modified in op2. The condition code is set = to indicate a desired byte found & the op1 register will hold displacement of that data byte within op1.
The displacement in the register is within the entire op1 area, ignoring any op1 displacement coded (unlike most other instructions).
If no desired bytes found, cc is set < to indicate no mismatches found & the op1 register will hold displacement to 1st byte beyond op1 data.
See /home/uvadm/pf/signscan1 as a good example of using the 'trs' instruction.
Return to first page of: this document this library (librefs) UV Software Home-Page
chx op1dsp(lth),op2dsp - instruction format
chx b0(50),a0 - converts 1st 100 bytes of area a
into 1st 50 bytes of area b
chx b0(6),x'313241426162' - convert the hexadecimal constant
12ABab <--- would be the result in area b
hxc op1dsp(lth),op2dsp - instruction format
hxc b0(100),a0 - converts 1st 50 bytes of area a
into 1st 100 bytes of area b
hxc b0(12),c'12ABab' - convert character constants
313241426162 <--- result in area b (in hex representation)
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
vhx op1 , op2 , op3 , op4 - format
printable chars, zones, digits, input-data
--------- output -------------,-- input --
vhx b0(100),b100(100),b200(100),a0(100) - example
vhx b0(100),b100,b200,a0(80) - op2&op3 lths default to op1
"vhx" converts the op4 data to vertical hexadecimal as follows:
| op1 |
|
| op2 |
|
| op3 |
|
| op4 |
|
| option a1 |
|
Please see the 'vhx' example on the next page --->
Return to first page of: this document this library (librefs) UV Software Home-Page
# vhex1.dat - test data file for uvcopy vhex1 job 2276673266722276772667626666266727766772766732666 3068581E4140D0453404141069C506F20563F090685810AF2
# - to convert data files to vertical hex rep 222276266676772667626666727627677666626672767 30D04F03FE652404141069C5304F06524931C08580250
uvcopy vhex1 - pre-programmed job to convert any text file to
============ vertical hex representation
- writes a file named vhex1.tmp, which you can examine
with the editor, or print with lp, or whatever
- this job is listed below (see vhex2 for fixed lengths)
# vhex1 - convert a file to vertical hex representation
# - for variable length text files LF terminated
# - see vhex2 for fixed length records (with no LF's)
fili1=?tf/vhex1.dat,rcs=100,typ=LST
filo1=$jobname.tmp,rcs=100,typ=LSTt
@run
opn all
loop get fili1,a0(100)
skp> eof
vhx b0(100),b100,b200,a0($rz100)
put filo1,b0(100)
put filo1,b100(100)
put filo1,b200(100)
skp loop
eof cls all
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
scn op1dsp(lth),'constant' - instruction format
skp= found - cc set = if match found
scn op1dsp(lth),op2dsp(lth)
scn b0(128),'IBM' - scan for 'IBM' & set cc = if found
skp! 1
mvc bx0(3),'XXX' - replace IBM with XXX via register x
which holds displacement of found data
scnm b0(80),',.;:' - option 'm' to scan for multi 1 byte patterns
scnp b0(80),'@#@ *#@#' - scan for cdn postal code (option p)
allowing 0,1,or more blanks in centre
scne1 bb0(80),'next' - option 'e1' stores dsplcmt of found
pattern in rgstr coded vs rgstr 'x' dflt
scn b0(80),<x'20' - scan area b for 1st byte < a space
- allowed if no option 'p' & op2 lth = 1
scn b0(80),'comp-3' - scan for 'comp-3' fields (COBOL program)
skp! 1 (condition code unequal '!' if not found)
msg b0(80) - display all 'comp-3' fields
| Note |
|
| condition code |
|
| register 'x' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| option 'b' |
|
| Warning |
|
| option 'd' |
|
| option 'e1' |
|
| option 'a1' |
|
| Note |
|
| Note |
|
| option 'u1' |
|
option 'g' - option 'g' modifies the fixed op2 length specified
g1 - length of op2 search pattern determined by first NULL
g2 - length of op2 search pattern determined by first TILDE
g4 - length of op2 search pattern determined LAST NON-BLANK
g7 - 'g7' (1+2+4) searches for all 3 situations in that order
option 'h1'- inhibit the scan if 1st byte of op2 pattern tilde '~'
- returns with condition code set > unequal
h2 - same but return with cc set = equal (if 1st byte was '~')
| option 'i' |
|
| option 'p' |
|
| option 'p1' |
|
| option 'p2' |
|
scnp1 a0(80),'##' <-- scan for '#' in 1st byte + any digit 0-9 in 2nd
option q1 - inhibit recognition in single quotes
q2 - inhibit recognition in double quotes
| option 'm' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
option 'n' - match occurrence number desired
n1 - the default scans for the 1st occurrence of the pattern
n3 - would scan for the 3rd occurrence of the pattern
| option 'r' |
|
option w1 - match only on the 1st word (or part of) encountered in op1
(vs the default of testing all data in op1)
w2 - would match on the 2nd word in op1
- words counted by 1 leading blank + a non-blank
w0 - could be used if you know there is no leading blank in op1
| option z1 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| problem |
|
=========================================================
05 gross-pay pic s9(5)v99 comp-3.
=========================================================
scn a0(80),'comp-3' scan for 'comp-3'
skp! xx cc = if found, unequal(!) if not
mvc ax0(6),'comp-4' found - change to comp-4
xx ---
"scn" leaves the displacement of the 1st byte of the found pattern in register 'x' (displacements are 0 relative vs 1 relative column#s). For example, if 'comp-3' started in column 50, rgstr x would hold 49 & 'ax0' would address (area 'a' byte 0 + 49) = column 50.
scn a0(80),'comp-3' scan for 'comp-3'
skp! 1 skip over next instrn if nofind
mvc ax5(1),'4' found - change '3' to '4'
In this solution, we are changing only the '3' of 'comp-3' to a '4' "ax0" points to the 1st byte of the found pattern 'comp-3', Therefore 'ax5' points 5 bytes higher (the 6th byte of 'comp-3') since this is zero relative.
scn a7(65),'comp-3' scan for 'comp-3'
skp! 2 skip over next instrn if nofind
mvc ax7(6),'comp-4' found - change 'comp-3' to 'comp-4'
mvc ax12(1),'4' -or- found - change '3' to '4'
"a7(65)" is often used to address the COBOL statement area which is columns 8-72 (zero relative displacements 7-71) The found pattern is then addressed as 'ax7(6)' The alternative solution shown above uses 'ax12(1)' to address only the '3' of the 'comp-3' (7+5 = 12 bytes higher than register 'x')
rep a7(65),'comp-3','comp-4'
This is an easier solution to the stated problem, but does not illustrate the finer points of the 'scn' instruction which was our intention here.
Return to first page of: this document this library (librefs) UV Software Home-Page
continuing the scan for a 2nd following pattern
-----------------------------------------------
| problem |
|
==========================================================
05 gross-pay pic s9(5)v99 comp-3.
==========================================================
scn a0(80),' pic ' - find any COBOL picture clause
skp! xx
scne ax0(80),' comp-3' - find any following 'comp-3'
skp! xx
mvc ax6(1),'4' - change 'comp-3' to 'comp-4'
The 1st scn leaves rgstr 'x' with the displacement of ' pic ' The 2nd scn codes op1 as 'ax0(80)' so that the scan will continue from the ' pic ' & not start over from the begining of area 'a'
mvc ax6(1),'4'
This moves the '4' 6 bytes higher than rgstr 'x' which points to the 1st byte of ' comp-3'.
Option 'e' is necessary on the 2nd scan in order not to clear the existing value in rgstr 'x' from the 1st scan.
The following is a simpler solution but does not illustrate the finer points of the 'scn' instruction.
scn a0(80),' pic '
skp! xx
rep a0(80),' comp-3',' comp-4'
Return to first page of: this document this library (librefs) UV Software Home-Page
| problem |
|
=============================================
input --> William F. Buckley
Thomas J. K. Edison
=============================================
=============================================
output --> Buckley
Edison
=============================================
scnr a0(80),>' ' - scan from right for 1st byte > than a blank
scnr a0($rx80),' ' - continue scan for blank before surname
mvc b0(25),ax1 - move surname to area 'b'
Your 1st thought might be to code 'ax0(80)' for op1 of the 2nd scan but this would not work since the right hand starting position would be to the right of the 80 byte area.
scnr a0($rx80),' '
^^^
This works because the x rgstr determines the right hand byte
(the length is in rgstr 'x', the 80 is a maximum in case x > 80)
The 'mvc' op2 is 'ax1' to address the 1st byte of the surname which is 1 higher than the displacement in rgstr x which points to the blank found by the 2nd scan
The following is a simpler solution using the 'p' option (special pattern match characters - see next page)
scnrp a0(80),' !' - scan from right for 1 blank & 1 non-blank
mvc b0(25),ax1 - move the surname to area 'b'
For more complex examples of 'scn', 'rep', 'mvu', please see the discussion of 'index registers' near the end of section uvcopy2.doc.
Return to first page of: this document this library (librefs) UV Software Home-Page
option 'p' activates the special pattern match characters:
@ - any alpha (upper or lower)
> - any upper case x'41' - x'5a'
< - any lower case x'61' - x'7a'
# - any numeric x'30' - x'39'
& - any alphanumeric - any numeric, UPPER case alpha,or lower case alpha - NOT blank, NOT punctuation
? - any printable character x'20' - x'7e'
! - any non-blank character (all except x'20')
% - any punctuation (non alphanumeric printable)
^ - any control character x'00' - x'1f'
* - previous character may repeat 0,1,or more times
; - any 1 of a blank, period, comma, semicolon,or right paren
| option 'p1' |
|
| option 'p2' |
|
scnp1 a0(80),'##' <-- scan for '#' in 1st byte + any digit 0-9 in 2nd
Return to first page of: this document this library (librefs) UV Software Home-Page
rep b0(80),'AS400','UNIX' - replace all AS400's with UNIX
skp= repmade - set cc = if any replacement made
cmn $ci1,1 - replacement count in $ci1 instrn ctr#1
skp> multi
rep b0(80),<' ','.' - replace any byte < space with a period
- allowed if no option 'p' & op2 lth = 1
repm b0(80),'ABC','XYZ' - option 'm' for multiple 1 byte replacements
(replaces A with X, B with Y, C with Z, etc)
| condition code |
|
instruction counter #1 ($ci1) will hold a count of total replcmnts made
| rgstr 'x' |
|
| rgstr 'u' |
|
Allowed only if 'p' option absent & the op2 pattern length = 1.
Any condition code is allowed, 1 or 2 bytes as follows: = (default) ! (not equal) < <= => >
| a1 |
|
| a2 |
|
| b |
|
| Warning |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| c1 |
|
| d |
|
| f |
|
| f1 |
|
| f2 |
|
| f4 |
|
| f7 |
|
Example - replacing patterns with filenames which are null terminated
mvc b0(50),'file = fff'
repf b0(50),'fff',$fili1
| g |
|
| g1 |
|
| g2 |
|
| g4 |
|
| g7 |
|
| q1 |
|
| q2 |
|
| m |
|
| p |
|
| r1 |
|
| s |
|
| v1 |
|
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
mvu b0(80),a0,'cat' move until 'cat' found
skp! nofind set cc = if found & rx to dsp
mvc bx0(3),'dog' replace cat with dog
mvuz3a7 bx0(80),ay0,'concat' move until 'concat' found
skp! nofind
mvcu1 bx0(5),'enate' append to make 'concatenate'
(see optns z,a,e below)
mvum h0(80),r0,'.,;:' move until period,comma,semi,colon
option 'm' multi 1 byte tragets
mvu b0(80),a0,<' ' move a to b until 1st byte < space
(if no option 'p' & op2 lth = 1)
| condition code |
|
'mvu' always stores the move length in registers 'x' (for op1) & 'y' (for op2).
You might use option 'z1/z2' to init explicitly coded op1/op2 registers on the 1st mvu & omit on subsequent to continue moving data in the same area.
You might use option 'e1/e2' to add the data move length to explicitly coded op1/op2 rgstrs. You might use option 'a4' to move the found search pattern to op1. You might use option 'a1/a2' to add the found pattern length to op1/op2 registers.
Options may be appended following the 3 character instruction code. Options are lower case alphas (a-z) & may have a following numeric value.
| d |
|
| m |
|
| p |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| g |
|
| g1 |
|
| g2 |
|
| g4 |
|
| g7 |
|
| q1 |
|
| q2 |
|
| q3 |
|
| a4 |
|
| a2 |
|
| a1 |
|
| e2 |
|
| e1 |
|
| Note |
|
| Note |
|
| Note |
|
| z1 |
|
| z2 |
|
| z3 |
|
| u1 |
|
| u2 |
|
| u3 |
|
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| given |
|
| required |
|
05 sale-quantity pic 9(5) comp-4 value 0.
05 sale-quantity pic 9(5) comp-4 sync value 0.
****
1 mvuz3e3a7 bb0(80),aa0,' comp-4 ' move until comp-4 (or end line) 2 skp! 2 skip next 2 instrns if comp-4 nofind 3 mvcu1 bb0(5),'sync ' insert sync (mvc not mvu) 4 mvue3a7 bb0(80),aa0,'. ' move rest of stmnt or line
option e3 causes the explicitly coded rgstrs (b & a) to be updated (rather than the default x & y rgstrs when no op1 & op2 rgstrs coded) this applies to the displacements up until the target pattern is found
option a7 (1+2+4) causes the move of the found pattern & an additional update of the rgstrs over the found pattern
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
sct area(length),tablebase(entrylth),entryoffset(patternlth),'stopchar'
sct b0(256),m0(80),m0(30),'~'
op1 - defines the data area to be scanned
op2 - defines the table start address & table entry length
op3 - offset to the pattern within each entry (usually 0)
& max length for each pattern (usually same as op2)
(length for any 1 pattern is determined by 1st tilde)
- op3 allows you to define a scan table as 1 portion
of a multi-purpose table
op4 - end-of-table (EOT) character (2 of which are required)
- default is tilde '~' (2 tildes '~~" in columns 1 & 2)
| Note |
|
sct b0(80),m0(12),m0(12) - scan area b using table in area m
skp= match - set cc = if any match found
The table might have been loaded as follows (before @run).
lod=m0(12) Mr.~~~~~~~~~ Mrs.~~~~~~~~ Doctor~~~~~~ ~~~~~~~~~~~~ '~~' in col 1&2 marks end of table
| condition code |
|
| register 'x' |
|
| register 'y' |
|
| register 'w' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| option b |
|
| Warning |
|
| option c1 |
|
| option d |
|
option h1 - inhibit the scan if 1st byte of op2 pattern tilde '~'
- returns with condition code set > unequal
h2 - same but return with cc set = equal
(if 1st byte of pattern was a tilde '~')
| option i |
|
| option p |
|
| option p1 |
|
| option p2 |
|
option q1 - inhibit matches within single quotes
q2 - inhibit matches within double quotes
| option w1 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
rpt area(lth),tablestart(entrylth),entryoffset(patternlth),'EOT char'
sct b0(256),m0(80),m0(30),'~'
op1 - defines the data area to be scanned
op2 - defines the table start address & table entry length
op3 - offset to the pattern within each entry (usually 0)
& max length for each pattern (usually 1/2 of op2 length)
(length for any 1 pattern is determined by 1st tilde)
- the replacement data always follows the search pattern
& is the same maximum length as the search pattern
(length for any 1 replacement is determined by 1st tilde)
op4 - end-of-table (EOT) character (2 of which are required)
- default is tilde '~' (2 tildes '~~' in columns 1 & 2)
| Note |
|
rpt b0(80),m0(20),m0(10) - replace patterns in area b matching
any entry on left side of table
with corresponding entry from right side
skp= match - set cc = if any match found
lod=m0(20) - load table (prior to @run)
Mr ~~~~~~~Mr.~~~~~~~
Mrs ~~~~~~Ms.~~~~~~~
Doctor~~~~Dr.~~~~~~~
~~~~~~~~~~~~~~~~~~~~ '~~' in col 1&2 marks end of table
| condition code |
|
instruction counter #1 ($ci1) - will hold the count of re palcements made
Return to first page of: this document this library (librefs) UV Software Home-Page
| a1 |
|
| a2 |
|
| b |
|
| Warning |
|
| d |
|
| p |
|
| q1 |
|
| q2 |
|
| m1 |
|
| s |
|
| c1 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| register 'x' |
|
| register 'y' |
|
| register 'u' |
|
| register 'v' |
|
| Note |
|
| register 'w' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# rptdemo - demo the uvcopy 'rpt' instrn
# - search/replace data via table of search/replace patterns
# - by Owen Townsend, UV Software, November 2009
# - read search/replace table into area 'b' (reserved word fixes)
# - read COBOL program line by line into area 'a' until EOF
# - execute 'rpt' to apply search/replace table to each line
# - write COBOL program lines to the output file
rop=r1 # Run OPtion r1 for outfile disposition prompt at EOF (vi, more,cat)
was=b8000 # increase areas b
fili1=?tf/cobol2.cbl,typ=LST,rcs=128
fili2=?tf/cnvcob9.tbl,typ=LST,rcs=128
filo1=?tmp/$fili1,typ=LSTt,rcs=128
@run
opn all open files
rtbc1 fili2,b0(80),b0(80) read search/replace table into area 'b'
# === option 'c1' bypasses any '# ' comment lines
# begin loop to get/process/put each line of COBOL progm until EOF
man20 get fili1,a0 get next line of COBOL prgm
skp> eof
#
rptd a7(65),b0(80),b0(30) apply s/r table
# === option 'd' allows search table words ending w blank,comma,period
put filo1,a0 write out modified program
skp man20
# EOF - close files & end job
eof cls all close files
eoj end job
uvcopy rptdemo,fili1=tf/cobol2.cbl,fili2=tf/cnvcob9.tbl,filo1=tmp/cobol2.cbl ============================================================================
uvcopy rptdemo <-- same as above (files default as shown above) ==============
# cnv/cnvcob9.tbl - search/replace table to test rptdemo,rtsdemo,rttdemo # - modify old COBOL prgms to allow for new compiler reserved words printer;~~~~~~~~~~~~~~~~~~~~~ printer1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name;~~~~~~~~~~~~~~~~~~~~~~~~ name1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ row;~~~~~~~~~~~~~~~~~~~~~~~~~ row1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ col;~~~~~~~~~~~~~~~~~~~~~~~~~ col1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
******* cobol2.cbl - dummy program to test uvcopy rptdemo,rtsdemo,rttdemo
******* modify old COBOL programs to allow for new compiler reserved words
******* - via search/replace table ctl/cnvcob9.tbl
printer should be changed to printer1
name should be changed to name1
row, should be changed to row1,
col. should be changed to col1.
Return to first page of: this document this library (librefs) UV Software Home-Page
sts will scan a specified portion of each entry in a table, for a specified pattern. The table must be terminated by an entry with '~~' in cols 1-2.
sts 1st-tbl-entry,scan-area,scan-pattern - instrn format
skp= - cc = if pattern found
sts h0(80),h7(65),' accept ' - scan a table (COBOL program in memory)
sts hh0(80),hj7(65),' display ' - scan table entries using rgstrs
loaded with start/stop displacements
op1 - defines the first entry in the table
- starting position & length of each entry
- table must be ended by '~~' in 1st 2 bytes of an entry
- op1 may specify a register with a start displacement
op2 - defines the scan area in each entry
using the displacement & length
- op2 may specify a register with a stop displacement
op3 - the search pattern (constant or data address)
| condition code |
|
instrctn ctr#1 $ci1 - match count, usually 1 when match made
- could be used with option n9999 to count total matches
| rgstr 'u' |
|
| rgstr 'w' |
|
| rgstr 'x' |
|
| op1 rgstr |
|
rgstr 'u' & 'w' - same as above (when op1 rgstr not coded)
| rgstr 'x' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| b |
|
| d |
|
| g |
|
| g1 |
|
| g2 |
|
| g4 |
|
| g7 |
|
| i1 |
|
n# - scan for specified occurrence# n99999 - can use to count total matches in instrn ctr#1 $ci1
| p |
|
| q1 |
|
| q2 |
|
| z1 |
|
# ststest - test the 'sts' instrn
# - scan COBOL program for all ' accept 's
was=b200000
fili1=?in,typ=LST,rcs=100
@run
opn fili1
rtb fili1,b0(100),b0(100) read file into memory table
mvn $rb,0 init rgstr b
# begin loop to search for each occurrence of pattern - until no more
loop sts bb0(100),b0(80),' accept '
skp! eoj
# match found - calc ttl dsplcmnt from bgn table, display,& repeat search
msg bb0(72) display matching entry
add $rb,100 bypass matching entry to next
skp loop
eoj cls fili1
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
rts will search/replace in the specified portion of each entry in a table. For example, assuming you have a COBOL program loaded into memory (with ttb) you can perform search/replace within columns 8-72 of each entry.
rts 1st-tbl-entry,scan-area,pattern,replacement - format
rts b0(80),b7(65),'sysswch','switch' - example
skp= match set cc = if found
op1 - defines first entry in table
- starting position & length of each entry
- table must be ended by '~~' 1st 2 bytes or null 1st byte
- op1 may specify a register to hold the starting displacement
op2 - defines portion of each entry to scan
- op2 may specify a register to hold the ending displacement
op3 - defines search pattern (constant or adrs of data)
op4 - defines replacement pattern (constant or adrs of data)
| condition code |
|
instruction ctr#1 ($ci1) - will hold count of replacements made
| rgstr 'u' |
|
| rgstr 'w' |
|
| rgstr 'x' |
|
| op1 rgstr |
|
rgstr 'u' & 'w' - same as above (op1 rgstr not coded)
rgstr 'x' = (rgstr 'u' + rgstr 'w' + op1 rgstr initial value)
- so rgstr x will point to matching entry within entire area
Return to first page of: this document this library (librefs) UV Software Home-Page
| a1 |
|
| a2 |
|
| b |
|
| c1 |
|
| d |
|
| f |
|
| f1 |
|
| f2 |
|
| f4 |
|
| f7 |
|
| g |
|
| g1 |
|
| g2 |
|
| g4 |
|
| g7 |
|
| k |
|
| k1 |
|
| k2 |
|
| k4 |
|
| p |
|
| q1 |
|
| q2 |
|
| m1 |
|
| v1 |
|
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# rtsdemo - demo the 'rts' instrn (search/replace all entries in a table)
# - convert COBOL program reserved word 'name' to 'name1'
# - read COBOL program into a table, search/replace,& write table out
# (faster than using get/rep/put line by line)
rop=r1 # Run OPtion r1 for outfile disposition prompt at EOF (vi, more,cat)
was=a200000
fili1=?tf/cobol1.cbl,typ=LST,rcs=128
filo1=?tmp/$fili1,typ=LSTt,rcs=128
@run
opn all open files
rtbc1 fili1,a0(100),a0(100) read file into memory table
# === option 'c1' bypasses any '# ' comment lines
#
rtsd a0(100),a7(65),' name;',' name1;' search/replace
# === option 'd' allows search table words ending w blank,comma,period
wtbe filo1,a0(100),a0(100) write out modified program
cls all close files
eoj end job
******* cobol1.cbl - dummy program to test uvcopy rptdemo,rtsdemo,rttdemo
******* modify old COBOL programs to allow for new compiler reserved words
******* Example - 'name' used in old COBOLs, reserved word in ANSI85
******* - our solution is to append '1' on such words
name should be changed to name1
name, should be changed to name1,
name. should be changed to name1.
| Note |
|
#1. Login as uvadm --> /home/uvadm
#2. uvcopy rtsdemo,fili1=tf/cobol1.cbl,filo1=tmp/cobol1.cbl
=======================================================
#2a. uvcopy rtsdemo <-- same as above (files default as shown above)
==============
#3. cat tmp/cobol1.cbl <-- display output file
================== - observe search/replacements
******* cobol1.cbl - dummy program to test uvcopy rptdemo,rtsdemo,rttdemo
******* modify old COBOL programs to allow for new compiler reserved words
******* Example - 'name' used in old COBOLs, reserved word in ANSI85
******* - our solution is to append '1' on such words
name1 should be changed to name1
name1, should be changed to name1,
name1. should be changed to name1.
Return to first page of: this document this library (librefs) UV Software Home-Page
rtt will search/replace in the specified portion of each entry in a table. For example, assuming you have a COBOL program loaded into memory (with rtb) you can perform search/replace within columns 8-72 of each entry via a 2nd table of search/replace patterns.
rtt data-table-entry,scan-area,search/replace-entry,search-length
rtt a0(80),a7(65),b0(60),b0(30) <-- search/replace data table in area 'a'
skp= match with search/replace tbale in area 'b'
op1 - defines first entry in table
- starting position & length of each entry
- table must be ended by '~~' 1st 2 bytes or null 1st byte
- op1 may specify a register to hold the starting displacement
op2 - defines portion of each entry to scan
- op2 may specify a register to hold the ending displacement
op3 - defines search/replace table area & total entry length
(length of search pattern + replace pattern + possible extra)
- search pattern length determined by 1st tilde '~'
op4 - defines search pattern length,
- replace pattern assumed to follow & equal length
- replacement pattern length determined by 1st tilde '~'
| condition code |
|
instruction ctr#1 ($ci1) - will hold count of replacements made
| rgstr 'u' |
|
| rgstr 'w' |
|
| rgstr 'x' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| op1 rgstr |
|
rgstr 'u' & 'w' - same as above (op1 rgstr not coded)
rgstr 'x' = (rgstr 'u' + rgstr 'w' + op1 rgstr initial value)
- so rgstr x will point to matching entry within entire area
| a1 |
|
| a2 |
|
| b |
|
| c1 |
|
| d |
|
| p |
|
| q1 |
|
| q2 |
|
| m1 |
|
| v1 |
|
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# rttdemo - demo the uvcopy 'rtt' instrn
# - search/replace data table via 2nd table of search/replace patterns
# - by Owen Townsend, UV Software, November 2009
# - read COBOL program into a table in area 'a'
# - read search/replace table into area 'b' (reserved word fixes)
# - execute 'rtt' to apply search/replace table
# - write COBOL program table to the output file
rop=r1 # Run OPtion r1 for outfile disposition prompt at EOF (vi, more,cat)
was=a200000b8000 # increase areas a & b
fili1=?tf/cobol2.cbl,typ=LST,rcs=128
fili2=?tf/cnvcob9.tbl,typ=LST,rcs=128
filo1=?tmp/$fili1,typ=LSTt,rcs=128
@run
opn all open files
rtb fili1,a0(100),a0(100) read COBOL prgm into table in area 'a'
rtbc1 fili2,b0(80),b0(80) read search/replace table into area 'b'
# === option 'c1' bypasses any '# ' comment lines
#
rttd a0(100),a7(65),b0(80),b0(30) apply s/r table
# === option 'd' allows search table words ending w blank,comma,period
wtbe filo1,a0(100),a0(80) write out modified program
cls all close files
eoj end job
uvcopy rttdemo,fili1=tf/cobol2.cbl,fili2=tf/cnvcob9.tbl,filo1=tmp/cobol2.cbl ============================================================================
uvcopy rttdemo <-- same as above (files default as shown above) ==============
# cnv/cnvcob9.tbl - search/replace table to test rptdemo,rtsdemo,rttdemo # - modify old COBOL prgms to allow for new compiler reserved words printer;~~~~~~~~~~~~~~~~~~~~~ printer1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name;~~~~~~~~~~~~~~~~~~~~~~~~ name1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ row;~~~~~~~~~~~~~~~~~~~~~~~~~ row1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ col;~~~~~~~~~~~~~~~~~~~~~~~~~ col1;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
******* cobol2.cbl - dummy program to test uvcopy rptdemo,rtsdemo,rttdemo
******* modify old COBOL programs to allow for new compiler reserved words
******* - via search/replace table ctl/cnvcob9.tbl
printer1 should be changed to printer1
name1 should be changed to name1
row1, should be changed to row1,
col1. should be changed to col1.
Return to first page of: this document this library (librefs) UV Software Home-Page
sqz b0(80),' ' - squeeze all blanks in op1
sqzc1 b0(80),' ' - squeeze multi-blanks to 1 blank
(option c1 leaves 1 between words)
sqzc2l2 h0(80),' ' - squeeze to 2 blanks between words
& also leave 2 blanks at begin op1
sqzr f40(20),' ','0' - squeeze right (vs default left)
- replaces blanks on right with zeros on left
- the op3 fill character defaults to blank
when not specified (as on above examples)
- the 'mvn' might be better for converting
character fields to numeric since mvn would
also strip out all nonnumeric characters
| c# |
|
| c0 |
|
| c1 |
|
| l# |
|
| l0 |
|
| l1 |
|
| l2 |
|
l99- special meaning
- leave the number of left hand fill characters as is
& squeeze only the right hand remainder of the op1 area
(from the existing left hand non-fill character)
| r |
|
| a1 |
|
sqzc1a1 b40(60),' ' <-- insert blank in b40(1) if b39(1) is non-blank
sqzc1a1 b0(60),' ' <-- option 'a1' has no effect if dsplcmnt 0 b0(60)
Return to first page of: this document this library (librefs) UV Software Home-Page
Condition Code set '=' if op1 all blank
Condition Code set '>' if ny data present
Return to first page of: this document this library (librefs) UV Software Home-Page
sqf b0(30),6 - squeeze out any blank fields from the
six 30 byte fields in area b (b0-b180)
- might be multi-line name & address
sqf b0(30),6,'*' - would squeeze out any all '*' fields
replacing with blank fields at end
sqf c0(10),'-- void --' - squeeze out any '-- void --' fields
| condition code |
|
| register 'x' |
|
| counter $ci1 |
|
| option 'r' |
|
| option 'd1' |
|
sqfd1 d0(10),5 - squeeze out any blank fields from the
from the 6 10 byte fields in area 'd'
- option 'd1' removes duplicated field3
111111111122222222223333333333444444444455555555556666666666
before sqf: <-field1-> <-field3-> <-field5-><-field3->
after sqf: <-field1-><-field3-><-field5->
sqfr d0(10),5 - squeeze right (vs default left)
111111111122222222223333333333444444444455555555556666666666
before sqf: <-field1-> <-field3-> <-field5->
after sqf: <-field1-><-field3-><-field5->
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
cnt a0(80),'cats' count no of cats in area a (alley)
skp= dogs cc set = if 1 match or > if 2 or more
skp=> dogs (use => to test for 1 or more matches)
cntp b0(100),'@#@' count alpha+number+alpha patterns
cnt b0(80),<x'20' count no of bytes < a space
(allowed if no option 'p' & op2 lth = 1)
"cnt" leaves the result in instruction counter #1 ($ci1)
Sets cc = if exactly 1 occurrence found
> if more than 1 found
< if none found
register x - holds the displacement in op1 of the 1st match to op2
y - holds the displacement in op1 of the last match to op2
u - holds the displacement in op1 of the 1st non-blank
v - holds the displacement in op1 of the last non-blank
| option 'c2' |
|
$ci2 = alpha
$ci3 = lower case alpha
$ci4 = upper case alpha
$ci5 = numeric
$ci6 = alphanumeric
$ci7 = printable
$ci8 = printable but not blank
$ci9 = punctuation
$ci10 = control < x'20' & > x'7e'
$ci11 = single quotes
$ci12 = double quotes
$ci13 = words
option 'g' - option 'g' modifies the fixed op2 length specified
g1 - length of op2 search pattern determined by first NULL
g2 - length of op2 search pattern determined by first TILDE
g4 - length of op2 search pattern determined LAST NON-BLANK
g7 - 'g7' (1+2+4) searches for all 3 situations in that order
| option 'i' |
|
| option p |
|
| option p1 |
|
| option p2 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
ins op1dsp(lth),op2dsp(lth) - instruction format
ins b10(30),'19' - insert '19' in cols 11-12
& shift cols 11-38 over to 13-40
abcd------961231--------------------wxyz - before
abcd------19961231--------------------wx - after
| Note |
|
The 'ins' instruction is useful when used with a register, for example' suppose we wanted to insert 'pre-' in front of every occurrence of the word 'processing' (note leading/trailing blanks below)
scn b0(80),' processing '
skp! 1
ins bx1(80),'pre-' - insert 'pre-' 1 higher than rgstr x
The above illustrates the 'ins' instruction, but is not the best way to perform the task of converting all 'processing' to pre-processing.
rep b0(80),' processing ',' pre-processing '
The 'rep' instruction would be better because it would convert multiple occurrences on the same line (& only requires 1 instrucit on).
| option g1 |
|
| option g2 |
|
| option g4 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
ctr op1start(op1length) <-- instruction format
ctr h0(80),' ' <-- center data in 1st 80 bytes of area h
Current data start & end is determined by scanning for 1st byte > space from the left & from the right of the op1 area.
Op2 is the new fill character, normally a space, but could be other characters such as '-'.
Return to first page of: this document this library (librefs) UV Software Home-Page
fix 1st-out-field,input,#fields,delimiter[,fillchar] - format
fix b0(20),a0(80),6,'","'
condition code will be set = if at least 1 sepstring found
| instrn ctr $ci1 |
|
| instrn ctr $ci2 |
|
| instrn ctr $ci3 |
|
| register 'x' |
|
| option b1 |
|
| option b2 |
|
| option b3 |
|
| option q1 |
|
| option q2 |
|
| option q3 |
|
Please see the 'lotus2' job in section uvcopy5.doc which converts an export file from a spreadsheet to a fixed field record format
fix b0(20),a0(80),6,'","'
===========================
13500","Steve Jobs","inv5015","124.95","8.75","7.50" 14962","Steve Wosniak","inv5024","57550","4029","3453" 12300","Bill Gates","cr9001","-2500","-175","-150"
13500 Steve Jobs inv5015 000012495 000000875 000000750 14962 Steve Wosniak inv5024 000057550 000004029 000003453 12300 Bill Gates cr9001 -00002500 -00000175 -00000150
Return to first page of: this document this library (librefs) UV Software Home-Page
fix h0(20),$reply,6,':','~' - convert msg reply to a table
If the input were: filename1:file2:thirdfile;etc
The output would be suitable for searching with sct (search table):
filename1~~~~~~~~~~~ file2~~~~~~~~~~~~~~~ thirdfile~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
fixb3 h0(20),$reply,6,':','~' - convert msg reply to a table
filename1 ~~~~~~~~~ file2 ~~~~~~~~~~~~~ thirdfile ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Return to first page of: this document this library (librefs) UV Software Home-Page
var c1(79),a0(20),6,'","'
| example |
|
13500 Steve Jobs inv5015 000012495 000000875 000000750 14962 Steve Wosniak inv5024 000057550 000004029 000003453 12300 Bill Gates cr9001 -00002500 -00000175 -00000150 24595 Jim Unruh inv5273 000245000 000017150 000014700 25669 Thomas Watson inv1234 000155000 000010850 000009300
"13500","Steve Jobs","inv5015","124.95","8.75","7.50" "14962","Steve Wosniak","inv5024","57550","4029","3453" "12300","Bill Gates","cr9001","-2500","-175","-150" "24595","Jim Unruh","inv5273","2,450.00","171.50","147.00" "25669","Thomas Watson","inv1234","1,550.00","108.50","93.00"
# spread out fields into area b 20 bytes apart - in preparation for 'var'
mvc b0(5),a0 cust# to 1st field
mvc b20(20),a10 cust name to 2nd field
mvc b40(10),a30 inv# to 3rd field
mvc b60(9),a40 sales $amt to 4th field
mvc b80(9),a50 GST $amt to 5th field
mvc b100(9),a60 PST $amt to 6th field
var c1(79),b0(20),6,'","' convert to variable format
# now insert opening '"' on 1st field & remove extra ',"' from last field
mvc c0(1),'"' insert opening quote for 1st field
rep c0(80),'," ',' ' remove extra ," form last field
| f2 |
|
| b2 |
|
$ci1 - count of signidicant fields (not yet implemented) $ci2 - count of null fields (not yet implemented)
Return to first page of: this document this library (librefs) UV Software Home-Page
dlm b0(80),a0(20),4
=====================
- converts 4 20 byte fields a0(20), a20(20), a40(20), a60(20),
to b0(80), inserting delimiters & removing trailing blanks.
dlmn1 c0(100),b0(100),5 <-- option 'n1' inhibits '"'s on numeric fields
=======================
You usually need to move the component fields to a contiguous set of maximum length same size fields, before executing the 'dlm' instruction. Here is a sample job taken from 'SQLdemo.doc#9A3'
# delimcust1 - "delimit", customer name & address for SQL demo examples
# - by Owen Townsend, UV Software, November 2008
# - see www.uvsoftware.ca/sqldemo.htm
#
# uvcopy delimcust1 <-- execute this job (files default as shown below)
# ================= - sample I/O for 1st record in file below:
#
# cust# 01-06, name 08-29, address 31-52, city 54-69, province 71-72
# 1 2 3 4 5 6 7
# 123456789012345678901234567890123456789012345678901234567890123456789012
#
# 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANAIMO BC
#
# 130140,"EVERGREEN MOTORS LTD.","1815 BOWEN ROAD","NANAIMO","BC"
#
fili1=?dat1/customers,rcs=80,typ=LST
filo1=?dat1/customers.txt,rcs=80,typ=LSTt
@run
opn all
#
# begin loop to process each record - until EOF
man20 get fili1,a0 get next record
skp> eof (cc set > at EOF)
# store fields 100 bytes apart for 'dlm' insert ","
mvc b0(6),a0 cust#
mvc b100(22),a7 name
mvc b200(22),a30 address
mvc b300(16),a53 city
mvc b400(2),a70 province
dlmn1 c0(100),b0(100),5 delimit 5*100 fields from area b to c
# =======================
put filo1,c0 write output record
skp man20 repeat loop
#
# EOF - close files & end job
eof cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
und c0(20),b0(80),4
=====================
- converts "delimited","fields", in b0(80) to 4 * 20 byte fields
c0(20), c20(20), c40(20), c60(20)
removing delimiters & blank filling on the right side of each field
# undlmsales1 - undelimit "customer","sales" test/demo file
# - by Owen Townsend, UV Software, November 2008
# - see www.uvsoftware.ca/sqldemo.htm
#
# uvcopy undlmsales1 <-- execute this job (files default as shown below)
# ==================
#
# 130140,21,2004-08-02,"INV1120","HAM001",000010,00012.00,0000120.00 <-- input
#
# 130140 21 2004-08-02 INV11201 HAM001 000010 00012.00 0000120.00 <-- output
#
# cust# 01-06, salesman 08-09, date 11-20, inv# 22-29, product 31-36 <-- layout
# quantity 38-43, unit price 45-52, extended amount 54-63
#
fili1=?dat1/sales.txt,rcs=80,typ=LST
filo1=?tmp/sales.fix,rcs=64,typ=RST
@run
opn all
#
# begin loop to process each record - until EOF
man20 get fili1,a0 get next record
skp> eof (cc set > at EOF)
#
und b0(100),a0(100),8 undelimit 8 fields from area a to b (8*100)
# =========================
# move data from fixed max lth fields to desired output layout (from b to c)
mvc c0(6),b0 cust#
mvc c7(2),b100 salesman
mvc c10(10),b200 date
mvc c21(8),b300 invoice#
mvc c30(6),b400 product code
mvc c37(6),b500 quantity
mvc c44(8),b600 unit price
mvc c53(10),b700 extended amount
put filo1,c0 write output record
skp man20 repeat loop
#
# EOF - close files & end job
eof cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
swp b20(30),',' - swap left & right sides of data in 21-50
based on a comma separator
sample input: Townsend, Owen
output: Owen Townsend
swp b20(30),'","',' / ' - swap left & right sides based on ","
& insert a ' / ' as the new separator
sample input: Townsend","Owen
output: Owen / Townsend
swpp c0(40),'%' - swap left & right sides of c0(40)
based on the 1st punctuation character
- the '%' represents any punctuation
- option 'p' (4th byte of 'swpp')
is required to activate special patterns
swp b0(80),<=' ' - swap on the 1st byte < or = to a space
(allowed if no option 'p' & op2 lth = 1)
| option p |
|
| option p1 |
|
| option p2 |
|
l1 - inhibit the automatic left justify of the original right
hand data into the new left hand side of op1
Return to first page of: this document this library (librefs) UV Software Home-Page
Days since 1900 most useful for adding to, subtracting from,or comparing calendar dates. Convert to days since 1900, perform the addition or subtraction,& then convert back.
The operand types are determined by options appended to the 'dat' instrn The types are coded as c=calendar, j=Julian, n=days since 1900. the input type (operand2) is coded in the 4th byte and the output type (operand1) is coded in the 5th byte.
| datcj |
|
| datcn |
|
| datjc |
|
| datjn |
|
| datnc |
|
| datnj |
|
The 'dat' instruction also stores the alphanumeric date in uvcopy working storage area 'y' at y350(17) or symbolic date $adate.
$adate y350(17) - # Day Mth dd yyyy
1 Mon Nov 27 1995 - for example
y350(1) - day# of week coded 0-6 for Sunday-Saturday
y352(3) - day of week (Sun,Mon,Tue,Wed,Thu,Fri,Sat)
y356(3) - month (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)
y310(2) - day of month '01'-'31'
y313(4) - year 1900-9999
#1. datcj b20(7),a20(6)
=====================
- convert calendar date (yymmdd) from cols 21-26 of area a
to julian (ccyyjjj) in cols 21-27 of area b
- the century will be supplied from the system date
#2. datcc b20(5p),a20(6)
=====================
- convert calendar date (yymmdd) from cols 21-26 of area a
to calendar (ccyymmdd) PACKED in cols 21-25 of area b
#3. datcc b20(4b),a20(6)
=====================
- convert calendar date (yymmdd) from cols 21-26 of area a
to calendar (ccyymmdd) BINARY in cols 21-24 of area b
Return to first page of: this document this library (librefs) UV Software Home-Page
4a. datcn $ca1,a20(8) - convert calendar date to days since 1900 4b. add $ca1,180 - add 180 days 4c. datnc a20(8),$ca1 - convert back to calendar date
5a. datcn $ca1,a20(8) - convert calendar date to days since 1900 5b. datcn $ca2,$date1(8) - convert system date to days since 1900 5c. sub $ca2,$ca1 - subtract to get age in days 5d. datnc c0(8),$ca2 - convert back to calendar format 5e. mvc a30(6),c2(6) - move age in yrs/mths/days back to record
Suppose we want to move the current date into a page heading in area h cols 61-71 'Mth dd yyyy' (drop day# of week)
----- ---------------
datcc c0(8),$date1(8)
mvc h0(11),$adate+6
----- ---------------
Some applications need to know whether dates fall on a week-end or not. For example, suppose we are reading records into area 'a' that have a date (yyyymmdd) in bytes 80-87 & we wish to store a flag 'W' in byte 88 if weekend.
----- ----------
datcn $ca0,a80(8) convert calendar date to days since 1900
tst $adate(1),'06' Sat or Sun ?
skp! 1
mvc a88(1),'W' yes - store 'W'eekend flag
----- ----------
Return to first page of: this document this library (librefs) UV Software Home-Page
# calendar1 - print a calendar from any start date to any end date (yyyymmdd)
# - by Owen Townsend, UV Software, orig 1999, updated 2008
#
# uvcopy calendar1 <-- defaults to printing calendar for current month
# ================
#
# uvcopy calendar1,uop=b20081201e20081231 <-- create calendar for Dec 2008
# ======================================= - options b/e = begin/end dates
# ** sample output **
#
# calendar, julian, days-since-1900, alpha-date
# 20081201 2008336 039782 1 Mon Dec 01 2008
# 20081202 2008337 039783 2 Tue Dec 02 2008
# 20081203 2008338 039784 3 Wed Dec 03 2008
# --------- etc ---------
# 20081231 2008366 039812 3 Wed Dec 31 2008
#
opr='$jobname - print a calendar from any start date to any end date (yyyymmdd)'
opr='uop=bYYYYMM01eYYYYMM31 - defaults to current month'
opr=' b20081201 - begin default (if run anytime in Dec 2008)'
opr=' e20081231 - end default (if run anytime in Dec 2008)'
uop=q1b00000000e00000000 # options for begin/end default to current month
rop=r1 # option r1 prompts for report disposition at eoj
filo1=tmp/$jobname.tmp,rcs=80,typ=LSTt
@run
# default begin/end dates to current month if options not spcfd
mvc d10(8),$date store current yyyymmdd for begin
mvc d20(8),$date store current yyyymmdd for end
mvc d16(2),'01' default begin day to 01
mvc d26(2),'31' default end day to 31
datcn $ca1,d10(8) cnvt current yyyymm01 to begin day#
datcn $ca2,d20(8) cnvt current yyyymm31 to end day#
cmn $uopbb,0 begin date spcfd ?
skp= man10
datcn $ca1,$uopbb cnvt users begin date to begin day#
datcn $ca2,$uopbe cnvt users end date to end day#
# create headings in output report file
man10 opn filo1
put filo1,'calendar, julian, days-since-1900, alpha-date'
put filo1,' '
# begin loop to create calendar lines until end date reached
man20 datnc b00(8),$ca1 cnvt to calendar
datnj b10(7),$ca1 cnvt to julian
mvn b20(6),$ca1 show days since 1900
mvc b30(17),$adate also show alphadate byproduct
put filo1,b0(80) write to output file
add $ca1,1 increment day ctr
cmn $ca1,$ca2 reached stop day# ?
skp<= man20
# end date reached - close output file
# - prompt for report disposition (caused by 'rop=r1' option above)
cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
sys '----shell command----' - op1 may be a constant
sys op1dsp(lth) or an address
sysv1 'lp -onobanner $filo1' - call the spooler to print
the physical file indicated
by the logical file '$filo1'
| condition code |
|
| RULES |
|
| option v1 |
|
filo1=tmp/xref.report
sysv1 'lp $filo1'
sysv1 'lp tmp/xref.report' <-- '$filo1' replaced with actual
sys 'echo "user=${LOGNAME}"' <-- ${...} always expanded on all instrns
(no options required)
Option 'v' was implemented in June/99 on: msg, mvf, rep, rts,& sys to control expansion of uvcopy $symbols & UNIX env-var ${symbols}
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
Option 'w' allows you to capture output from 'sys' into work area w1000-w9000, making it easier for you to examine the output (vs having to code your own .redirect to a file & read-back from the file).
Here is code to capture output of 'wc -l /etc/passwd' WITHOUT option 'w':
fili2=/tmp/passwd_lines,typ=LSTt,rcs=128
...
sys 'wc -l /etc/passwd >/tmp/passwd_lines'
opn fili2
get fili2,a0
mvn $ca1,a0(6)
Here is code to capture output of 'wc -l /etc/passwd' WITH option 'w':
sysw3 'wc -l /etc/passwd'
mvn $ca1,$ci1
| Note |
|
| option w1 |
|
| option w3 |
|
Option 'w1' stores up to 9 lines from sys output & isolates up to 9 words for each line. Here are the areas used:
| w1000(100) |
|
| w1100(100) |
|
| w1900(100) |
|
- - - etc for line2-line8 - - -
| w9100(100) |
|
| w9900(100) |
|
Option 'w2' converts numerics from words on 1st line to counters $ci1-$ci9:
$ci1 - binary value of numerics in 1st word w1100(100) of 1st line w1000(100)
$ci2 - binary value of numerics in 2nd word w1200(100) of 1st line w1000(100)
- - - etc - - -
$ci9 - binary value of numerics in 9th word w1900(100) of 1st line w1000(100)
Return to first page of: this document this library (librefs) UV Software Home-Page
# testsysw3 - test uvcopy sys instrn option w3 redirect output to w1000+'
# - by Owen Townsend, UV Software, Aug 24/2008
# - see sys instrn doc at www.uvsoftware.ca/uvcopy3.htm#sys
# - run as follows, no input files required
#
# uvcopy testsysw3
# ================
#
@run
man10 msg '$jobname - test option w3 redirect sys output to w1000+'
sysv1w3 'wc pf/adm/testsysw3'
msg 'w1000(100)->',w1000(66)
msg 'w1100(30)-->',w1100(30)
msg 'w1200(30)-->',w1200(30)
msg 'w1300(30)-->',w1300(30)
msg 'w1400(30)-->',w1400(30)
msgv1 'ci1=$ci1,ci2=$ci2,ci3=$ci3,ci4=$ci4,ci5=$ci5,ci6=$ci6'
eoj
080824:182556:testsysw3: uvcopy ver=20080824 pf=/home/uvadm/pf/adm/testsysw3 uvcopy DISAM ext=dat LNX L64 license=20080824V site=UV_Software $jobname - test option w3 redirect sys output to w1000+ w1000(100)-> 19 76 697 pf/adm/testsysw3...................................... w1100(30)-->19............................ w1200(30)-->76............................ w1300(30)-->697........................... w1400(30)-->pf/adm/testsysw3.............. ci1=19,ci2=76,ci3=697,ci4=0,ci5=0,ci6=0
Return to first page of: this document this library (librefs) UV Software Home-Page
lok table-entry,table-key,search-key,EOT-marker - instrn format
skp= - cc = if found
| op1 table-entry |
|
| op2 table-key |
|
| op3 search-key |
|
| op4 EOT marker |
|
The default lookup condition (when no option specified on the lok instruction) is to look for a match (same as lok=). Don't confuse with the = or ! conditions that might be coded on the skp_ instruction to test success/fail of the lookup.
Option 'm' conditions (m1-m7) should be used on the lokm_ instruction to avoid this confusion. See option 'm' codes discussed on the next page --->
The data table might have been loaded by the 'lod' function, or by the 'rtb' (read table) instruction, or any other means.
lod=m0(20) load table of 20 byte items
T1:aaa=aardvarks
T1:bbb=bumblebees
T1:ccc=cats
~~~~~~~~~~~~~~~~~~~~
---
lok m0(20),m3(3),a0(3) - look-up via 3 byte arg
skp= ok - condition code set = if found
| register 'x' |
|
| op1 register |
|
Option 'z1' may be used to clear the register on the 1st 'lok' & might be omitted on subsequent 'lok's down the same table. The following example will use register 'g' (vs default rgstr 'x'):
lokz1 mg0(20),mg0(3),r0(3) <-- 1st lok (option z1 clears rgstr g)
skp= xxx
lok mg0(20),mg0(3),r0(3) <-- 2nd lok (w/o z1) continues search
skp= xxx
Return to first page of: this document this library (librefs) UV Software Home-Page
You may specify the type of lookup desired via symbols < = <= > or => or by option 'm' & digits 1,2,3,4,5,6,7.
lok lok - default is to look for an exact match (=) lok= lokm2 (may be coded but this is the default)
skp= skp= - don't confuse the lok condition with the skp? test condition skp! skp! - can test for match found (=) or match NOT-found (!)
lok> lokm4 - looks down table for the 1st entry > than the argument lok=> lokm6 - looks down table for the 1st entry = or > than the argument
lok< lokm1 - looks down table for the 1st entry > than the argument
& then backs up to the preceding entry (except if 1st)
lok<= lokm3 - looks down table for the 1st entry > or = to the argument
- if = entry found, register 'x' will point to it
- if > entry found, register 'x' will be decremented to the
preceding entry (except if 1st)
Option m1-m7 is recommended since lok is usually followed by skp with a condition code & it is confusing if lok also carries a condition code.
lokm4 m0(20),m3(3),a0(3) - look for 1st entry > op3
skp= ok - condition code set = if desired entry found
cc set '=' (equal) if desired entry found,
regardless of lookup mode (lok, lok=, lok=>, lok<, lok<=)
cc set '!' (not equal) if desired entry not found
the not equal could be '<' or '>' as follows:
(usually do not need to make a distinction)
cc set '<' if nofind due to end tbl marker '~~' reached
or if op3 end tbl marker was specified & reached
cc set '>' if nofind due to end tbl marker x'0000' reached
might be used to distinguish max table area when looking up
& adding entries to an area filled with tildes '~'s
Normally the end of the table is signalled by the 1st entry found whose 1st 2 bytes are '~~' or whose 1st 2 bytes are null x'00' If operand 4 is specified, then the end of the table will be signalled by the 1st entry that matches op3 on the number of bytes specified by the length of op3.
lok m0(20),m0(3),a0(3),'~EOT'
This table lookup will be ended by the 1st entry encountered whose 1st 4 bytes match '~EOT'. This feature might be used when looking up binary tables where x'00' could occur, in Big Endian machines vs little Endian (Intel) machines.
Return to first page of: this document this library (librefs) UV Software Home-Page
# uvhtm25 - copy HTML code (generated from UVSI text doc)
# - correcting excess space at end ordered lists - ID by </OL>
# - by Owen Townsend, UV Software, November 2009
# - called by script 'uvhtm2X' (see doc there)
#
# uvcopy uvhtm25,fili1=tmp1/htmlfile,filo1=tmp2/htmlfile
# ======================================================
# - search for </OL> replacing <BR><BR> on prior line with just 1 <BR>
#
# <LI> --- documentation text --- <BR><BR> <-- reduce to just 1 <BR>
# </OL>
#
# read HTML file into a table in area 'a'
# - begin loop to search for </OL>
# - search prior line for <BR><BR> & replace with <BR>
# - repeat search until no more </OL> found
# write memory table to the output file
#
was=a8000000 # increase area 'a' to 8 meg, allowing 40,000 lines of 200 bytes
fili1=?tmp1/html,typ=LST,rcs=256
filo1=?tmp2/$fili1,typ=LSTt,rcs=256
@run
opn all open files
rtb fili1,a0(200),a0(200) read HTML fiel into table in area 'a'
mvn $ra,0 init register to base of table
#
# begin loop to search for </OL> replacing <BR><BR> on prior line with <BR>
# ===
man20 lok aa0(200),aa0(5),'</OL>'
# ===
skp! man80
man22 mvn $rb,$ra save ptr to </OL>
sub $rb,200 backup to prior line
rep ab0(180),'<BR><BR>','<BR>'
add $ra,200 bypass </OL> line
skp man20 repeat loop til no more </OL>
#
# No more </OL> found - write table to output file & close files
man80 wtbe filo1,a0(200),a0(200) write out modified program
cls all close files
eoj end job
This job also illustrates 'rtb' (read file into memory table) & 'wtb' (write memory table out to a file).
Note that register 'a' on the 'lok' instrn (2nd 'a' of aa0(200) captures the table displacement to next occurrence of '</OL>'. We then transfer to register 'B' & subtract 200 (1 table entry) to modify the preceding line.
Return to first page of: this document this library (librefs) UV Software Home-Page
pop a80(20) - process options in 81-100 of area a
into $popca-$popcz & $popba-$popbz
popu 'abcd1e25f12345z9' - process options from constant string
into $uopca-$uopcz & $uopba-$uopbz
cmc $popcx,'x' - test option x character specified ?
skp= opx
cmn $popbx,100 - test option x integer value
skp= opx
Return to first page of: this document this library (librefs) UV Software Home-Page
fxt a0(80) - add the instruction in area a to the table
fxt $reply - add the instruction in $reply to the table
A good example of using this instruction is the 'copyvq' job in uvjobs6 which solicits uvcopy instructions from the operator via 'msgw' prompts & adds the instructions to the end of the prmfile.
"copyvq" is a skeleton job which would simply copy a file unchanged if no instructions were keyed in at the prompt.
This job is very handy when you only want to perform 1 or 2 or a few instructions since it saves you from having to create a new prmfile
Jobs using the fxt instruction must be coded with a 'bal' subroutine at the end of the prmfile & must supply the 'ret' instruction after all other instructions have been added
Most of the copyvq job is shown below. Note the following:
1 - solicitation of instructions via msgw & storing via 'fxt'
(the job supplies the 'ret' when the operator keys a period to end)
2 - the 'bal' to the skeleton subroutine from the record get/put loop
3 - the skeleton subroutine coded at the end of the prmfile
fxt1 msgwn 'enter a uvcopy instruction (period "." terminates entries)'
cmc $reply(1),'.' end of instrn entries ?
skp= fxt2
mvc f1(80),$reply move to area f leaving col 1 blank
fxt f0(80) add instrn to end of execution table
skp fxt1 repeat loop
fxt2 mvc c0(10),' ret #' setup 'return' instrn for end of table
fxt c0(10) add return instrn to end of table
#
loop get fili1,a0(256) get each record into area 'a'
skp> eof
mvc b0(256),a0 move record to output area 'b'
bal mod execute the users instrns in subrtn
put filo1,b0(256) write record to output file
skp loop
#
eof cls all
eoj
#
# subroutine for user entered instructions (must be at end of job)
mod nop
# --- ----,---- user entered instrns built here
# ret # return added after last user instrn
Return to first page of: this document this library (librefs) UV Software Home-Page
env areadsp(lth),'symbol' - instruction format
env e0(200),'PATH' - get the value of PATH into area 'e'
skp! nofind (cc set = if found, unequal if not)
"env" searches the environment for the variable specified by op2 (usually a constant, but could be stored in an area).
If found, the value will be stored in op1 & blank filled by default.
| option 't1' |
|
| condition code |
|
| register 'x' |
|
${symbols} are expanded on all functions and instructions as of Nov2002. Prior to Nov2002 ${symbols} were expanded only on msg,mvf,mrep,rts,sys instructions if option v2 present (option v2 no longer required).
mvf h0(20),'${LOGNAME}' <-- no option required to expand
${...} symbols on any instruction
The 'lod' function requires the 'v2' option to expand ${...} symbols
on the data lines following the 'lod' up to the '~~' end of data marker.
Use option 'v3' (v1+v2=v3) for both $symbols & ${symbols}, for example:
lodv3=h0(80)
ABC Company Expense Report
For user: ${LOGNAME} Date: $datetime
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expansion controlled by option v1/v2/v3/v5 as follows:
v1 - expand any uvcopy $symbols
v2 - expand any environmental variables ${...}
v3 - expand both $symbols & ${symbols}
v5 - (v1+v4) controls expansion of $symbols
v1 (4 bit absent) - replacing data ended by 1st blank (or null)
v5 (4 bit present) - replacing data ended by 1st tilde (or null)
Return to first page of: this document this library (librefs) UV Software Home-Page
evt 1stentry,no of entries - instruction format
evt e0(80),200 - store all env vars in area 'e'
each entry 80 bytes, max 200 allowed
| operand 1 |
|
| operand 2 |
|
| option 't1' |
|
| option 't2' |
|
| counter $ci1 |
|
PATH=/bin:/usr/bin:.:/home/uvadm/bin:/home/uvadm/sf LOGNAME=uvadm MAIL=/usr/spool/mail/uvadm PS1=uv> PFPATH=/home/userxx/pf:/home/uvadm/pf SHELL=/bin/ksh HOME=/home/uv TERM=ansi PWD=/home/uv TZ=PST8PDT
| Note1 |
|
uvcopy uvenv - writes a file with all env values
============ - displays the file on the screen
- leaves the file in cwd as 'uvenv.tmp'
(in case you want to use in any way)
| Note2 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
'vnf' Verifies Numeric Field digits & sign (packed or zoned), and sets the condition code =/! to indicate OK/errors. vnf stores error counts (see below).
vnft1 field,count,'field name' <-- instruction format
skp> error - cc set > if any error
skp= good - cc set = if no error
vnf a0(6z) <-- verify 1st 6 bytes area a (numeric zoned)
vnft1 a0(6),1,'cust#' <-- must specify option 't1' on 1st vnf in job
to init area t tabale of errors
- op3 fieldname optional (will show in area t)
vnf a120(5p),12,'monthly-sales' <-- verify 12*5 byte packed
- op2 may specify a repeat count
for multiple contiguous same size fields
cmn $ce3,1 <-- test $ce3 for any errors (digits or signs)
skp> err
$ce1,$ce2,$ce3 store error counts for digits,signs,total for last vnf.
$ce11,$ce12,$ce13 accumulate error counts for digits,signs,total since vnft1 (ie for current record).
vnf also builds a table of field errors in area 't'. You must init the table by specifying option 't1' on the 1st vnf in the job. You can use the 'wtb' (write table) to dump the table after the last vnf for each record.
1 2 3 4 5 6
01234567890123456789012345678901234567890123456789012345678901234567
##p-<--------packed-hex----------> <---numeric---> 999 99 fieldname
00-01 - field length in 2 digits 02-02 - 'p' if packed, else ' ' blank 03-03 - '-' neg sign if valid negative sign 04-33 - hexrep of packed or numeric dat (15*2=30 bytes) 35-49 - numeric zoned data (max 15) 51-53 - current fili1 rec# (min 3 digits, will expand if reqd) 55-56 - occurs# (if applicable, min 2 digits, will expand if reqd) 55-80 or 58-80 - field dscrptn from vnf op3 (will shorten if reqd)
| Register 't' |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
# testvnf5 - test vnf (Verify Numeric Field) instrn
# - by Owen Townsend, UV Software, Jan 2009
# - test repeat option for multiple contiguous fields
rop=r1
was=t80000 #increase area t to 80,000 to allow 1000 * 80 byte entries
fili1=dat1/cm1_testvnf,typ=RSF,rcs=256
filo1=tmp/cm1vnferrs,typ=LSTt,rcs=80
@run
opn all
#
# begin loop to test each record - until EOF
man20 get fili1,a0
skp> man90
vnft1 a0(6),1,'customer#'
vnf a120(5p),12,'this-year-sales'
vnf a180(5p),12,'last-year-sales'
#
# End all vnf numeric field checks for current record
# if any errs - dump area 't' table of vnf errors detected
# - write out cust# & name with err counts
man50 cmn $rt,0 any errs ?
skp<= man20
wtbe filo1,t0(80),t0(80) dump table of errs detected
mvf b0(80),a0(35) store cust# & name
mvfv1 b36(44),'ERRs: $ce11 digits, $ce12 signs, $ce13 total'
put filo1,b0
put filo1,' ' space between records
skp man20
#
# EOF - close files & end job
man90 cls all
eoj
You can run the demo job as follows:
#1. cd /home/uvadm
==============
#2. uvcopy testvnf5
===============
06 313358313430 13X140 001 customer# 05p EE1234567C 001 01 this-year-sales 05p- EF0001669D 001 12 last-year-sales 13X140 EVERGREEN MOTORS LTD. ERRs: 3 digits, 0 signs, 3 total
05p 0E3456789C 003 12 last-year-sales 139923 JOHNSTONE BOILER & TANKS ERRs: 1 digits, 0 signs, 1 total
06 333135583132 315X12 026 customer# 05p 000123456E 026 03 this-year-sales 05p- EE0203040D 026 04 last-year-sales 315X12 PARTS PLUS ERRs: 2 digits, 1 signs, 3 total
Return to first page of: this document this library (librefs) UV Software Home-Page
The test/demo file for testvnf5 is /home/uvadm/dat1/cm1_testvnf. It has 32 records of 256 bytes. We purposely created errors in rec#s 1,3,& 26. We will show you the uvhd display for record #1 only.
uvhd dat1/cm1_testvnf <-- use 'uvhd' for files with packed fields =====================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 13X140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3353332222454545444244545524542222233332445442544422222222224444
138140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 LARRY WRENCH ..4V|...
44422222222224425353432222333233323333244555255444422222E1357000
9DF00000000002306931810000250D754D55310C12290725E3800000E246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 .E|...V}.......................f.....<........f.C 19950531
0470005700000000880000000018000680001300000E00694233333333222222
35C0046D0000C0023C0000C0083C0056D0012C0000CF016D3019950531000000
000-005 - '13X140', 'X' in numeric zoned field (customer#)
120-124 - x'EE1234567C', x'EE' in 1st byte of 1st 5 byte packed field
- in 2nd segment (starting at byte 64 on left)
- x'EE' under byte 56 (on top scale) + 64 (begin segment) = 120
235-239 - x'EF0001669D', x'EF' in 1st byte of 24th 5 byte packed field
- in 4th segment (starting at byte 192 on left)
- x'EF' under byte 43 (on top scale) + 192 (begin segment) = 235
Return to first page of: this document this library (librefs) UV Software Home-Page
xxa,xxb,& xxc instructions are provided to call user subfunctions. These subfunctions must have been compiled & archived to /home/uvadm/lib/uvlib.a so they can be linked to uvcopy.
uvsubxxa.c, uvsubxxb.c,& uvsubxxc.c are 3 dummy subfunctions provided in subdir /home/uvadm/srcf/... that you may modify with your desired C code. Here is uvsubxxa.c, which includes the procedure required:
| NOTE |
|
/* uvsubxxa.c - dummy subfunction for uvcopy&uvqrpg user instrn xxa */
/* - also see uvsubxxb.c for xxb & uvsubxxc.c for xxc */
/* */
/* /home/uvadm/srcf/uvsubxxa.c <-- this code stored in subdir 'srcf' */
/* /home/uvadm/lib/uvlib.a <-- for link & archive to uvlib.a */
/* */
/* 1. cd /home/uvadm */
/* 2. vi srcf/uvsubxxa.c <-- modify dummy instrn with yours */
/* 3. ccf uvsubxxa INT I32 NOISAM <-- compile & archive to lib/uvlib.a */
/* 4. ccc uvcopy INT I32 DISAM <-- recompile&link uvcopy with subrtns */
/* */
/* uvcopy instructions xxa, xxb, xxc have no operands */
/* - areas i,j,k must be stored for subrtn arg1,2,3 (see area1,2,3 below) */
/* - instrn ctrs 21,22,23 must be stored for arg4,5,6 (see ctr1,2,3 below)*/
/* - ctrs are defined here as long, but in uvcopy/uvqrpg as UVi64 */
/* which is long if I32 but long long if I64 (modify here if I64) */
/* - ctrs are pointers so you can store them as well as reference them */
/* */
#include <stdio.h>
int uvsubxxa(char *area1, char *area2, char *area3,
long *ctr1, long *ctr2, long *ctr3)
{
int ii;
/* ............ user would code his desired function here .............. */
/* - this dummy function will copy area2 to area1 for length in ctr1 */
/* & store the actual length in ctr2 */
memcpy(area1, area2, *ctr1);
for (ii=80; ii > 0; ii--)
{ if (area1[ii] > ' ')
break;
}
*ctr2 = ii;
return(ii);
}
See sample job to test 'xxa' & 'uvsubxxa.c' on the next page --->
Return to first page of: this document this library (librefs) UV Software Home-Page
# testxxa - test user instrn June 29/00
# - see srcf/uvsubxxa.c & uvcopy instrn xxa
# - uvsubxxa.c copies area 'j' to area 'i' for length in $ci21
# - stores actual lth in $ci22, & returns lth (to set cc in uvcopy)
# - instrns xxa,xxb,xxc pass character pointers to areas i,j,& k, and
# long pointers to instruction counters $ci21, $ci22,& $ci23
@run
msgwa1 'test user instrn xxa - enter something to copy via xxa'
mvc j0(80),$arg1 store data in area j
mvn $ci21,30 store lth to copy
#-----------------------------------------------------------------------
xxa # xxa copies j to i for lth $ci21
#-----------------------------------------------------------------------
mvn $ci24,$cc save condition code for msg below
msg i0(80) display output data
msgv1 'max lth = $ci21, actual lth $ci22, cc = $ci24 '
eoj
This job is supplied in /home/uvadm/pf/testxxa & you can run as follows:
uvcopy testxxa ==============
test xxa, enter some text: --> how long is this ? how long is this ? max lth 30, actual lth 17
This test stores input for the uvsubxxa.c subrtn in area 'j', calls the 'xxa' instruction, and displays area 'i' (output of uvsubxxa.c).
You can modify uvsubxxa.c with your own desired code, recompile uvsubxxxa, and recompile uvcopy (to link new uvsubxxa from archive lib/uvlib.a)
If desired, you can add more 'own code' instructions to uvcopy.c. I suggest you use vi to search for 'xxa'. You will easily see where you can add more instructions (xxd,xxe,xxf,etc). Then add the corresponding uvsubxxd.c, etc to /home/uvadm/srcf/, compile them with 'ccf',& recompile/ relink uvcopy (as shown above).
Return to first page of: this document this library (librefs) UV Software Home-Page
The 'srt' instruction is intended for sorting fixed size items in memory (tables, record arrays, etc). This instruction is completely unrelated to the external sort instructions (sxo,sxp,sxs,sxg,sxc).
srt entry,key,number - instruction format
srt b0(80),b0(20),100 - sort 80 byte entries in area 'b'
- key is 1st 20 bytes of each entry
- 100 max entries (see option n1).
| d1 |
|
| d2 |
|
| d4 |
|
| n0 |
|
| n1 |
|
| n2 |
|
| r1 |
|
| b_ |
|
| b1 |
|
| b2 |
|
| b4 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| rgstr x |
|
| rgstr y |
|
$ci1 - total entries in the table
- prior to the 1st '~~' entry unless overridden by option 'n1'
$ci2 - number of non-blank entries
$ci3 - number of blank entries
$ci4 - no of passes required (for the internal bubble sort)
$ci5 - no of field swaps required (for the internal bubble sort)
Please see the 'uvenv' job documented in UVjobs1.doc. This job reads all environmental variables, sorts them,& displays on the screen. The entire uvcopy job (interpretive parameter file) is listed below:
# uvenv - display UNIX environment variables = values (SORTED)
opr='$jobname - display UNIX environment variables=values (SORTED)'
opr='demo powerful table handling instructions:'
opr='evt - read environmental variables into a table'
opr='srt - sort table in memory'
opr='wtb - write table to a file'
rop=r1x2 #Run OPtion EOJ prompt report disposition(vi,more,etc), default more
was=a100000 # allow 200 entries of 500 bytes each = 100K
filo1=tmp/uvenv,rcs=512,typ=LSTt # writes to a file for user use ?
@run
opn filo1
evtt2 a0(500),200 table all env-vars & '~' terminate
srtb7 a0(500),a0(30),200 sort table
wtbe filo1,a0(500),a0(500) dump table to file
cls filo1
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
sxo rcsz,'key1,key2,etc','sortwork dir' - open the sort
sxo 256,'228(3pd),59(15ca),0(8)' - open sort for 3 keys
1 - 229:231 packed descending
2 - 60:74 character ascending
3 - 1-8 char ascend (default)
sxo c0(4),'59(15)','tmp' - op1 may be an address containing
the record size to be sorted
- op3 may specify the sort workfile
directory (default tmp in cur dir)
sxo $rn,'0(8)' - op1 may be a register, or counter
or user option ($uopbn)
sxp a0(256) - put record to the sort
sxs - perform the sort
- stores no of records sorted in $ci1
(not yet implemented as of May 2009)
sxg b0(256) - get a record from the sort
skp> eof - cc set > at end of all records
- also stores '~EOS' in 1st 4 bytes
of the get area
sxc - close the sort
- not required unless you want to do
2 sorts in 1 job
| a |
|
| b |
|
| c |
|
| e |
|
| f |
|
| h |
|
| i |
|
| p |
|
| u |
|
| y |
|
| z |
|
| a |
|
| d |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| sxo option m |
|
| sxom64 |
|
| sxom256 |
|
uvcopy jobxxx,rop=m256 <-- run option m overrides sxom64 & internal default
| sxo option w |
|
| sxow100 |
|
| Note |
|
| sxo option v0 |
|
| sxov1 |
|
sxo 64,'44(6y)' <--- field type y for windowed date field sort
| rop=y70 |
|
| rop=y70z1 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
sxgd1 b0(80) <-- option d1 will drop dup recs on all keys spcfd
- when no k# option spcfd on sxo & no op2 spcfd
sxgd1k2 b0(80) <-- option d1k2 drops dup recs matching on 1st 2 keys
- see demo job 'sort1' on the next page
sxgd1 b0(80),b30(6) <-- op2 overrides keys spcfd on sxo
- this would drop recs matching on cols 31-36
- dangerous if overriding higher sort keys
The next page lists a complete uvcopy job with an external sort. The 'sort1' demo job sorts dat1/sales2 on key1=slsmn,key2=customer,& key3=product.
Here we have extracted the essential sort instructions to demo options 'd1k2' (on sxgd1k2) to drop records with dups on 1st 2 keys (salesman & customer).
sxo 80,'10(2),0(6),30(6)' open sort, specify rcsz & sort fields
# sort key1=slsmn,key2=customer,key3=product
fget get fili1,a0(80) get record from input file
skp> eof (cc set > at EOF)
mvc b0(80),a0 copy input area to work area b
sxp b0(80) put to the sort
skp fget return to get next record
#
eof sxs sort created records
#
sget sxgd1k2 g0(80) getrec, drop if match on 1st 2 keys
# ======= ===========================
skp> eos (cc set > at end sortrecs)
put filo1,g0(80) write to output file
skp sget
#
eos cls all
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
The following job is provided as a template to copy, rename,& modify whenever you need to create a new job using the sort feature of uvcopy.
#1. cp /home/uvadm/pf/sort1 pf/mysort - copy & rename to your pf directory
=================================
#2. vi pf/mysort - modify as required
============
# sort1 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/demo/
# sort1 - sample/skeleton uvcopy job to illustrate sort capability in uvcopy
# - template for creating new uvcopy/sortjobs (copy/rename/modify)
# - sorts demo file /home/uvadm/dat1/sales2 on slsmn,customer,product
# sort1 - this job demos option 'sxgd1k2' drop recs with dups on 1st 2 keys
# sort1a - alternate job to drop if dup on product# only (op2 on sxg)
#
opr='$jobname - sample/template uvcopy job to illustrate sort capability'
fili1=?dat1/sales2,rcs=80,typ=LST
filo1=?tmp/$fili1,rcs=80,typ=LSTt
@run
opn all
sxo 80,'10(2),0(6),30(6)' open sort, specify rcsz & sort fields
# sort key1=slsmn,key2=customer,key3=product
# input phase - get records & put to the sort
fget get fili1,a0(80) get record from input file
skp> eof (cc set > at EOF)
#--------------------------------------------------------------------
mvc b0(80),a0 copy input area to work area b
# --- -----,----- process input records here
#--------------------------------------------------------------------
sxp b0(80) put to the sort
skp fget return to get next record
#
# end of input file - sort the created records
eof sxs sort created records
#
# get records from the sort & write to the output file
sget sxgd1k2 g0(80) getrec, drop if match on 1st 2 keys
skp> eos (cc set > at end sortrecs)
#--------------------------------------------------------------------
# --- -----,----- process output records here
#--------------------------------------------------------------------
put filo1,g0(80) write to output file
skp sget
#
# end sort records - close files & end job
eos cls all
eoj
Return to first page of: this document this library (librefs) UV Software Home-Page
#1. cd /home/uvadm
==============
#2. cat dat1/sales2 <-- display input file (for sort1 demo sxgd1k2)
===============
1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123
cust# slsm# date invoice# product# qty price amount
================================================================
130140 21 940802 IN111001 HAM001 000020 0000001 000000020
130140 21 940802 IN111001 SCR012 000021 0001001 000021021
130140 21 940802 IN111001 CHR001 000022 0002001 000044022
139923 35 950802 IN111002 TAB013 000023 0003001 000069023
139923 35 950807 IN111002 TAB013 000024 0004001 000096024
150825 44 960804 IN1122 HAM001 000025 0005001 000125025
150825 44 960804 IN1122 HAX129 000026 0006001 000156026
201120 44 970807 CR5234 WHIP75 000027 0007001 000189027
223240 65 980816 CR955 HAM001 000028 0008001 000224028
223240 65 980816 IN441 BBQ001 000029 0009001 000261029
308685 21 990812 IN6605 SAW051 00001p 0000001 00000001p
308685 21 990812 IN6605 WHIP75 00001q 0001001 00001101q
308685 21 990812 CR8835 TAB013 00001r 0002001 00002401r
315512 44 000805 IN2251 HAM001 00001s 0003001 00003901s
315512 44 000805 IN2251 SAW051 00001t 0004001 00005601t
315512 44 000805 IN2255 WHIP75 00001u 0005001 00007501u
400002 85 010812 CR245 HAX129 00001v 0006001 00009601v
406082 35 020815 IN33001 BBQ001 00001w 0007001 00011901w
406082 35 020815 IN33001 TAB013 00001x 0008001 00014401x
406082 65 020816 IN441 HAM001 00001y 0009001 00017101y
#3. uvcopy sort1 <-- execute demo job to illustrate sxgd1k2
============
#4. cat tmp/sales2 <-- display output file
==============
1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123
cust# slsm# date invoice# product# qty price amount
================================================================
130140 21 940802 IN111001 CHR001 000022 0002001 000044022
308685 21 990812 IN6605 SAW051 00001p 0000001 00000001p
139923 35 950802 IN111002 TAB013 000023 0003001 000069023
406082 35 020815 IN33001 BBQ001 00001w 0007001 00011901w
150825 44 960804 IN1122 HAM001 000025 0005001 000125025
201120 44 970807 CR5234 WHIP75 000027 0007001 000189027
315512 44 000805 IN2251 HAM001 00001s 0003001 00003901s
223240 65 980816 IN441 BBQ001 000029 0009001 000261029
406082 65 020816 IN441 HAM001 00001y 0009001 00017101y
400002 85 010812 CR245 HAX129 00001v 0006001 00009601v
Return to first page of: this document this library (librefs) UV Software Home-Page
| sort1 |
|
| pswsort1 |
|
try this ---> uvcopy pswsort1
===============
| index |
|
| sort2 |
|
| cmreport |
|
| cmsplit |
|
Most sort times are determined by input & output times. Intermediate sort merges are required only for files larger than 6.4 gigabytes, assuming the default sort memory of 64 megs & 100 sort work files. As the input file is read, each 64 meg portion is sorted & written to up to 100 work files in the tmp subdir. These are then merged during the output phase.
#1. sort 100 meg file of 300,000 * 350 byte records
- requires 25 seconds (10 seconds input & 15 seconds output)
#2. sort 1 gig file of 3,000,000 * 350 byte records
- requires 7 minutes (3 input & 4 output)
The tests above were run using 64 megs & 100 work files max. For test#2 about 18 work files are created in tmp during the input phase which are merged during the output phase. (18 * 64 meg = 1 gig file approx). There is no advantage increasing the memory unless the file is > 6.4 gig.
Return to first page of: this document this library (librefs) UV Software Home-Page
| tbl |
|
| tbf |
|
| tbh |
|
| tbp |
|
| tbd |
|
"tbl" will build tables in memory to be printed at the end of the job.
Each table may have an argument up to 48 bytes which could be composed in a work area from several subfields before the 'tbl' instruction is executed. Up to 6 accumulators may be specified for each table.
An entry count is provided automatically so you don't have to waste 1 of the 6 accumulators for this purpose.
Percentages of the 100% total at the bottom, may be automatically calculated, for the entry count & for each of the 6 accumulators.
Several 'tbl' instructions could be executed for each record of the input file, with several different arguments & accumulators. The tables are built & dumped in sequence by their argument fields.
The tables are normally dumped to an output file at the end of the job by the 'tbp' &/or 'tbd' instructions.
"tbp" edits (prints) the tbl entries into a file which may be subsequently printed via 'lp'.
"tbd" writes the the tbl entries (unedited) into a file for additional processing, collection,or storage.
There is no limit on the number of tables or on the number of entries in any 1 table (other than available system memory), but there are defaults which may be increased via 'run' options 'u' & 'v'.
| rop=u12 |
|
| rop=v2000 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
tbl argument,heading,acum1,acum2,acum3,acum4,acum5,acum6
tblt1f2 a100(16),'city-name;sales;costs;profit',a40(8z),a48(6p),a54(4b)
tbhh1 '-dummy-;sales;costs;profit'
----
tblt1f2h1 a100(16),'city-name',a40(8z),a48(6p),a54(4b)
tblt1f2h1 a120(6),'postal-code',a40(8z),a48(6p),a54(4b)
Return to first page of: this document this library (librefs) UV Software Home-Page
| t# |
|
| f# |
|
| h# |
|
"=" if the table already contained the current argument
"<" if a new table entry was created for the current argument.
">" if the entry pointer table is full (area 'w')
- stops with an error message
- may continue bypassing the current entry
- you could test the condition ">" & branch to dump the table ?
(or better kill, increase area w,& rerun the job)
$ci21 - will be set to the number of table entries present
$ci22 - will be set to the number of matches for current argument
Return to first page of: this document this library (librefs) UV Software Home-Page
tbf argument-location(length),accumulator editing formats
tbff2 p19(20),'zzz,zzz,zzz.zz- %%%.%%- zzz,zzz,zzz.zz- %%%.%%- .etc.'
| f# |
|
| d# |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
tbh table-field-headings
tbhh1 'city name;sales;costs;profit'
| h# |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
tbp file,table-title-heading
tbpt1e3 filo1,'sales analysis'
| t# |
|
| e# |
|
| c |
|
| l## |
|
| s# |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
| h# |
|
mvf $tbh1,'product#;quantity;amount'
tbp filo1,'Sales by Product#'
| i1 |
|
| i2 |
|
| i4 |
|
| i8 |
|
| i12 |
|
| j1 |
|
| j2 |
|
| j4 |
|
| j7 |
|
| z1 |
|
| z2 |
|
| z3 |
|
$ci1 - no of table entries written (not yet implemented)
Return to first page of: this document this library (librefs) UV Software Home-Page
tbd file,constant-data (to be appended to table entries)
tbdt1e3 filo2,'19940430'
| t# |
|
| e# |
|
| c |
|
| j1 |
|
| z1 |
|
| z2 |
|
$ci1 - no of table entries written (not yet implemented)
Return to first page of: this document this library (librefs) UV Software Home-Page
| given |
|
| required |
|
*slstbl2 1994/05/29_15:35:41 sales by city (this yr & last yr) * *tbl#001 pg#001 -argument- -acum#1- % -acum#2- % * *line# count % city name thisyr sales lastyr sales * * * * 1 4 8 CALGARY 3,150.58 2 3,274.76 5 * * 2 1 2 CHILLIWACK 4,478.00 3 8,610.30 13 * * 3 1 2 COQUITLAM 1,420.00 1 .00 * * -etc- -etc- -etc- -etc- * * 23 1 2 SURREY 10,761.58 9 .00 * * 24 1 2 THREE HILLS 340.52 .00 * * 25 4 8 VANCOUVER 24,112.72 21 1,220.16 1 * * * * 46*100 *TOTAL* 112,684.76 *100 65,493.51 *100 *
# slstbl2 - table analysis of customer master sales history file
opr='$jobname - summarize sales (thisyr&lastyr) by city name'
fili1=dat1/custmas1,rcs=256,typ=RSF
filo1=$jobname.tmp,rcs=80,typ=LSTt
@run
opn all
# begin loop to read all customer master sales history records
# - crossfooting & accumulating (tabling) thisyr & lastyr totals
loop get fili1,a0(256)
skp> eof
xft $ca1,a120(5p),12
xft $ca2,a180(5p),12
tblt1f2 a60(16),'city name;thisyr sales;lastyr sales',$ca1,$ca2
skp loop
# end of file - print/edit the tables to a file for: lp, cat,or vi
eof tbpt1s2 filo1,'sales by city name (this yr & last yr)'
cls all
eoj
| Note |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
tbff1 p19(16),'zz,zzz,zzz,zz9- %%9- zz,zzz,zzz,zz9- %%9- .etc.' DEFAULT tbff2 p19(16),'zzz,zzz,zzz.99- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff3 p19(16),'zz,zzz,zzz,zz9- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff4 p19(32),'zz,zzz,zzz,zz9- %%9- zz,zzz,zzz,zz9- %%9- .etc.' tbff5 p19(32),'zzz,zzz,zzz.99- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff6 p19(32),'zz,zzz,zzz,zz9- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff7 p19(48),'zz,zzz,zzz,zz9- %%9- zz,zzz,zzz,zz9- %%9- .etc.' tbff8 p19(48),'zzz,zzz,zzz.99- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff9 p19(48),'zz,zzz,zzz,zz9- %%9- zzz,zzz,zzz.z9- %%9- .etc.' tbff10 p19(16),'zzz,zzz,zzz.99- %%9.%%- zzz,zzz,zzz.99- %%9.%%-.etc.' tbff11 p19(16),'zz,zzz,zzz,zz9- zz,zzz,zzz,zz9- .etc.' tbff12 p19(16),'zzz,zzz,zzz.99- zzz,zzz,zzz.z9- .etc.'
count% ---acum#1--- ----acum#2---- max-print max-print
fmt# dcmls arg-lth dcmls %dcmls dcmls %dcmls acum3-6 2 acums 6 acums
f1 0 16 0 0 0 0 same as 78 149 DFLT f2 0 16 2 0 2 0 acum #2 78 149 f3 0 16 0 0 2 0 " 78 149 f4 0 32 0 0 0 0 " 94 181 f5 0 32 2 0 2 0 " 94 181 f6 0 32 0 0 2 0 " 94 181 f7 0 48 0 0 0 0 " 110 197 f8 0 48 2 0 2 0 " 110 197 f9 0 48 0 0 2 0 " 110 197 f10 2 16 2 2 2 2 " 84 171 f11 0 16 0 - 0 - " 68 115 f12 0 16 2 - 2 - " 68 115
| f1 |
|
| f2 |
|
| f3 |
|
| f4 |
|
| f5 |
|
| f6 |
|
| f7 |
|
| f8 |
|
| f9 |
|
| f10 |
|
| f11 |
|
| f12 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page
The edit patterns are shown only for the 1st 2 sets of (acum & %) on each line because acums 3-6 are always the same as acum #2 (for these pre-programmed formats).
tbff3 p19(16),'zz,zzz,zzz,zzz- %%%- zz,zzzz,zzz.zz- %%%- ..etc..'
Accumulator digit positions are indicated with 'z's & percentage digit positions are indicated with '%' symbols.
There must be 1 space between the edit patterns. On the total line, the space following the acum will be set to an "*" to identify the total line.
Percentage edit patterns should always be at least 3 long.
You can use 9's in trailing positions of either accumulator or percentage edit patterns to stop zero suppress.
tbff3 p19(16),'zz,zzz,zzz,zz9- %%9- zzz,zzz,zz9.99- %%9.99- ..etc..'
The maximum print position assumes that all 6 acums are present which is rarely the case.
All acums are 10 digits max & are either 0 decimals (quantity) or 2 decimals (dollars & cents).
If none of these pre-programmed formats fits your requirements, you can re-specify any or all of these to your desired format via the 'tbf' instruction.
Return to first page of: this document this library (librefs) UV Software Home-Page
* jobname 1994/05/29_15:35:41 sales by city (this yr & last yr) * *tbl#001 pg#001 -argument- -acum#1- % -acum#2- % * *line# count % city name thisyr sales lastyr sales * * * * 1 4 8 CALGARY 3,150.58 2 3,274.76 5 * * 2 1 2 CHILLIWACK 4,478.00 3 8,610.30 13 * * 3 1 2 COQUITLAM 1,420.00 1 .00 * * -etc- -etc- -etc- -etc- * * 23 1 2 SURREY 10,761.58 9 .00 * * 24 1 2 THREE HILLS 340.52 .00 * * 25 4 8 VANCOUVER 24,112.72 21 1,220.16 1 * * * * 46*100 *TOTAL* 112,684.76 *100 65,493.51 *100 *
tbff1 p19(16),'zz,zzz,zzz,zzz- %%%- zz,zzz,zzz,zzz- %%%- ..etc..'
All pre-programmed formats allow for line#, count,& % of count in the 1st 17 print positions & this is why the pre-programmed formats all specify the argument field as p19(xx).
If you wanted count % edited to 2 decimals, you could specify option 'd2' & specify the argument operand as p20(16) or whatever.
tbff1d2 p20(16),'zz,zzz,zzz,zzz- %%%- zz,zzz,zzz,zzz- %%%- ..etc..'
If you did not want any count percentage, you could specify option 'd9' & then specify the argument operand as low as p14(xx)
If you did not want any line# & count in your report, you could specify the argument as p0(18) which would overlay the line & count with the argument. The actual argument data length is specified on the tbl instruction & would usually be less than & left justified within the the tbf specification.
Return to first page of: this document this library (librefs) UV Software Home-Page
000-000 (character) - 'T' to identify a valid table entry
001-003 (character) - table# zoned numeric 000-999
004-051 (character) - table argument, 48 bytes max, blank filled on right
^G*TOTAL* in 1st 8 bytes for table Total record
052-055 (binary) - sequence# of entry when written to output file
056-059 (binary) - hit count, no of matches/adds to this entry
060-063 (binary) - table#
064-067 (binary) - accumulator #1 068-071 (binary) - accumulator #2 072-075 (binary) - accumulator #3 076-079 (binary) - accumulator #4 080-083 (binary) - accumulator #5 084-087 (binary) - accumulator #6 088-111 - not used
064-071 (binary) - accumulator #1 072-079 (binary) - accumulator #2 080-087 (binary) - accumulator #3 088-095 (binary) - accumulator #4 096-103 (binary) - accumulator #5 104-111 (binary) - accumulator #6
112-127 - jobname (of uvcopy job creating the table)
128-143 - date & time created, 14 characters yyyymmddhhmmss
144-xxx - operand 2 (if any) from the 'tbd' instruction
- max length would depend on the rcsz declared on the output file
tbd filo1,'x---appended to dumped entries---x'
The record size written by 'tbd' depends on the rcs= declared on the "filo1" declaration, for example:
filo1=tmp/tablexxx,rcs=160,typ=RSF
This example (rcs=160) include space for the optional items (jobname, datetime,operand 2), and the 1st 16 bytes from op2 of the tbd instruction. "rcs=72" will include the 1st 2 acums if 32 bit & only the 1st acum if 64 bit.
Return to first page of: this document this library (librefs) UV Software Home-Page
Note that 64 bit versions (of uvcopy & uvqrpg) are available on some machines & architectures, as documented in doc/install.doc. As of May 2000 these are:
The table total control record would be written out first & it has the same format as the table entry detail records shown above.
It can be identified by the x'07' in the 1st byte of the argument. or possibly '*TOTAL' in bytes 2-7 of the argument if you know you cannot have this in your data.
The control record carries the totals on which the 100% calcs are based. The sequence# would carry the total no of entries in the table.
You would only need to know the table entry layout when & if you are using the 'tbd' instruction to dump the tables (unedited) into a file for subsequent processing.
For example, you could collect table records for each day, week,or month & then re-table them for summaries at the end of the week, month,or year.
The records will be written out with the length specified by the 'rcs' parameter on the output file. The records will have no linefeeds since they contain binary fields.
Return to first page of: this document this library (librefs) UV Software Home-Page
Table entries are 88 bytes each & storage is assigned dynamically as required via memory requests from the operating system.
However the number of table control structures & the pointers to the table entries are assigned within fixed areas within the uvcopy program.
The defaults allow for 12 tables & 1000 total entries for all tables.
If you exceed 12 tables or 1000 total table entries, you will get an error message. You would then increase the maximums via run options "u" &/or "v" and rerun your job.
| rop=u12 |
|
| rop=v1000 |
|
| rop=u50 |
|
| rop=v5000 |
|
uvcopy tbljob,rop=u50v5000 - u & v may be coded on command line ==========================
# tbljob
rop=u50v5000 - better to code within the parameter file
fili1=xxxx,rcs=999,typ=RSF
filo1=yyyy,rcs=80,typ=LSTt
@run
opn all
--- etc ---
Return to first page of: this document this library (librefs) UV Software Home-Page
| given |
|
| required |
|
# tblprm - table analysis of the payroll master file
# - accumulating ytd reghrs,othrs,gross,tax,pension,& insurance
# by dept, job class, birth yr,& dept + birth yr
opr='$jobname - table analysis of the payroll master file'
fili1=paymaster,rcs=256,typ=RSF
filo1=$jobname.tmp,rcs=132,typ=LSTt
@run
opn all
# declare tbl format: acums 1&2 1 dcml, acums 3-6 2 dcmls (4-6 duplicated)
tbff1 p17(10),'zz,zzz.z- %%%- zz,zzz.z- %%%- zzz,zzz.zz- %%%-'
# declare tbl headings - for accumulators, argument modified by each tbl
tbhh1 'argument;reg hrs; over hrs; gross; tax; pension; insurance'
#
# begin loop to get records & build tables until EOF
loop get fili1,a0(256) get a record
skp> eof ( cc set > at EOF)
tblt1f1h1 a10(3),'dept',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p)
tblt2f1h1 a13(4),'class',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p)
tblt3f1h1 a20(4),'birth',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p)
# move dept & birth together, to create argument for table #4
mvc b0(3),a10 dept to w/a 'b'
mvc b4(4),a20 append birth yr leaving 1 space
tblt4f1h1 b0(8),'dept+birth',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p)
skp loop repeat loop until EOF
#
# EOF - dump (print/edit) tables to output file & then print via 'lp'
eof tbpl55 filo1 print/edit to file (55 lines/page)
cls all
sysv1 'lp $filo1 ' print via UNIX lp
eoj end job
Return to first page of: this document this library (librefs) UV Software Home-Page
The tblprm sample job illustrates several important points & to facilitate discussion, the relevant tbl instructions are reproduced below.
(init) 1. tbff1 p17(10),'zz,zzz.z- %%%- zz,zzz.z- %%%- zzz,zzz.zz- %%%-'
(loop) 3a. tblt1f1h1 a10(3),'dept',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p) 3b. tblt2f1h1 a13(4),'class',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p) 3c. tblt3f1h1 a20(4),'birth',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),a75(5p) 3d. tblt4f1h1 b0(8),'dept+birth',a50(5p),a55(5p),a60(5p),a65(5p),a70(5p),
(eoj) 4. tbpl55 filo1 print/edit to file (55 lines/page)
1 - The 'tbff1' stores the table format 'f1' to be used when the tables
are printed out at the end of the job by the 'tbp'.
- Op1 p17(10) defines the print area for the argument (dept,class,birth)
- Op2 defines the edit patterns for the 6 accumulators & their percentages
- Note that we had to define this custom tbf because none of the standard
12 formats fit our requirements (acums 1 & 2 with 1 decimal for hours
& acums 3-6 edited to 2 decimals for dollars & cents).
- We did not have to code the edit patterns for acums 4-6, because the
right most edit patterns are duplicated to the remaining sets.
2 - The 'tbhh1' stores the headings to be used when the tables are printed
out at the end of the job by the 'tbp'.
- Note that the 'tbl' instructions all specify the 'h1' option to link
the tbl to the desired headings.
- Also note that the 'tbl' modifies the tbhh1 headings via its op2
(dept,class,birth) which replaces the 1st field in the h1 stored
headings (up to the 1st semicolon).
3 - The above logic is possible because the 'tbl' instruction (at setup
time) also creates a control structure for each unique tbl#.
The control structure holds the headings integrated from the tbl &
the tbh. The control structure also holds the totals for all
accumulators to allow percentage calculations of 100% before we
reach the total line.
4 - The 'tbpl55' prints (edits) all tables into a file which is then
actually printed via the UNIX 'lp' command.
- The 'l55' specifies 55 lines per page & of course a formfeed is also
generated between the 4 tables being printed.
- The proper headings (as described above) will be associated with
each table.
Return to first page of: this document this library (librefs) UV Software Home-Page
| wordtbl1 |
|
| slstbl1 |
|
| slstbl2 |
|
Return to first page of: this document this library (librefs) UV Software Home-Page