uvhd CONTENTS


Part_0 - Overview of uvhd (interactive file investigation utility)
- Free Software notice (GNU FSF GPLv3)
- sample uvhd display (vertical hexadecimal)
  64 byte segments on 3 lines (characters, zones,& digits)
  sample for customer master record with 24 packed fields

Part_1 - Download uvhd.c source from www.uvsoftware.ca & Compile for Unix/Linux
  Download uvhd.exe from www.uvsoftware.ca for Windows/DOS
  Customizing the DOS Command Prompt window for Windows 2000
- changing small, ugly, black & white default to big, blue,& beautiful
  Compiling uvhd.c to uvhd.exe on Windows/DOS using lcc-win32 or gcc MinGW
- not required, since you can download uvhd.exe from www.uvsoftware.ca
  Customization re printing

Part_2 - Help screens (26 help screens)
- command line format & options
- interactive functions (browse,search,update - see all in Part 4)

Part_3 - uvhd command line OPTION summary
- uvhd COMMAND summary
- uvhd FUNCTION summary
 Part_4 - uvhd Tutorial for all functions
        - tutorial based on fixed-length records (see variable-length in Part 5)
        - preparation for tutorial
        - copy demo files to subdir in your home directory
    Browse - display records consecutively (null entry for next)
           - jump to & display any record in fixed-length files by record#
           - find/display any record in variable-length files by record#
    Search - search by patterns anywhere in record or in specified columns
    Update - update current record with specified data in specified columns
           - update all records with data, optionally qualified by existing data
    Enum   - Enumerate/count records matching specified patterns
    Accum  - Accumulate fields from All records (current until EOF)
           - or from records matching 1 or 2 specified patterns in spcfd bytes
    Write  - write selected records to a temp file: tmp/filename.yymmddhhmmW
    Print  - write selected hexdump records to temp file for later view/print
    Iprint - Immediate print selected hexdump records
    Generate Sequence Numbers - may specify starting number & increment
    Check  - check sequence of specified field
    Scan/Replace - scan for patterns & replace with alternate patterns
    Move   - move fields, use to reformat records & write new files
    Translate - to Ascii, Ebcdic, Upper, Lower, unprintable characters to periods
    Drop   - copy to tmp file, dropping records matching 1 or 2 patterns
    Modify filesize - truncate or extend with x'00's

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

uvhd Contents (continued)


Part_5 - uvhd tutorial on Variable-Length files
- based on 7 formats of the vendormas* demo file
  vendormas0 - Fixed-Length EBCDIC 64 byte records
  vendormas1 - Fixed-Length ASCII 64 byte records
  vendormas2 - Variable-Length TEXT file (LineFeed terminators)
  vendormas3 - Variable-Length RDW (recsize in binary record prefixes)
  vendormas4 - Micro Focus fixed-length Indexed file
  vendormas5 - Micro Focus varlth 2 part .dat & .idx
  vendormas6 - Micro Focus varlth single partition file
- converting between file types using 'uvcp/uxcp' (part of VU pkg)
- converting between file types using 'uvhd' (free download)
- STL files added Feb 2016 (AIX COBOL files)

Studying &/or performing the tutorials in Part 5 will give you a good understanding of how uvhd can help you investigate & convert between the various file types. This is especially important if you are interested in mainframe conversions or file transfers between mainframes & Unix/Linux systems.


Part_6 - Miscellaneous tips using uvhd
- finding Record-Size in a fixed length file
- using the NOT= (!) condition
- searching binary files, example: find version of /bin/ksh (Korn shell)
- use 'uvcopy' when your problem is too complex for 'uvhd'
  (uvcopy can do whatever data manipulation you might require)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_0 uvhd - file investigation hexdump utility

0A1. uvhd - Program Description

'uvhd' is a binary file investigation utility. It displays any file in vertical hexadecimal and prompts for commands to browse, search, select, update, scan/replace, print, translate, etc. uvhd is an interactive utility with a command line interface and 26 help screens.

Copyright(C) 1993-2019, UV Software Inc, distributed under GPLv3

You may download uvhd from: https://www.uvsoftware.ca/freestuff.htm

Licensed under GPLv3

This program is free software: you may redistribute it and/or modify it under the terms of GPLv3 (GNU General Public License version 3), as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the full description of the GNU General Public License at: https://www.gnu.org/licenses.

uvhd & Vancouver Utilities

'uvhd' is offered as a Free sample of the Vancouver Utilties which are often used to convert mainframe JCL, COBOL,& DATA to Unix/Linux/Windows Mainframe JCL is converted to Korn shell scripts, and Mainframe COBOL is converted to Micro Focus COBOL to run under Unix/Linux.

uvhd is especially valuable to investigate mainframe type files with packed fields and no linefeeds (required by most unix/linux utilities) uvhd can investigate all converted file types: sequential, fixed, variable, indexed, text, binary, C-ISAM, D-ISAM, Micro Focus COBOL IDXFORMAT1,3,8)

uvhd displays any file in vertical hexadecimal, 64 byte segments, in 3 line groups (characters on 1st line, zones on 2nd line,& digits on 3rd line).

When you find a data problem, use the print function to capture the evidence and send it to your associates via email or hardcopy printout. Hardcopy or softcopy printouts of binary/packed files with byte position scales are not possible with most other unix utilities.

 ============================================================================
 Owen Townsend, UV Software, 4667 Hoskins Rd., North Vancouver BC, V7K2R3
         Tel:   604-980-5434          Fax: 604-980-5404
         Email: owen@uvsoftware.ca    Web: https://www.uvsoftware.ca
 Copyright(C) 1993-2019, UV Software Inc, All rights reserved
 ============================================================================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

0A2. uvhd - file investigation hexdump utility

uvhd Display format illustrated

Records are displayed 256 bytes at a time by default (if rcsz not spcfd) in 4 groups of 3 vertical hex lines as follows:

         ...........record in character format (. for non-dspl chars)....
         ...........hex representation of record zones...................
         ...........hex representation of record digits..................

sample display - 1st record from dat1/custmas1 file


 uvhd dat1/custmas1 r256s2   - command to display the testfile
 =========================     options: r256=record-size, s2=double space
 filename=/home/uvadm/dat1/custmas1 options=r256s2
 records=32 rsize=256 fsize=8192 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
 rec#=1 rsize=256 rcount=32 fsize=8192 fptr=0
 Enter command, or ?=Help, or null=NextRecord --> q  <-- Quit command

In this example we entered 'q' to quit after the 1st 256 bytes of the file was displayed, but we could have entered a record# or byte# to explore other areas of the file. Note that the current record# & byte# are displayed at the left of the two top lines (the 0-64 byte scale).

The uvhd display is especially useful for displaying data files that do not have line feeds & therefor are not easily displayed by an editor & for files with packed decimal fields.

Any non displayable characters is represented by periods on the character line (1st line of 3 vertical hex lines). The above sample has a lot due to the multiple packed fields.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

0A3. uvhd - file investigation hexdump utility

uvhd Display - default spacing + command prompts


 uvhd dat1/custmas1 r256k1   - display custmas1 with default spacing (not s2)
 =========================     options: 'r256'=rec-size, 'k1'=command prompts
 filename=/home/uvadm/dat1/custmas1 options=r256k1
 records=32 rsize=256 fsize=8192 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
 rec#=1 rsize=256 rcount=32 fsize=8192 fptr=0
 null=next,r#=rec,s=search,u=update,x=undo,p=print,i=iprint,w=write,e=count
 ,R#=Recsize,h1=char,h2=hex,g=genseq#,c=chkseq#,t=translate(ta,te,tu,tl,tc,tp)
 ,q=quit,k0=helpoff,k1=helpon,?=HelpScreens --> q  <-- Quit command
 Enter command, or ?=Help, or null=NextRecord -->

Notes

  1. Compare this display (without option 's2') to the prior page (with 's2'). Option 's2' (prior page) inserts blank lines between the 3 line groups of vertical hexadecimal (characters, zones, digits).

  2. The default display (no 's2' option) leaves no blank lines to allow larger records to be displayed on 1 screen without continuation screens.

  3. If you always wanted the 's2' option you could add 'export UVHDROP=s2' to your user login profile (also documetented on help screen 19).

  4. Option 'k1' (this page above) added 2 lines of command help prompts at bottom of display.

  5. Note that 'k1' is also a command (issued at the --> prompt) as well as an option (entered on the 'uvhd' initiation).

  6. The default is 'k0' (command prompts off). Just enter 'k1' to display the command prompts whenever you need reminders of available commands.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_1 uvhd - file investigation hexdump utility

Part 1 - download & compile


1A1. Download uvhd.c source from www.uvsoftware.ca
- Compile for Unix/Linux
- setup PATH for execution under Unix/Linux

1B1. Download uvhd.exe (EXEcutable for Windows)
- setup PATH for execution under Windows

1B2. Customizing the Command Prompt window for Windows
- changing small, ugly, black & white default to big, blue,& beautiful
 1B3. Compiling uvhd.c to uvhd.exe on Windows (using lcc-win32 or lcc MinGW)
     - not required, since you can download uvhd.exe from www.uvsoftware.ca

1C1. Customization for printing (Immediate print vs Print from a file)

1C2. Environmental variables to control print destination & script (lpi,etc)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1A1. uvhd - file investigation hexdump utility

Download uvhd.c & Compile for Unix/Linux

Assuming
  • you have already downloaded the program from www.uvsoftware.ca
  • you have a login on your Unix/Linux system (userxx for example)
  • your Unix/Linux system has an ANSI C compiler

 #1. Login userxx --> /home/userxx

 #2a. mkdir src               <-- make subdir for uvhd.c source program
      =========

 #2b. mkdir bin               <-- make subdir for compile output
      =========

 #3. cp ??/uvhd.c src/uvhd.c  - copy downloaded program to source subdir
     =======================    (ensure filename is 'uvhd.c')

 #4. cc -DH64 src/uvhd.c -obin/uvhd  <-- compile the program
     ==============================
     - option '-DH64' 64 bits (no big advantage, default handles files > 2 gig)
     - also add '-q64' for AIX

 #5. bin/uvhd bin/uvhd      - test uvhd (using uvhd itself as sample file)
     =================      - will display 1st 256 bytes & prompts for command
     --> s 'uvhd version' <-- suggested command to search for uvhd version
     --> ss               <-- repeat the search for other occurrences

 #6. Add bin to your PATH so you can execute it from anywhere.

     PATH=$PATH:/home/userxx/bin; export PATH
     ========================================

Customizing uvhd for each user via UVHDROP

You may export variable UVHDROP in the .profile to specify the preferred options for each user. For example, users who prefer 1 relative scales and space 2 for displays, may wish to add the following to their .profile:


 export UVHDROP=g1s2    <-- user options for 1 relative & space 2
 ===================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B1. uvhd - file investigation hexdump utility

Download uvhd.exe & Execute under Windows

uvhd runs in the Command Prompt window under Windows (XP,Vista,Windows7)

The simplest plan is to download uvhd.exe & store it in the 'Program Files' directory so windows will find it when you type 'uvhd'.

Here is an alternative plan if you prefer to store uvhd in a separate directory. This is consistent with the documentation tutorials & Help screen examples. It is also compatible with the installation of the entire package of Vancouver Utilities for Windows (in case you later decide to purchase them).

Setup separate Directories for uvhd & test files

C:\uvwin
  • super directory for Vancouver Utilities
C:\uvwin\binDOS
  • store downloaded uvhd.exe here
C:\uvwin\dat1
  • store downloaded test file 'custmas1' here
C:\uvwin\tmp
  • tmp subdir used by uvhd for write selections, etc

Setup PATH - for Windows


 #1. ControlPanel -> System -> Advanced -> Environmental Variables

 #2. New or Edit (depending on whether PATH is already defined or not)

 #3. PATH   C:\uvwin\binDOS
     ======================

Setup PATH - for DOS (obsolete)


 #1. EDIT C:\AUTOEXEC.BAT

 #2. SET PATH=%PATH%;C:\uvwin\binDOS

uvhdcob - alternate version for COBOL shops

'uvhdcob' displays COBOL copybook fieldnames with the corresponding data. See complete details in section uvhdcob.doc.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B2. uvhd - file investigation hexdump utility

Customize Windows Command Window

This is optional, but it is highly recommended, since it converts the default small & ugly black & white command window to a beautiful blue experience. The following was tested on a 17 inch monitor.

  1. Create a shortcut to the command prompt on your desktop.

  2. Right click on the shortcut & click on properties. You will get a 'Command Prompt Properties' window with several menu choices (General, Shortcut, Options, Font, Colors).

  3. On the Shortcut menu, update Startin & Run as follows:


 #3a. Startin --> C:\uvwin
 #3b. Run --> Maximized    (choices: Normal, Minimized, Maximized)
  1. On the Layout menu, update Screen buffer size & Window size:


 #4a. Screen buffer size Width  --> 120
 #4b. Screen buffer size Height --> 300
 #4c. Window size Width  --> 112
 #4d. Window size Height --> 56
  1. On the Color menu:


 #5a. Screen background --> dark blue
Note
  • Setting Window size width to 112 allows use of option 'l100' on 'uvhd'
  • line width of 100 characters is preferred by most users

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B3. uvhd - file investigation hexdump utility

compiling uvhd for WINDOWS

uvhd has been compiled on Windows using the command prompt window. I used the lcc-win32 compiler which may be downloaded from www.cs.virginia.edu.

You do not need to download lcc-win32 & compile uvhd for Windows/Dos since I have already compiled it and you may download uvhd.exe from the UV Software website www.uvsoftware.ca. In case you are interested, here are procedures that could be used to compile uvhd for Windows. Please see WindowsDOS.htm#E3 for the exact procedures used at UV Software.

Directories used to compile on WinDos

D:\lcc\bin
  • holds the lcc-win32 compiler
  • PATH must include this directory
D:\uvwin\src
  • directory of UV programs on Windows
D:\uvwin\cctmp
  • temporary directory for compiles
D:\uvwin\bin
  • directory of UV executables on Windows
  • PATH must include this directory
D:\uvwin\dat1
  • directory of test files
  • custmas1 test file with packed decimal fields

Windows compile with lcc-win32


 #1. cd D:\uvwin
 #2. copy src\uvhd.c cctmp - copy master source to cctmp for compile
 #3. cd cctmp
 #4. lcc -DDWIN uvhd.c     - compile uvhd source to object
     =================
 #5. lcclnk uvhd.obj       - link uvhd object to executable
     ===============
 #6. cd ..
 #7. copy cctmp\uvhd.exe binDOS  - copy uvhd.exe to the binDOS subdir on WinDos
 #8. uvhd dat1\custmas1 r256     - execute/test uvhd on custmas1 demo file

Windows compile with MinGW gcc

In Dec2011 I switched to gcc MinGW (Minimalist GNU) to compile for Windows See instructions at www.uvsoftware.ca/windowsdos.htm#G1 - G5 After MinGW installed, directories setup & VU files copied as page G1-G2


 mgcc1 uvhd H32   <-- compile uvhd for Windows (page G5)
 ==============

See the gcc compile script 'mgcc1.bat' at /home/uvadm/batDOS/mgcc1.bat or at C:\uvwin\batDOS\mgcc1.bat

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1C1. uvhd - file investigation hexdump utility

uvhd Printing - Customizing

Note that the print command 'p' does not print immediately, but collects output (from possible multiple print commands in a uvhd session) into a tmp/file, which is subsequently printed manually after you quit uvhd.

Or, you can specify option 'i' on the 'p' command for 'i'mmediate printing. The immediate print option 'i' uses the command stored in the variable 'prtcmd' in the uvhd.c source code.


 char prtcmd[30] = "uvlp12";       /* default iprint command */
 ===========================

The 'uvlp12' script is part of the Vancouver Utilities package that calls the 'uvlist' utility (has many options for cpi, landscape, etc).

If you also specify option 'l' on print command then prtcmdW is used. You would probably do this when you wish to print 100 chars per line but view the 64 chars per line on then screen.


 char prtcmdW[30] = "uvlp12L";     /* default when option l on p/i cmd */
 =============================

If desired, you could change these commands to use the 'lp' command directly (vs the uvlp12/uvlp12L script defaults).


 char prtcmd[30] = "lp -onobanner -dlaser1";  /* specify lp vs uvlp12 scripts */
 ===========================================

iprint command defaults for Windows

If you are running uvhd in the command window of a Windows system (95,XP,Windows7,etc), then the print commands default to the following:


 char prtcmd[30] = "uvlpr12";     /* default iprint for Windows */
 ===========================

 char prtcmdW[30] = "uvlpr12L";   /* default iprint if option l on Windows */
 =============================

'uvlpr12/uvlpr12L' are Windows batch scripts & the full names are uvlpr12.bat & uvlpr12L.bat. They are stored in subdir C:\uvwin\batDOS. These batch scripts redirect output to LPT1.

'uvlp12/uvlp12L' are Unix/Linux Korn shell scripts & are stored in subdir /home/uvadm/sf/util/. These Korn shell scripts pipe output to 'lp'.

Note that uvlpr12/uvlpr12L are used when compiled for native Windows with compile variable 'DWIN'. See install guide WindowsDOS.htm for Windows (vs install.htm for Unix/Linux).

When uvhd.c is compiled for Unix/Linux emulators (SFU/UWIN/CYGWIN) that run under Windows, then uvlp12/uvlp12L unix scripts will still apply.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1C2. uvhd - file investigation hexdump utility

environmental variables for Immediate printing

A more convenient method of modifying Immediate printing is to use the environmental variables 'UVLPDEST' & 'UVHDPRINT'. You could export them at your shell prompt before running uvhd or even better setup your normal choices in your .profile. Here are some examples:

 export UVLPDEST=-dlaser2     <-- setup printer dest for all 'uvlp' scripts
 export UVHDPRINT=uvlp12      <-- the default script uvlp12 for 64 chars Portrait
 export UVHDPRINT=uvlp18      <-- could specify uvlp18 to get 128 chars Portrait
 export UVHDPWIDE=uvlp12L     <-- UVHDPWIDE script used when option 'l'
                                  specified on print/iprint commands
                                - uvlp12L gets 100 chars on Landscape
                                - uvlp14L gets 128 chars on Landscape

prtcmdW or UVHDPWIDE is used if you specify the 'l' option on print/iprint commands, for example:

 --> p5il100            <-- prints next 5 records, 100 chars per line
                            Landscape at 14 cpi to fit 11" across
 --> p5il128            <-- can get up to 128 chars Landscape at 14 cpi
 --> p5i                <-- would default to 64 chars per line Portrait
                            (possibly modified by 'l' command line option)

env-vars for printing on Windows

The default scripts for printing on Windows are uvlpr12 & uvlpr12L. These are defined within the uvhd.c program & are used if no environmental variables are defined. These are equivalent to the following:

 set UVHDPRINT=uvlpr12     <-- specify batch script for 64 chars Portrait
 set UVHDPWIDE=uvlpr12L    <-- UVHDPWIDE script used when option 'l'
                               specified on print/iprint commands

For Windows you could define on the following screen:

ControlPanel --> System --> Advanced --> Environmental Variables

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_2 uvhd - file investigation hexdump utility

2H01. HELP menu, uvhd version 20190226


2H01. Help screen menu, enter 2-24 for desired help screen
2H02. command line options a-i
2H03. command line options k-z
2H04. Browsing, jump to byte# or rec# (fixlth), see 'H21' find varlth
2H05. Search by data strings with optional qualifiers
2H06. Search commands continued
2H07. Update (u) & Rollback (x/X)
2H08. Update - more examples
2H09. Enumerate/count(e) records (all or with specified data in fields)
2H10. Accumulate(a) record field (zoned/packed/binary)(all or qualified)
2H11. Write selected records to date/time stamped filename in tmp/ subdir
2H12. Write options (a=ASCII,c=chars,r=recsize to write,t=terminator,etc)
2H13. Print - writes to tmp/filename_date_timeP, option i print Immediate
2H14. Translate to Ascii,Ebcdic,Upper,Lower,Characters,Periods
2H15. sequence number checking & generating
2H16. Scan/Replace (v)
2H17. Move character (m) & move Numeric (n), Example on 'H18'
2H18. Move Example, reformat customer master into telephone list
2H19. Konvert among numeric formats (zoned, packed, binary/hex)
2H20. Drop records, writes backup to tmp/ in case restore required
2H21. Truncate files & option t=multi-byte record terminators in hex
2H22. find records by record# in large variable length files
2H23. Index file saved in tmp/..., saves for next uvhd if same file&size
2H24. uvhd Tips & Techniques (saving keystrokes)
2H25. Customizing uvhd for User Preferences re Options & Printing
2H26. uvhd version 20190226, Free Software Licensed under GNU FSF GPLv3

2H02. command line options (a-i)


 uvhd dat1/custmas1 r256s2u  <-- Example (r256=recsize,s2=space2,u=updates)
 ==========================
 - options entered as arg 2 on uvhd command line, must be contiguous string
 - options are lower case alphabetics (optionally followed by numeric value)
 a1  - translate to Ascii, character line (prior to zone & digit lines)
 b#  - Begin display fileptr, used by uvhdcob exit to uvhd show same record
 c1  - display extended ASCII Chars values 128-255 (vs showing as periods)
 d1  - inhibit display blank/null 64 byte segments, except 1st in record
 d2  - compress multi-blanks to 1, for Text files with large blank areas
 d4  - show file Dsplcmnts on all segments vs only 1st segment of record
 e1  - no Errmsg filesize/recsize not divisible, e2=no recsize calc, e3=both
 f1  - build Index for Variable-Length files (BDW/RDW,IDXf8,text)
     - build Index for Fixed-Length files NOT required, can calc fileptrs
 f0  - inhibit Index build (save time if only need to see 1st few records)
 f3  - force Index re-build even if existing & filesize unchanged
 g0  - zero relative column scale (default)
 g1  - 1 relative dsplcmnts on displays & commands (search,update,etc)
 h#  - h0=hex display (default), h1=force characters only, h2=auto determine
 h2  - chars only or Hexadecimal (depending on data)
 i1  - Inhibit bold search patterns, i2=no BOLD errmsgs, i3=both(DOS dflt)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

               ** 2H03. command line options continued (k-z) **
 l#   - Line display width, default 64, max 1024
 m#   - Max lines/screen (default 24) allow for hex/char, sp1/sp2
 n#   - Number of records per screen (between prompts, for short records)
 o#   - inhibit column scale to every #records, use with n# records/screen
 p#   - progress message interval (search,index) record count default 1000000
 r#   - Record size, default 256, max 32768
 s#   - Space before: s1=scale, s2=data, s4=prompt, s8=after scale, s15=all
 t    - Text records ended by LF=x'0A' - standard unix/windows
 t=FF01 - may specify multi-byte terminator in hex, example for EBCDIC EOR
        - see '2H21' example for EBCDIC EOR t=FF01
 u    - allow Updates to file (will lock file) else read only
        applies to: Update,Move,V(scan/replace),Translate,Generate Seq#
 u2   - allow Updates w/o file-lock (in case lock problems on some unixs)
 v    - Variable length records Micro Focus Seqntl/Indexed IDXFORMAT3/8
 v4     show recs: v1=filehdr, v2=deleted, v4=active data, v8=all (dflt=v5)
 v4w8 - w8 round up Varlth recs to multiple 8 if recsize >4095 (use with v_)
 x    - STL records for AIX COBOL (Sequential, Indexed,or Relative)
 x#     x2=Sequential, x4=Indexed, x8=Relative
 x#y#   y4=show Deleteds, y1=show file Header, y2=show Systems, y7=show All
 x#y#j4 j4=inhibit showing valid data records, y4j4=show Deleteds only
 z#   - input RDW format (2,4,8 byte prefixes with recsize in binary)
 z2   - RDW prefix 2 bytes only, recsize EXCLUDES prefix size
 z4   - RDW prefix 4 bytes, recsize 1st 2, 3&4 nulls, recsize INCLUDES prefix
 z8   - BDW/RDW 4+4, BDW bypasswd, else like z4
 z1   - (+ 1 bit) = z3/z5/z9 Little-end binary, z2/z4/z8 default BIG-end
 ?    - display help (20 screens)

2H04. file Browsing commands

>>> uvhd commands begin here on 'H04' & continue thru 'H25' <<< uvhd commands are entered at --> prompt following each record display

 null - next record (or next segment if rcsz > 384)
 r#   - goto specific record# in the file (one relative)
      - fast & accurate for fixed-record-length files
 ###   - may omit 'r', a number assumed to be a record# (if Fixed-length)
 R#   - change Record size (vs option 'r' on command line)
 b#   - goto specific  byte#  in the file (zero relative)
 +#   - advance specified # of records (from current position)
 -#   - backup  specified # of records (from current position)
 +/-  - default 1 if no value specified
f#
  • find records by record# in LARGE variable length files (RDW,text,IDX)
f#
  • use 'f#' if you need exact record# in Large Variable-Length files
  • may omit 'f', find record# assumed if BDW/RDW variable length file
  • see 'H21' for options to Index & find records by size min to max

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H05. Search (1st of 2)


 uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#4A2
 =======================  - option r256=recsize, option u if updates intended
  - search for patterns until EOF (should goto rec #1 before 1st search)
  - try these on the custmas1 demo file, then try similar on your file
  - add 1 to following byte#s if you used option g1 for 1 relative (vs 0 rel)
 s 'LTD'           - search for 'LTD' anywhere in record
 ss                - repeat last search (starting from next record)
 s 0(60),'LTD'     - search for 'LTD' anywhere in 1st 60 bytes
 s 77(2),='BC'     - search for 'BC' in bytes 77-78 (match = assumed)
 s 77(2),!'BC'     - search for Not 'BC' in bytes 77-78
 s 120(5),x'000000000C'  - search for packed decimal zero field in 120-124
 s 120(5),!x'000000000C' - search for non-zero packed field in 120-124
 s 'ROAD',|,'STREET'     - search for ROAD or STREET anywhere in record (|=OR)
 s 'ROAD',|,'STREET',|,'DRIVE' - search for 3 patterns anywhere in record
 s 0(1),'1',77(2),'BC',90(3),'604'   - '1' in 0 And BC(77-78) And 604(90-92)
 s 0(1),'1',|77(2),'BC',|90(3),'604' - '1' in 0 Or BC(77-78) Or 604(90-92)
 s adrs1,value1,adrs2,value2,adrs3,value3 - 3 pairs of address & value
  - 'AND' is the default when 2 or 3 conditions are specified
  - 'OR' is signalled by the '|' (pipe symbol)
 s 120(4b),338  - search for binary value (custmas1 rec#3 x'00000152' 120-123)
 s 120(4bs),338 - need option 's' Switch ends for Big-end binary on Intel

2H06. Search (continued)


 uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#4A2
 ======================== - must specify option 'u' if updates intended
s 'LTD'
  • search (forward by default) for LTD anywhere in record
ss
  • repeat last search (starting from next record)
sss
  • repeat search (in same record incrementing byte#)
 s 77(2),'BC',242(4),>'1989',242(4),<'2000' - search for BC updated in 1990's
 s 77(2),'AB',|77(2),'AL'   - search for 'AB' or 'AL in 77-78
 s 77(2),'AB',|,'AL'        - same as above (2nd field defaults to 1st)
 s 77(2),'AB',|,'AL',|,'YK' - search for 'AB' Or 'AL' Or 'YK' in 77-78
 s 'LTD','ROAD','BC'        - searches entire record, all 3 must be found
 s 'LTD',|,'ROAD',|,'BC'    - searches entire record, any 1 found is a match
 s 77(2),'AL',,'LTD',,'ROAD' - search 'AL' in 77(2) & 'LTD' & 'ROAD' anywhere
   - if op3/op5 dsp(lth) omitted & op4/op6 constant lth not= op1/op2 length
     op3/op5 dsp(lth) defaults to search entire record for op4/op6 constant
 s 77(2),'AB',,'AL',,'YK' - cant work, if op4/op6 constant lth = op1/op2
   - then op3/op5 dsp(lth) default same as op1 (AND condition in same field)
 sn5 77(2),'BC'  - search for 5th occurrence of 'BC' in following records
 so5 77(2),'BC'  - search for 5th occurrence of 'BC' in any 1 record following
 s 77(2)  <-- HIGHLIGHT spcfd columns on all records (by omitting search data)
           - to identify desired fields & confirm col#s for subsequent search
 s 77(2),,120(5),,235(5)  <-- may HIGHLIGHT up to 3 fields

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H07. Update (u) & Rollback (x/X)


 uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#4A2
 ======================== - must specify option 'u' when updates intended
u 77(2),'AB'
  • update current record 77-78 with 'AB' (fixing some 'AL's)
x
  • rollback last update (repeat 'x' toggles last update)
uu
  • repeat last update (after moving to different record)
u99 77(2),'AB'
  • update All records from 1st to EOF (99 short for 999999999)
  • count 99 resets to 1st record & processes until EOF
  • u99 saves having to return to record#1 before update all
  • any other count does not reset (processes from current record)
  • no x/X rollback for multi-record updates (backup file 1st)

u99 77(2),'AB',77(2),'AL' - update next 99 recs with AB 77-78 if currently AL u99 77(2),'AB',,'AL' - same as above, 2nd adrs defaults to 1st u99 9(1),'*',8(1),'D',77(2),'BC' - update byte 9 '*', if 8 is 'D' & prov BC

 x/X - rollback last update or all updates to current rec
 x       - rollback last update to current rec (repeat x toggles last update)
 X       - rollback ALL updates to current rec (repeat X toggles ALL updts)
 x/X only for record on display & applies to both u(update) & v(scan/replace)
   - rollback applies only to 1 current record & ability lost if you move off

2H08. Update - more examples


 uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#4A2
 ======================== - must specify option 'u' if updates intended
 u 75(1),'*',77(2),'BC' - test conditional update on 1 (current) record
 uu99                   - repeat update on ALL records (99 short for 99999999)
                        - count 99 resets to 1st record & processes until EOF
               - OR for interactive updates, use 'ss' & 'uu' interleaved
 s 77(2),'BC'  - 1st search to qualifying record
 u 75(1),'*'   - 1st update to record on display
ss
  • repeat last search (s 77(2),'BC')
uu
  • repeat last update (u 75(1),'*')
  • can also use this for interleaved 'ss' & 'vv' (scan/rep)
 u99s 77(2),'AB',,'AL' - update bytes 77-78 with 'AB' if currently 'AL'
    s        <-- note option 's' on 'u99s' saves update args in search args
 1               for subsequent reset to BOF (by goto record #1)
 ss          <-- and 'ss' to verify updates (without re-entering arguments)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H09. Enumerate (e)


 uvhd dat1/custmas1 r256 - demofile#1 shown at www.uvsoftware.ca/uvhd.htm#4A2
 =======================
 e               <-- Enumerate/count all records from current position to EOF
 e99             <-- count 99 resets to 1st record & processes until EOF
                   - any other count does not reset (processes from current record)
 1                 - e99 saves having to return to record#1 before count all
 e500 77(2),'BC' <-- count (in next 500 recs) recs with BC in bytes 77-78
 e  77(2),'AB',|77(2),'AL'  - count records with AB or AL in bytes 77-78
 e  77(2),'AB',|,'AL'       - same as above (2nd adrs defaults to 1st)
 e  77(2),'BC',90(3),!'604' - count recs with BC in 77-78 & Not 604 in 90-92
e 'LTD'
  • count records with 'LTD' anywhere in file, anywhere in record
  • scans all records in file - when count omitted
  • scans all columns in record - when start(length) omitted
es 'LTD'
  • 's' option save args for later 'ss' search to inspect 1 by 1

lw/lp/lvw/lvp separate or combined write/print files

 lw  <-- may follow write command with 'lw' command to close file for separate
         output files or omit for combined outputs from multi write commands
 lp  <-- similar command close print files for separate or omit for combined

2H10. Accumulate (a)


 uvhdcob dat1/custmas1 mf/maps/custmas1 r256 - customer mstr sales history
 ===========================================
                    - see custmas1 demofile at www.uvsoftware.ca/uvhd.htm#4A2
 a 120(5p)        <-- accum 5 byte packed field from current record until EOF
 =========
 a99 120(5p)      <-- count 99 resets to 1st record & processes until EOF
                    - any other count does not reset (processes from current record)
 1                  - a99 saves having to return to record#1 before acum all
 a 120(5p),,77(2),'BC'              <-- acum if 'BC' in bytes 77-78
 a 120(5p),,77(2),'AB',|77(2),'YK'  <-- acum if 'AB' or YuKon
 a 120(5p),,77(2),'AB',|,'YK'       <-- acum if 'AB' or 'YK', omit 2nd 77(2)
 a 120(5p),,77(2),'BC',90(3),!'604' <-- acum if 'AB' and area code not=604
 ax12 120(5p)  <-- crossfoot & acum 12 x 5 byte packed fields (this yr sales)

 uvhdcob dat1/sales2 mf/maps/sales2 r64 - sales detail records
 ======================================
              - see sales2 demofile at www.uvsoftware.ca/uvhd.htm#4A3
 a 53(9)    <-- acum 9 bytes (assume unpacked Ascii, sign in zone or sep +/-)
 =======      - zone +sign x'3_', -sign x'7_' (Micro Focus COBOL compatible)
 a 53(9ze)  <-- acum 9 byte Zoned Ebcdic, +sign x'F_' or x'C_', -sign x'D_'
 =========    - do not need (_ze) if option 'a' on cmd line for EBCDIC input
 a 53(9zx)  <-- need (_zx) ASCII file with EBCDIC signs vs Micro Focus signs

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

H11. Write selected records to tmp/ subdir

 w   <-- write unformatted data records to tmp/ (smaller test files etc)
       - writes start at current position & end at EOF (or max count)
       - outputs written/appended to $UVTMPDIR/filename_yymmdd_hhmmssW
       - $UVTMPDIR defaults to tmp/ in your current dir (not system /tmp)
       - writes fixedlth if input fixedlth, else defaults to LF terminated

 w5              - write (unformatted) 5 records from current position
 ===
 w99 'VANCOUVER' - write all records with 'VANCOUVER' anywhere in record
                 - 'w99' is short for write ALL records from current to EOF
                 - count 99 resets to 1st record & processes until EOF
 1               - w99 saves having to return to record#1 before write all
 w25 77(2),'BC'  - write (25 max) records with 'BC' in bytes 77-78
 ww              - repeat last write command (from current position)
 w 8(1),'D',77(2),'AB',|,'AL' - write recs with 'D' in 8 & AB or AL in 77-78
ws10
  • select every 10th record (to make smaller test file ?)
w100e5
  • write 100 records, select every 5th (file must have 500+)
ws10 77(2),'BC'
  • select every 10th rec with province 'BC' (from here to EOF)
w100r64t2
  • sample Write command to Write next 100 records with options
  • r64=fixedsize 64 byte recs, t2=terminate with LF in last byte
w99z2a1c1
  • write next 99 recs in RDWz2 format (recsize in 2 byte prefix)
  • translate to ASCII, translate any unprintable chars to periods
  • see write options on next help screen

2H12. Write options

a1
  • translate write command output records to ASCII
d#
  • displacement to 1st byte to be written
e1
  • translate write command output records to EBCDIC
c1
  • convert unprintable chars in write output records to periods
n1
  • insert variable recsize as 4 numerics at BEGIN write output
n2
  • insert variable recsize as 4 numerics at END write output
r#
  • record size for fixed-length output, omit for RDWz2/z4
t1
  • append Carriage-Return at end write records (for MAC)
t2
  • append Line-Feed at end of records (default if input file not fixedlth)
t3
  • append both CR & LF at end write records (for some Windows programs)
t4
  • append after Last-Non-Blank, else at end recsize (t6 for LF)
z#
  • write RDW format (2 or 4 byte prefixes with recsize in binary)
z2
  • prefix 2 bytes only, recsize EXCLUDES prefix size
z4
  • prefix 4 bytes, recsize 1st 2, 3&4 nulls, recsize INCLUDES prefix
z1
  • (add 1 bit) = z3/z5 Little-end binary, z2/z4 default BIG-end binary
 w50d10r25t6 - Write next 50 records, option d10=dsplcmnt to 1st byte to write
             - r25=recsize to write, t6=terminate LF after last nonblank
  - would write just customer name field of demo file dat1/custmas1
 lw  <-- may follow write command with 'lw' command to close file for separate
         output files or omit for combined outputs from multi write commands

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H13. Print selected records to tmp/ subdir

 p  <-- print(write formatted records) to a file for subsequent lp,uvlp,vi,etc
      - writes $UVTMPDIR/filename_yymmdd_hhmmssP (concat for uvhd session)
      - $UVTMPDIR defaults to tmp/ in your current dir (not system /tmp)
      - export UVLPDEST="lp -dlaserxx" for unix lp (see 'H24' below)
 p5                - print 5 recs from current position
 p25 'VANCOUVER'   - search & print (25 max) records with 'VANCOUVER' anywhere
 p 77(2),'BC'      - search & print (til EOF) records with BC in bytes 77-78
 p 77(2),'BC',90(3),!'604' - print recs with BC in 77-78 & Not 604 in 90-92
 p 0(120),<x'20'     - print records with any bytes < space in 1st 120 bytes
 p9s2f3            - print 9 records, space 2, formfeed every 3rd record
 pp                - repeat last print command (from current position)
 lp  <-- may follow print command with 'lp' command to close file for separate
         output files or omit for combined outputs from multi print commands
 p5i <-- option 'i' Immediate print (Aug2011 change to option vs command 'i')
       - writes tmp/filename_yymmdd_hhmmssP & calls script uvlp12
       - script 'uvlp12' schedules 'lp' to print the tmp/... file immediately
         'export UVLPDEST=-dPRINTERNAME' in profile defines printer near you
       - see print control Environmental Variables on '2H25'
       - see uvhd doc for more info on immediate printing

2H14. Translate to Ascii,Ebcdic,Upper,Lower,Characters

 t  <-- translate to ASCII,EBCDIC,UPPER,lower,characters,periods
        ta=Ascii, te=Ebcdic, tu=Upper, tl=lower, tc=characters, tp=periods
 ta         - translate to Ascii, entire current record, (t1a is same)
 ta 0(120)  - translate to ASCII, 1st 120 bytes of current record
 ta 240(16) - translate bytes 240-255 (zero relative, 241-256 one relative)
 t99a    - translate to Ascii, ALL records in file (99 short for 999999999)
         - count 99 resets to 1st record & processes until EOF
 1       - t99_ saves having to return to record#1 before translate all
 te      - translate to Ebcdic, entire current record
 ts      - translate zoned Sign from mainframe to Micro Focus conventions
           positives {ABCDEFGHI->0123456789, negatives }JKLMNOPQR->pqrstuvwxy
 tu      - translate to Upper, entire current record
 tl      - translate to Lower, entire current record
 tc      - translate to Characters, any unprintables translated to blanks
         - unprintables are x'00'- x'1F' & x'7F'-x'FF'
 tc1     - translate unprintable Chars to blanks, except LineFeeds x'0A'
 tc2     - translate to Characters, except for Carriage-Returns x'0D'
 tc4     - translate to Characters, except for FormFeeds x'0C'
 tc8     - translate to Characters, except for Tabs x'09'
 tc15    - translate to Chars, except LFs,CRs,FFs,Tabs (1+2+4+8=15)
 tc3     - translate to Chars, except for LFs & Crs
 tp      - translate any unprintable Characters to periods
 tp15    - translate unprintables to periods, except LFs,CRs,FFs,Tabs
 t99p1 0(120) translate ALL records, unprintables to periods, except LF
 /*Apr04/06 - changed unprint char rep from period to carat */
 /*         - did not like, should change back              */
 /* - or provide 3 options tb=blanks, tc=carats, tp=periods */

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H15. sequence number checking & generating

 c        <-- check sequence in specified field - until EOF or SEQUENCE ERR
 c  0(6)    - check sequence in key field 0-5 (cols 1-6), show 1st out of seq
 cd 0(6)    - option 'd' to check sequence descending (vs ascending default)
 ce 74(6)   - option 'e' to consider EQUAL keys out-of-sequence
 ci 74(6)   - option 'i' to check sequence number increment by 1
 ci10 74(6) - option 'i10' to check sequence number increment by 10, etc
 cc         - repeat last sequence check (from current position to EOF)
g99 75(5),'00001'
  • generate seqnums in cols 76-80 incrmnt by 1 from 00001
  • on all records from 1st to EOF (999 short for 999999999
  • any other count does not reset (processes from current record)
  • count 99 resets to 1st record & processes until EOF
g
  • if count omitted sequence# inserted only in current record
  • must specify 'u' option on command line (like update)
g10 75(5),'00001'
  • generate seq# on next 10 records (vs g99 ALL records)
gg20
  • repeat(gg) seq# on next 20 recs, same cols & inc as prior
 gi10 72(8),'#00010.' - seqnum cols 74-79 from 000010 incrmnt by 10
        - any non-numeric data is inserted before & after the seqnum digits
 g  74(6),'A00001',0(1),'A' - conditional seqnum, if col 1 = 'A'
 r1                         - return to record #1 before next command
 g  74(6),'B00001',0(1),'B' - conditional seqnum, if col 1 = 'B'

2H16. Search/Replace (v)

 v    <-- search/replace, scan for search string & replace with alternate
        - will truncate or blank fill if search/replace string lengths unequal

 uvhd dat1/custmas1 r256u - demo file layout at www.uvsoftware.ca/uvhd.htm#4A2
 ======================== - must specify option 'u' if 'v' updates intended
 v 10(25),'LTD','LIMITED' - replace 'LTD' with 'LIMITED' anywhere in 10-34
       - will lose any data pushed beyond byte 34 (fixed length record/fields)
 v99 35(25),'RD.','ROAD'  - change RD. to ROAD til EOF (99 short for 999999999
 v99 35(25),'RD.','ROAD',77(2),'BC' - replace only if BC in 77-78
                   - count 99 resets to 1st record & processes until EOF
                   - any other count does not reset (processes from current record)
 1                 - saves having to return to record#1 before search/replace all
 v99 'RD.','ROAD'         - a big mistake for fixed length record layouts
 v99 0(256),'RD.','ROAD'  - same as this, entire record would be shifted

 uvhd tf/tabtest1 t <-- demo TEXT file with tabs (unix expands to 8 spaces)
 ==================   - option 't' Text file, 'u' not req'd to write sep file
 v99 x'09','    '  <-- replace tabs (x'09') with 4 spaces (tf/tabtest1 file)
                      - omitting dsp(lth) causes scan/rep entire record
 /*Nov25/10 - write option on scan/replace removed */
 /*"v99w 35(25),'RD.','ROAD' - option 'w' to write separate file to tmp/...*/
 /*"   - writes tmp/filename_yymmdd_hhmmssV (Text records, this field only)*/
 /*"v99s 35(25),'RD.','ROAD' - option 's' save args for 'ss' search/verify */
 /*"   - records written to tmp/... will be expanded/contracted as required*/

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H17. Move character & move Numeric


 uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#4A2
 ======================== - must specify option 'u' when moves intended
 m 35(12),90       <-- Move character (m), omit op2 lth assumes same as op1
 m 35(30),90(12)   <-- move 90-101 to 35-46, 47-64 extra op1 length blanked
 n 64(9z),120(5p)  <-- move Numeric (n), unpacks 5 bytes into 9 bytes Zoned
 n 130(5p),64(9z)  <-- move Numeric (n), 9 zoned bytes to 5 packed bytes)
 n 51(4b),120(5p)  <-- move Numeric, 5 bytes packed to 4 bytes binary
 n 64(9ze),120(5p) <-- move Numeric, unpacks 5 bytes into 9 bytes Zoned EBCDIC
                   - data type codes z/p/b (z default) 1st alpha after length
                   - Ascii/Ebcdic codes a/e (a default) 2nd alpha after length
 n 120(5p),123456  <-- move Numeric value (length omitted) to 5 bytes packed
 nx12 120(5p),0      - use with option 'x' to clear multiple contiguous fields
 n99x12 120(5p),0  <-- clear 12 mth sales in all records (99 means 999999999)
                     - n99 repeats moves on all records until EOF reached
                     - count 99 resets to 1st record & processes until EOF
 n 120(5p),0,,77(2),='BC' <-- clear 5 bytes packed (move 0) if province 'BC'
                            - conditional moves via qualifiers in op3-op6
 x             <-- use 'x/X' to rollback (only for moves on 1 record)

2H18. Move Example

 Move Example - create Telephone-List from custmas1 demo file (layout follows)
 00-05 cust, 10-34 cust-name, 35-89 address, 90-91 tel#, 120-240 packed fields
 desired: move tel# after cust-name, blank fill,& write 64 byte text records
              - see this example illustrated at www.uvsoftware.ca/uvhd.htm#4K1

 cp dat1/custmas1 tmp/cm1  <-- 1st copy custmas1, rename (not final output)
 ========================

 uvhd tmp/cm1 r256u        <-- run uvhd with Update option 'u'
 ==================

 m99 35(30),90(12)         <-- Move tel# after cust-name & blank to 64
 ==================          - on all records (99 short for 999999999)

 w99r64t6                  <-- Write, max Recsize 64, Textfile option 't6'
 =========                   - t6 appends LF after last nonblank

 cp tmp/cm1_yymmdd_hhmmssW dat1/tellist <-- copy/rename date_time_stamped
 ======================================     tmp file output as desired

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H19. konvert numeric,packed,binary/hex

 'k' converts between numeric formats (zoned, packed, binary/hex)
   - results displayed only, records not updated, programmer convenience

 uvhd dat1/testbnp1 r128 <-- file to demo binary,numeric,packed conversions
 =======================
                  10        20        30        40        50        60
 r#    1 0123456789012345678901234567890123456789012345678901234567890123
       0 0000001 0000256 0004096 0065536 1048576 .... .... .... .... ....
         3333333233333332333333323333333233333332000020000201002000020010
         0000001000002560000409600065536010485760100000100000000001000000
      64 ....... .....%l ......l ....eSl ....HWl .... .... .... .... ....
         0000001200000262000000620000656200014562000020000200102000020100
         000000C0000005C0000049C0000053C0000087C0000100010000000010000000
 Binary 40(4b),45(4b),50(4b),55(4b),60(4b) are Little-End (Intel,x86 Solaris)
 Binary 104(4b),109(4b),114(4b),119(4b),124(4b) Big-End (Sparc,AIX,HPUX,RISC)
 k 40(4b) =1, k 45(4b) =256, k 50(4b) =4096, k55(4b) =65536, k60(4b) =1048576
 k 40(4b)   --> 1          <-- x'01000000' on little-End machines (Intel, this doc)
 k 40(4bs)  --> 16,777,216 <-- option 's' Switch ends, shows value on other end
 k 104(4b)  --> 16,777,216 <-- x'00000001' on Big-End machines (AIX,SPARC,HPUX)
 k 104(4bs) --> 1          <-- option 's' on Big-End shows little-end value
 k x'00010000' --> 256 <-- may also enter a constant to convert (hex to numeric)
 kh4 '256'     --> 00010000 <-- convert numeric constant to Hex 4 bytes

2H20. Drop records

drop
  • writes 3 date/time stamped files to $UVTMPDIR/ (default tmp/)
    tmp/filename_yyyymmdd_hhmmssB - Backup file (all records)
    tmp/filename_yyyymmdd_hhmmssC - Corrected file (after drops)
    tmp/filename_yyyymmdd_hhmmssD - Dropped records file
 drop resets to record#1 to ensure entire file is backed up before drop
 After 3 files copied to tmp/, 'C' file copied back overwriting original
 - reopened as the new input file, & a prompt issued for next command
 If no unique pattern exists, could update with unique flag in unused byte
 - then return to record#1 & issue drop based on the unique flag
 d 8(1),'D'              - copy to tmp/ dropping records with 'D' col 9
 d 8(1),>'C',77(2),='BC' - drop records based on 2 patterns
 da100b199               - drop records within range 100-199
 da100b199c500d599       - drop records 100-199 & 500-599
 options a/b & c/d will drop by record# ranges
 option p  controls action when both range & pattern specified
        p0 - drop only if pattern match within range
        p1 - drop either wwithin range or by pattern match
 da100b199 8(1),'D' - may combine drop by rec# ranges with drop by patterns
 d500a100b199  - could limit no of records output (d500 would output max 500)
 d99a100b199   - 'd99' means process to EOF (same as omitting number after d)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H21. Truncate file

z
  • modify filesize (truncate or extend with x'00's)
z100000
  • truncate file to 100,000 bytes
  • works on Unix,Linux,Windows/SFU, but not on Windows/DOS

multi-byte hexadecimal record terminators


 uvhd dat1/testEORt1 at=FF01  <-- example EBCDIC End-Of-Record
 ===========================
                 10        20        30        40        50        60
 r#   1 0123456789012345678901234567890123456789012345678901234567890123
      0 dat1/testEORt1 - test uvcp typ=EORt1 translate to EBCDIC..
        88AF6A8AACDDAF464A8AA4AA894AA97CDDAF4A989A98A84A94CCCCCCF0
        413113523569310003523045370387E5693103915231350360523493F1
                 10        20        30        40        50        60
 r#   2 0123456789012345678901234567890123456789012345678901234567890123
     58 & append x'FF01' at EOR, depending rcs= on fili1/filo1     ..
        548998984A7CCFF748A4CDD64889898898498A749948898F68899F44444F0
        0017755407D6601D0130569B04575549570932E06506939116936100000F1
Note
  • uvhd options 'at=FF01'
  • option 'a' translates char line to ASCII (zones/digits lines EBCDIC)
  • option 't=FF01' specifies End-Of-Record ID for uvhd (new Jan 2015)

2H22. find by record#

f#
  • find records by record# in LARGE variable length files (RDW,text,IDX)
  • use 'r#' OK for Fixed-Length files, NOT for Variable-length
f#
  • use 'f#' if you need exact record# in Large Variable-Length files
f#
  • uses an Index of record#s & filepointers to find records quickly
  • Index built at program startup if variable lth input (RDW,text,IDX3/8)
 ### - can omit the 'f' or 'r' of record#, uvhd will determine the filepointer
     - based on the file type (calculate if fixed, use index if variable)

option m & n to find records by size

r1
  • might return to record #1 before using options m & n
f99m123
  • option 'm' to find record with specified record-size
f99m50n90
  • option 'm' & 'n' to find records from minimum to maximum size
  • 'f99' used to search to EOF (99 is short for 999999999)
ff
  • repeat prior find command, to find next rec with m & n size
ff
  • 'ff' saves retyping big numbers & options m & n

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H23. Index file saved for re-use


 uvhd dat1/testBDWRDW z8a    <-- demo uvhd on BDW/RDW testfile
 ========================
 vi tmp/uvhdindex_testBDWRDW <-- investigate saved Index file
 ===========================   - sample Index save file listed below

 #01:uvhdindex_testBDWRDW
 #02:filesize=999999,fileptr1=999900,options=z8
 #03:IndexCreated=110428_110305,BuildTimeSeconds=0
 #04:BDWmin=536,BDWmax=536,BDWavg=536,Blocks=2
 #05:RCSZmin=28,RCSZmax=28,RCSZavg=28,Records=38
 #06:1=0,2=32,3=60,4=88,5=116,6=144,7=172,8=200,9=228,10=256,11=284,12=312,
 #07:13=340,14=368,15=396,16=424,17=452,18=480,19=508,20=540,21=568,22=596,
 #08:23=624,24=652,25=680,26=708,27=736,28=764,29=792,30=820,31=848,32=876,
 #09:33=904,34=932,35=960,36=988,37=1016,38=1044,38=1072,

2H24. uvhd Tips & Techniques

  tip#1 - use command repeats to save keystrokes
        - use 'double letter commands' to repeat prior cmd w/o rekeying args
     ss - repeat last search, uu - repeat last update, mm - repeat last move
        - 1st re-position to desired rec before executing repeat command
        - or '1' to return to begin file to include all recs
    ww5 - may specify count on repeat commands, if original was 'w5 0(1),'A''
          ww5 would write next 5 recs with A in 1st byte (bypassing non 'A's)
 tip#2 - Transfer Search arguments to other commands (w,e,p,i)
       - allows you to verify correct arguments before other commands:
       - then transfer verified args to desired command w/o having to re-key
         for example, we could specify args on search & transfer to write:
   s 77(2),'BC',242(4),>'1997'  - search for BC records newer than 1997
   w=s                          - transfer Search args to Write command
   ww99                         - Write out selected records until EOF
       - transfer also applies to Enumerate(e=s), Print(p=s)
 tip#3 - using NOT '!' condition, can use to find exceptions to most records
       - for example to find any provice codes that are NOT 'BC'
   s 77(2),!'BC'      <-- display records with province codes NOT = 'BC'
   w99 77(2),!'BC'    <-- write NON 'BC' records to tmp/filename_date_time

s 77(2) <-- HIGHLIGHT spcfd columns on every record (by omitting search data)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2H25. Tips & Customizing uvhd (User Preferences)

 tip#4 - '99' is short-code for 999999999 (IE - all records in file)
         w99  <-- Write All records until EOF
 tip#5 - coding constant types for EBCDIC files vs ASCII default
       u 77(2),e'AB' <-- may code e'...' for Ebcdic vs c'...' for ASCII
       u 77(2),'AB'  <--BUT, may omit if option 'a' on command-line
 Add Environmental Variables to .profile, saves options on command line
 - for example setup option 'g1' if you prefer one relative to zero relative
 export UVHDROP=g1   <-- user preference options example
                         g1=one relative byte#s (vs 0 rel default)
 Environmental Variables for print option 'i' (Print Immediate)
 export UVTMPDIR=tmp       <-- directory default for tmp files (print,write)
 export UVLPDEST=-dlaserxx <-- specify printer destination for 'pi' command
 export UVHDPRINT=uvlp12   <-- specify print script for 64 char lines
                             - uvlp12 is UV script for laser Portrait printing
 export UVHDPWIDE=uvlp12L  <-- recommended script for Landscape 100+ chars
                             - UVHDPWIDE used if you specify 'il100'
 export UVHDPRINT="lp -dlaserxx" <-- may specify standard unix lp command
 export UVHDPWIDE="lp -dlaserxx -onobanner" - for 64 chars or 100 chars
                  ** 2H26. Program Licensed under GPLv3

'uvhd' is a binary file investigation utility. It displays any file in vertical hexadecimal and prompts for commands to browse, search, select, update, scan/replace, print, translate, etc. uvhd is an interactive utility with a command line interface and 26 help screens. See free download info at: www.uvsoftware.ca/freestuff.htm

Licensed under GNU FSF GPLv3

This program is free software: you may redistribute it and/or modify it under the terms of GPLv3 (GNU General Public License version 3), as published by the Free Software Foundation. See the full description of the GNU General Public License at: https://www.gnu.org/licenses.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

uvhd version 20190226, from Owen Townsend, UV Software, owen@uvsoftware.ca

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_3 uvhd - file investigation hexdump utility

Part 3 - options & commands summary


3A1. command line option summary

3B1. command/function summary

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3A1. uvhd - file investigation hexdump utility

Command Line Options


 uvhd filename [options] - display the named file on the screen
 =======================   in 64 byte lines (see display format above)

Options must follow the filename as 1 string of alpha & numeric values. If omitted, option 'r' record size defaults to 256


 uvhd dat1/custmas0 r256a1s3  <-- example showing multiple options
 ===========================    - recsize, Ascii translate, space lines
a
  • translate to ASCII, character line (prior to zone & digit lines)
    zone & digit lines will still reflect the EBCDIC values
  • also causes any constants entered on commands (search,update,etc)
    to be translated from ASCII entry to EBCDIC (to match datafile)
  • also causes fill chars to be EBCDIC blanks on write commands
  • Always specify option 'a' for EBCDIC files
b#
  • Begin display fileptr, used by uvhdcob exit to uvhd to show same record
  • uvhd display shows all data vs uvhdcob shows 1st 36 bytes of long fields
c1
  • display extended ASCII chars values 128-255 (vs showing as periods)
d1
  • Drop blank lines (for Text files)
d2
  • compress multi-blanks to 1, for Text files with large blank areas
d4
  • show file Dsplcmnts on all segments vs only 1st segment of record
e1
  • no errmsg filesize/recsize not divisible, e2=no recsize calc, e3=both
f0
  • inhibit build Find index (faster start for large Fixed length files)
g0
  • zero relative column scale (must enter zero relative displacements)
g1
  • one relative column scale
  • also allows you to enter 1 relative displacements on commands
    --> s 1(80),'XX' <--vs--> s 0(80),'XX' <-- search 1st 80 for XX
h0
  • auto determine display: chars only or hexadecimal (depending on data)
h1
  • force characters only (inhibit hex zone/digit lines)
h2
  • force vertical hexadecimal display
i1
  • inhibit BOLD highlighted search patterns (for dumb terminals)
i2
  • inhibit BOLD errmsgs (b3=both - DOS default)
l99
  • declare the line size (how much to display on each screen line)
  • default 64 bytes, max 64 bytes
  • might specify 50 if your rcsz was 50, 100, 150, 200, etc

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3A2. uvhd - file investigation hexdump utility

Command Line Options (continued)

 m#    - max lines/screen (default 20) allow for hex/char, sp1/sp2
 n#   - number of records per screen (between prompts, for short records)
 o#   - inhibit column scale to every #records, use with n# records/screen
 p#   - progress message interval (search,index) record count default 1000000
r9999
  • declare a record size other than the default 256 bytes
  • max 32768, max display segment is 384 per screen
s#
  • space options for record display & printing
s1
  • space before the scale
s2
  • space before the data segments (3 line groups of chars/zones/digits)
s4
  • space before the prompts at the end of each record display
  • you may binary combine these options, for example
s3
  • space before scale & before data segments (s1+s2=s3)
s7
  • maximum spacing (s1+s2+s4=s7)
t
  • End Record Markers for variable length TEXT records (vs fixed records)
t1
  • records ended by CR=x'0D' - unusual, old Macs, obsolete ?
t2
  • records ended by LF=x'0A' - standard unix/windows
t3
  • records ended by LF+CR (x'0D0A'), redundant on input (y3 for output)
u
  • required for update capability, else read only
  • must enter on command line if you intend to use instructions:
    u=update, v=scan/replace,or t=translate
v#
  • Micro Focus Variable length Indexed/sequential files IDXFORMAT3
  • the numeric value indicates records to be displayed or printed
v4
    v1=filehdr, v2=deleted, v4=data, v8=all/system
    (default is v5 = file header & data records)
v4w8
  • w8 round up Varlth recs to multiple 8 if recsize >4095 (use with v_)
 x    - STL records for AIX COBOL (Sequential, Indexed,or Relative)
 x#     x2=Sequential, x4=Indexed, x8=Relative
 x#y#   y4=show Deleteds, y1=show file Header, y2=show Systems, y7=show All
 x#y#j4 j4=inhibit showing valid data records, y4j4=show Deleteds only
z4
  • RDW, variable lth, recsize 1st 2 bytes binary, bytes 3&4 x'0000'
    recsize includes prefix-size + data-size (z/z0 default z4)
z2
  • RDW, prefix 2 bytes only, recsize excludes prefix size
  • z2/z4 default Big-end binary, specify z3 or z5 for little-end binary

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3A3. uvhd - file investigation hexdump utility

command line option examples

uvhd dat1/custmas1 r256 - display the file as 256 byte records (default)

 uvhd file r128aus2g1     - may concatenate all options
 uvhd file r128,a,u,s2,g1 - or may separate with commas if desired
           r128           - recsize=128
                a         - translate character line to ASCII (for EBCDIC files)
                          - constants on commands will be translated to EBCDIC
                  u       - allow update commands to be used
                    s2    - space between 3 line segments (chars/zones/digits)
                       g1 - use 1 relative column scale (vs zero relative)
                          - also expects you to enter 1 relative displacements
                            on the commands (search, update, etc)
uvhd file r100l50
  • display 100 byte records on 2 lines of 50 bytes each
    (note 'l50' is the 'l' ell option)
uvhd file t2
  • determine rec size via linefeeds (vs fixed 256 bytes)

OPTION RULES

  1. Options may be entered on the program command line following the command name & the filename.

  2. The program design allows for 26 option codes (26 letters of alphabet).

  3. An option letter may be followed by a value pertaining to that option.

  4. Options must be contiguous (no spaces between the option codes). but you may separate with commas if desired

  5. You may setup your preferred options via an environmental variable in your .profile (so you don't have to enter on command line every time). You might use this for the 'g1' option (one relative scale vs zero rel).

    export UVHDROP=g1     <-- force 'g1' on all subsequent uvhd commands

Note that you could still override this on the command line

    uvhd file r256g0      <-- 'g0' on command line overrides UVHDROP=g1

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3B1. uvhd - command/function summary

uvhd commands - Browsing

null
  • defaults to continuing display from current position
r#
  • goto specified record# within the file (one relative)
  • may omit 'r', goto record# assumed if Fixed-Length files
    OR 'f' find assumed for Variable-Length files
f#
  • find records by record# in LARGE variable length files (RDW,text,IDX)
f#
  • use 'f#' if you need exact record# in Large Variable-Length files
f#
  • uses an Index of record#s & file-pointers to find records quickly
  • Index built at program startup if variable lth input (RDW,text,IDX3/8)
 ### - can omit the 'f' or 'r' of record#, uvhd will determine the filepointer
     - based on the file type (calculate if fixed, use index if variable)
b#
  • goto specified byte# within the file (zero relative)
 +#   - go specified # of records ahead from current position
 +    - '+1' assumed (same as null entry, which is easier)
 -#   - go specified # of records back  from current position
 -    - '-1' assumed
R#
  • change record size & re-display current record

uvhd commands - Actions

s
  • search for a data pattern starting at a specified byte or within a range
  • may qualify matches by 1 or 2 patterns in other specified bytes
u
  • update records in specified bytes with new data
  • update 1 record at a time or update next number of records or to EOF
  • may qualify updates by 1 pattern in the same or other fields
e
  • enumerate (count) records from current position to EOF
  • may qualify matches by 1 or 2 patterns in other specified bytes
a
  • accumulate 1 record field (numeric,packed,binary) & display total at EOF
  • may qualify records accumulated by 1 or 2 patterns in specified bytes
w
  • write, write unformatted records to the 'tmp' subdirectory
  • assigns filename as tmp/filename.yyyymmddHHMMW
    (example: tmp/custmas1_971130_154500W)
Note
  • the write command is a very handy way to create test files
  • you can select specified number of records by patterns
  • change file location & repeat previous search/selection criteria.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3B2. uvhd - command/function summary

p
  • print, write formatted records to a temporary file,
    for later print/display via: lp, uvlp12, vi, etc
  • assigns filename as tmp/filename.yyyymmddHHMMP
  • print the next specified number of records or until EOF (with 'p99')
  • may qualify prints with 1 or 2 patterns in other specified bytes
i
  • immediate print, write formatted records to a temporary file,
    which is immediately printed via 'uvlp12' (lp for download version)
  • may qualify iprints with 1 or 2 patterns in other specified bytes
t
  • translate to Ascii, Ebcdic, Upper, Lower, Characters, Periods
  • unprintable Characters can be translated to blanks or Periods
c
  • check sequence on specified field (until EOF reached)
  • displays 1st record not in sequence (or EOF all OK)
g
  • generate sequence numbers on specified no of records or until EOF
  • may specify starting value of seqeunce# field
  • may qualify with 1 patterns in other specified bytes
v
  • scan/replace, search data fields replacing a specified pattern,
    with an alternate (which may be of different length).
m
  • move characters to a specified field from a 2nd field or a constant
  • will blank fill any extra length if sending field shorter than receiving
  • may qualify moves by 1 or 2 patterns in other specified bytes
n
  • move Numeric to a specified field from a 2nd field or a numeric value
  • will right adjust & zero left fill
  • may qualify moves by 1 or 2 patterns in other specified bytes
d
  • delete records, copies file to the 'tmp' subdirectory
    for inspection before copying/moving back over original file.
h
  • force hex display, h2=hex, h1=char, h0=automatic by data inspection
z##
  • truncate file, specify ## number of bytes to retain
lw
  • close the Write output file (after 1 or multiple 'w' write commands)
  • follow each write command with 'lw' for separate output files
    or omit for combined outputs from multiple write commands
  • write output file automatically closed at end program if 'lw' not used
lp
  • similar command close print files for separate or omit for combined files

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_4 uvhd - file investigation hexdump utility

Part 4 - uvhd Tutorial


4A1. uvhd Tutorial Preparation
- copy demo files to subdir in your home directory

4A2. dat1/custmas1 - demo file for most following tutorials
- customer master Name,Address,& Sales-History file
- 256 byte records with 24 x 5 byte packed fields

4A3. dat1/sales2 - demo file#2, sales detail records
- cust#,slsmn#,date,inv#,product-code,units,price,amount
- 64 byte records with unpacked Zoned numeric qty/amount
- Zoned signs compatible with Micro Focus COBOL

4B1. Browsing - demo for ASCII file with packed fields
- display records consecutively
- jump to & display any record in fixed length files by record#
- find/display any record in variable length files by record#
  (uses Index created by initial scan to quickly find records)

4B2. Browsing - demo for EBCDIC file with packed fields

4C1. Search - search by pattern, anywhere in the record (by default)
  or within specified column locations
- may search on 1 or 2 fields with AND/OR relationships
- match data =,>,< equal(default), greater than, less than
- repeat previous search via 'ss' vs 's' + search args

4C2. Search Indexed files for deleted records
- applies to D-ISAM, C-ISAM,& MF COBOL IDXFORMAT1

4D1. Update - update the current record on display
- specified columns replaced with specified data (char/hex)
- option to rollback current record updates
- option for multi-record updates with 1 qualifier field

4E1. Enumerate - count records from current position matching 1 or 2
specified patterns until EOF or within a max record count

4F1. Accum - Accumulate fields from All records (current until EOF)
- or from records matching 1 or 2 specified patterns in spcfd bytes

4G1. Write - write Unformatted records to a file: tmp/fname.yymmddhhmmW
  for subsequent use as test files, etc.
- may specify number of records from current position
  or records matching 1 or 2 patterns within specified columns
- select specified records from big files for small test files

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

uvhd Tutorial contents (continued)


4H1. Print - write formatted records to tmp file for later lp,uvlp,etc
- output file will be: tmp/filename.yymmddhhmmP
- may specify a number of records from current position
- may specify records matching 1 or 2 patterns & a max count
- To actually print, you must quit uvhd & select the desired
  filename from the tmp directory.

4H2. Iprint - write formatted records to a file for immediate printing
  via the 'uvlp12' command (see uvlist.doc).
- may specify a number of records &/or records matching
  1 or 2 specified patterns within specified columns.

4I1. Translate - to Ascii, Ebcdic, Upper, Lower, Characters, Periods
- unprintable characters can be translated to blanks or Periods

4J1. Check - check sequence of specified field
- options for ascending, descending, duplicates
 4J2. Generate Sequence Numbers
     - may specify starting number & increment (default 1)
     - may specify constants before & after sequence#

4K1. Scan/Replace - searches the specified record field, searching for a pattern
  - if found, replace with a replacement pattern.
- will truncate or blank fill if search & replace lengths different
- for fixed length records, use with fields such as Name & Address
- most effective with variable length text records.

4L1. Move - Move fields within records
- probably reformatting to create a new file
- be sure to copy/rename file to avoid dstruction of original
- see Example reformatting Cust N&A records into Telephone list

4L3. Alternative solution to Move Example, using uvcp & uvsort (vs uvhd)

4L4. Alternative solution to Move Example, using uvcopy
- overkill here, but use uvcopy for really complex reformatting

4M1. Move Numeric

4N1. Drop - drop records matching 1,2,or 3 patterns, creates 3 files in tmp/
- Backup, Corrected (dropped records removed),& Dropped records
- then copies Corrected file back, re-opens,& displays 1st record

4O1. Modify filesize - truncate or extend with x'00's

4P1. Close Files, lw - close Write file, lp - close print file
- use after each write/print for separate files or omite for combined
- automatically closed at end program if omitted

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4A1. uvhd - file investigation hexdump utility

uvhd Tutorial - Preparation

If you have installed the full Vancouver Utilities package, you will have the testfile in the /home/uvadm/dat1 subdirectory.


 #1. Login userxx --> /home/userxx
     ============

 #2. mkdir dat1 tmp           - make directories for testfile & print outputs
     ==============

 #3. cp /home/uvadm/dat1/custmas1 dat1  - copy supplied file to your sub dir
     =================================

 #4. uvhd dat1/custmas1 r256   <-- test uvhd with demo files
     =======================

alternative download demo-files from internet

Note
  • the uvhd.c source program download & compile instructions have
    already been presented on page '1A1' of this documentation.

#1. https://www.uvsoftware.ca - goto UV Software web site
========================

 #2. VUdemofiles.zip           - click on VUdemofiles.zip to download
     ===============           - save to disc

 #3. Login userxx --> /home/userxx
     ============

 #4. mv /downloaddir??/VUdemofiles.zip /home/userx/dat1/
     ===================================================
        - move testfile to dat1/ subdir in your homedir

 #5. cd dat1                   <-- change into dat1 subdir
     =======

 #6. unzip VUdemofiles.zip     <-- unzip demo files
     =====================
     custmas0,1,2,3,4; sales0,1,2,3,4, vendormas0,1,2,3,4,5,6 test100

 #7. cd ..                     <-- change back to your homedir

 #8. uvhd dat1/custmas1 r256   <-- test uvhd with demo files
     =======================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4A2. Test/Demo files for uvhd Tutorials

dat1/custmas1 demo file

          001-006 - customer#
          009-009 - delete flag (D)
          011-035 - customer name
          036-060 - address
          061-076 - city
          078-079 - province
          081-090 - postal code
          091-102 - phone#
          103-120 - contact name
          121-180 - this year sales 12 x 5 byte packed fields
          181-240 - last year sales 12 x 5 byte packed fields
          241-244 - credit codes
          245-250 - date of last change
          251-256 - unused (no LineFeed at end record)

We need 'uvhd' to investigate this file. We cannot use the unix/linux utilities (such as vi, cat, more, lp) becuase of the packed fields & no LineFeeds. But, here is 'dat1/custmas2' which has 1st 80 bytes extracted to a separate file.

 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANAIMO          BC
 132588    GEECOE GENERATOR SERVICESUNIT 170 - 2851 SIMPSON  RICHMOND         BC
 139923    JOHNSTONE BOILER & TANKS 1250 EAST PENDER STREET  VANCOUVER        BC
 142175    LILLY ELECTRIC (1973) LTD16809 - 24TH AVENUE      SURREY           BC
 145264  D MAGRATH SUPPLIES LTD.    1939 KIRSCHNER ROAD      KELOWNA          BC
 147615  X O'CONNER R.V. CENTRE     44430 YALE ROAD WEST     CHILLIWACK       BC
 149304    POINT GREY GOLF & COUNTRY3350 S.W. MARINE DRIVE   VANCOUVER        BC
 150825    RIGGERS INDUSTRIAL       960 - 6TH AVENUE         HOPE             BC
 152355    SHAW, JOHN               477 CARIBOO CRES.        PORT COQUITLAM   BC
 154688    TAURUS RESOURCES         1110 - 625 HOWE STREET   VANCOUVER        BC
 157352  D WHYTE, W.                1150 LODGE ROAD          NORTH VANCOUVER  BC
 173320  X ZENITH TRANSPORT         2381 ROGERS AVE          COQUITLAM        BC
 201120    ALLTYPE RENTAL LTD.      BOX 1819                 DRAYTON VALLEY   AL
 204700    CASE POWER EQUIPMENT     12611-100 ST             GRANDE PRAIRIE   AL
 208060    E&L TRUCKING             LAND & CATTLE LTD        WARBURG          AB
 211140  D FORD NEW HOLLAND         BOX 1, 440 ELLIS ROAD    WINTERBURN       AB
 223240  X NICHOLSON CHEVROLET LTD. 7215 ARGYLL ROAD         EDMONTON         AL
 224700    OTTO MOBILES WESTERN LTD.8441 CORONET ROAD        EDMONTON         AL
 231550    SPARROW ELECTRIC CO. LTD.BOX 88                   NISKU            AL
 234300    TERRITORIAL REWIND       BOX 1648                 WHITEHORSE       YK
 237286    WEBER, TOM               BOX 5503                 FORT MCMURRAY    AL
 301120  D ALBERTA GAS CHEMICALS LTD3RD. FLOOR, 11456 JASPER EDMONTON         AL
 306959  X 356582 ALBERTA LTD.      DEVITT NURSERY           CALGARY          AL
 308685    FOOTHILLS ELECTRIC       3932 - 3A ST. N.W.       CALGARY          AL
 313720    MONITREX ENGINEERING LTD 7-2280-39 AVE, N.E.      WHITEHORSE       YK
 315512    PARTS PLUS               BOX 510 MAIN ST          THREE HILLS      AB
 318833    TOP NOTCH CONSTRUCTION   BOX 308, STN J           CALGARY          AL
 400002    ACKLANDS LTD             945 -2ND AVE             PRINCE GEORGE    BC
 401210    COAST RANGE CONSTRUCTION 1103-207 W. HASTINGS ST  VANCOUVER        BC
 402875    HULL, DON & SONS LTD.    BOX 1297                 PRINCE GEORGE    BC
 403887  D MILNER, LARRY            BOX 28 RAU ROAD R.R.8    DAWSON CITY      YK
 406082    PRECAM RENTALS LTD:      10116-94TH AVE           FORT ST. JOHN    BC

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4A3. Test/Demo files for uvhd Tutorials

dat1/sales2 - demo file with Zoned Signs

        01-06 - CUST#
        11-12 - SLSMN#
        14-19 - DATE
        21-28 - INVOICE#
        31-36 - PRODUCT#
        39-44 - QTY      (pos digits 0123456789, neg digits pqrstuvwxy)
        46-52 - PRICE
        54-62 - $AMOUNT  (pos digits 0123456789, neg digits pqrstuvwxy)
        64-64 - linefeed terminated
          1         2         3         4         5         6
 1234567890123456789012345678901234567890123456789012345678901234
 CUST#    SLM  DATE   INV#     PROD#     QTY   PRICE    AMOUNT
 130140    21 940802 IN111001  HAM001  000020 0000001 000000020
 130140    21 940802 IN111001  SCR012  000021 0001001 000021021
 139923    35 950802 IN111002  HAM001  000022 0002001 000044022
 139923    35 950802 IN111002  TAB013  000023 0003001 000069023
 139923    35 950807 CR5421    TAB013  000024 0004001 000096024
 150825    44 960804 IN1122    HAM001  000025 0005001 000125025
 150825    44 960804 IN1122    PLN012  000026 0006001 000156026
 201120    44 970807 CR5234    WHIP75  000027 0007001 000189027
 223240    65 980816 CR955     HAM001  000028 0008001 000224028
 223240    65 980816 IN441     BIT001  000029 0009001 000261029
 308685    75 990812 IN6605    SAW001  00001p 0000001 00000001p
 308685    75 990812 IN6605    WID115  00001q 0001001 00001101q
 308685    75 990812 CR8835    TAB013  00001r 0002001 00002401r
 315512    33 000805 IN2251    HAM001  00001s 0003001 00003901s
 315512    33 000805 IN2251    SAW051  00001t 0004001 00005601t
 315512    33 000805 IN2255    WID115  00001u 0005001 00007501u
 400002    85 010812 CR245     HAX129  00001v 0006001 00009601v
 406082    55 020815 IN33001   BBQ001  00001w 0007001 00011901w
 406082    55 020815 IN33001   TAB013  00001x 0008001 00014401x
 406082    65 020816 IN441     HAM001  00001y 0009001 00017101y

dat1/sales3 - demo file with separate signs

 130140    21 940802 IN111001  HAM001  00020+ 0000001 00000020+
 130140    21 940802 IN111001  SCR012  00021+ 0001001 00021021+
 139923    35 950802 IN111002  HAM001  00022+ 0002001 00044022+
               - - - 14 records omitted - - -
 406082    55 020815 IN33001   BBQ001  00017- 0007001 00119017-
 406082    55 020815 IN33001   TAB013  00018- 0008001 00144018-
 406082    65 020816 IN441     HAM001  00019- 0009001 00171019-

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4B1. uvhd - file investigation hexdump utility

Browsing the ASCII demo file


 uvhd dat1/custmas1 r256s2  <-- initiate uvhd on test file with options
 =========================      'r256' (record-size) & 's2' (double space)
                                (between 3 line groups of chars,zones,digits)
 filename=/home/uvadm/dat1/custmas1 options=r256s2k1
 records=32 rsize=256 fsize=8192 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
 rec#=1 rsize=256 rcount=32 fsize=8192 fptr=0
 null=next,r#=rec,s=search,u=update,x=undo,p=print,i=iprint,w=write,e=count
 ,R#=Recsize,h1=char,h2=hex,g=genseq#,c=chkseq#,t=translate(ta,te,tu,tl,tc,tp)
 ,q=quit,k0=helpoff,k1=helpon,?=HelpScreens -->
 Enter command, or ?=Help, or null=NextRecord -->

uvhd displays the 1st record & waits for you to enter a command. Null entries cause uvhd to display records consecutively. You can jump to & display any record in the file by entering the desired record#.


 #1. null entry          - display next consecutive record
     ==========

 #2. r10                 - display record #10
     ===

 #3. r99                 - go to End Of File
     ===                   '99' is shorthand for 999999999

 #4. -1                  - backup to & display last record in file
     ==

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4B2. uvhd - file investigation hexdump utility

Browsing EBCDIC files


 uvhd dat1/custmas0 r256    <-- investigate EBCDIC demo file (dat1/custmas0)
 =======================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ......@@@@.........@......@...K@@@@....@.....@....@@@@@@@@@@....
             FFFFFF4444CECDCDCCD4DDEDDE4DEC44444FFFF4CDECD4DDCC4444444444DCDC
             130140000055597955504636920334B000018150266550961400000000005151
          64 ...@@@@@@@@@@..@......@@@@...`...`....@@@@@@@@@@@@@@@@@@........
             CDD4444444444CC4EFEFCF4444FFF6FFF6FFFF44444444444444444400000000
             946000000000023059218100006040754055310000000000000000000000C000
         128 .........W0....`........)X|..f3.....\.......................f...
             0000000005300016000000002570063100095000000000000000000000016000
             0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
         192 .E|...V}.......................f.....<........f..@@@@@@@@@@@@@@@
             047000570000000088000000001800068000130000000069C444444444444444
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000

BUT, of course we can NOT read the data on unix/linux ASCII systems. 'uvhd' provides option 'a' to perform EBCDIC to ASCII translation on the character line of the 64 byte 3 line groups (characters, zones, digits). You can then 'read' the EBCDIC data. Note that the zones & digit lines will reflect the actual data values (see an EBCDIC code card).

re-display with option 'a'


 uvhd dat1/custmas0 r256a  <-- investigate EBCDIC demo file, using option 'a'
 ========================      to translate the character lines to ASCII
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             FFFFFF4444CECDCDCCD4DDEDDE4DEC44444FFFF4CDECD4DDCC4444444444DCDC
             130140000055597955504636920334B000018150266550961400000000005151
          64 IMO          BC V9S1H1    604-754-5531                  ........
             CDD4444444444CC4EFEFCF4444FFF6FFF6FFFF44444444444444444400000000
             946000000000023059218100006040754055310000000000000000000000C000
         128 .........W.....-.........X@..f.....m*.......................f...
             0000000005300016000000002570063100095000000000000000000000016000
             0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
         192 .E@...V'........c..............f..............f.C
             047000570000000088000000001800068000130000000069C444444444444444
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4B3. uvhd - file investigation hexdump utility

Packed Decimal fields

Note that there are 24 * 5 byte packed fields in 120-240. You can identify the end of each packed field by the sign, x'_C' or x'_D'in the last byte. For example here is the 1st 8 bytes of last segment:

         192 .E@...V'   <-- character line
             04700057   <-- zones line
             35C0046D   <-- digits line
               ^    ^   <-- '^' marks sign/end of each packed field

Relevancy of option 'a'

Option 'a' is relevant to sites that are converting from an IBM mainframe to Unix, Linux, or Windows/SFU. The data files are transferred to the new machine where they are converted from EBCDIC to ASCII (see DATAcnv1.htm).

The conversion jobs are generated automatically from the COBOL copybooks. All character type & unpacked numeric fields are translated from EBCDIC to ASCII, while preserving any packed or binary fields unchanged (since they would be destroyed by the translation).

'uvhd' with option 'a' is a vital asset to verify the data conversions, you can spot check the conversion by examining both the input EBCDIC data & the output ASCII file.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4C1. uvhd tutorial - SEARCHING

You can search for & display records containing a specified pattern. The pattern may be anywhere in the record (by default) or within specified column locations.

Searching is performed from the current record on display until EOF, so you may need to return to the begining of file (command 'r0') to ensure you find all records.


 uvhd dat1/custmas1 r256     - initiate uvhd
 =======================     - display 1st record & wait for oprtr command

 #1. s 0(120),'CALGARY'     - search for 1st record concatenating 'CALGARY'
 #   ==================       (within 1st 120 bytes of each record)

***found CALGARY at byte# 60

 r#      23           1         2         3         4         5         6
 b#    5632 0123456789012345678901234567890123456789012345678901234567890123
          0 306959    356582 ALBERTA LTD.      DEVITT NURSERY           CALG
            3333332222333333244445542454222222244545524555455222222222224444
            306959000035658201C252410C44E0000004569440E5235290000000000031C7
         64 ARY          AL T2T5N1       -   -                      ........
            4552222222222442535343222222222222222222222222222222222200000000
            12900000000001C04245E10000000D000D00000000000000000000000000C000
        128 ..........)....`................................................
            0000000001280006000000000000000000000000000000000000000000000000
            0C0000C0009C0030C0000C0000C0000C0000C0000C0000C0000C0000C0000C00
        192 ..........&Rl..................'l...I\..........C   870807
            0000000000256000000000000000001260004500000000004222333333222222
            00C0000C0062C0000C0000C0000C0027C0029C0000C0000C3000870807000000

 #2. ss                      - repeat search for next record with 'CALGARY'
     ==                        (using last specified search criteria)
                            - repeat the 'CALGARY' search until EOF reached

 #3. r0                      - return to 1st record in the file

 #4. s <x'20'                - search for any byte < x'20' (space character)
     ========                - could specify as:  s <' '

 #5. s 'LTD','ROAD'          - search for records with 'LTD' AND 'ROAD' anywhere

 #6. sb 'LTD',|,'ROAD'       - search BACKWARD for records with 'LTD' OR 'ROAD'

 #7. ssb                     - repeat last search BACKWARD (vs default forward)

 #8. s 77(2),>'AA',,<'AZ'    - search for recs with cols 78-79 from AB to AY

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4C2. uvhd: Searching for Deleted records in Indexed files

This applies to D-ISAM Indexed files which are compatible with C-ISAM and Micro Focus COBOL IDXFORMAT1 files. First we need an Indexed file for our test/demo. If you have the Vancouver Utility package you can use the supplied D-ISAM file in subdir dat1/. Note that D-ISAM files are in 2 parts: data & indexed, with extensions '.dat' & '.idx'.


 dat1/custmast.dat     <-- data partition of indexed file
 =================
 dat1/custmast.idx     <-- index partition of indexed file
 =================

We will only be interested in data partition (where our data records are) since the .idx partition is unintelligible to most of us. The data partition is quite simple. All that happens when we load an indexed file from a sequential file is that 1 extra bye is added to each record. The extra byte will initially be x'0A' (LineFeed), but programs may delete records which change the x'0A' to a x'00' (null).


 uvhd dat1/custmast.dat r257     <-- examine D-ISAM file with uvhd
 ===========================         (recsize 1 extra for ISAM files)
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
         256 .
             0    <-- note x'0A' in byte 256, zero relative, 257 one relative
             A      - x'0A' IDs a good record, x'00' IDs a deleted record

 s 256(1),x'00'    <-- search for 1st deleted record
 ==============
 ss                <-- repeat search for next deleted record
 ==
 1                 <-- return to begining of file
 =

 e 256(1),x'00'    <-- enumerate (count) no of deleted records in the file
 ==============

If you have a lot of indexed records, you can use 'uvsort' to sort the data partition (making it more efficient) & drop the deleted records. See uvsort.htm#L5 & uvsort.htm#M1 (to recover corrupted files).

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4D1. uvhd tutorial - UPDATING

The 'u' command will update the current record on display. You can replace specified columns with specified data (character or hexadecimal).

This is a safe method of updating Micro Focus Indexed files, because uvhd will never change the record size. Micro Focus Indexed files can be updated with 'vi' but this is very dangerous, because it is easy (with vi) to add a byte or drop a byte, which would destroy the integrity of the remainder of the file (fixed record slots, not variable text).


 cp dat1/custmas1 tmp/cm1    - copy test file to tmp, since update will modify
 ========================

 uvhd tmp/cm1 r256u          - initiate uvhd
 ==================          - 'u' option require when update intended

 #1. u 14(5),'red  '          - change 'EVERGREEN MOTORS'
     ===============            to 'EVERred   MOTORS'

 #2. x                         - undo (rollback) the last update
     =                         - repeat to re-apply last update (toggle)

 #3. u 192(3),=x'12345C'       - update 1 of the packed fields
     ===================         (using hexadecimal notation)
 r#       1           1         2         3         4         5         6
 b#       0 0123456789012345678901234567890123456789012345678901234567890123
          0 130140    EVERred   MOTORS LTD.    1815 BOWEN ROAD          NANA
            3333332222454554422244545524542222233332445442544422222222224444
            13014000005652254000DF4F230C44E0000181502F75E02F140000000000E1E1
         64 IMO          BC V9S1H1    604-754-5531                  ........
            4442222222222442535343222233323332333322222222222222222200000000
            9DF00000000002306931810000604D754D55310000000000000000000000C000
        128 .........W0....`........)X|..f3.....\.......................f...
            0000000005300016000000002570063100095000000000000000000000016000
            0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
        192 .4\...V}.......................f.....<........f.C
            1350005700000000880000000018000680001300000000694222222222222222
            24C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
            ^^^ - note results of:  u 192(3),x'12345C'
                             & of:  u 14(5),'red  '
 4a. r0                        - reset file pointer to rec #0 (1st in file)
 4b. u99 77(2),'AB',77(2),'AL' - update cols 78-79 to 'AB' if currently 'AL'
                                 (no rollback for multi-record updates)
Note
  • To ensure multi-record updates to EOF, specify 'u99', which is
    shorthand for 'u999999999' (big number greater than records in file)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4E1. uvhd tutorial - Enumerate (count records)

The 'e' command counts (enumerates) records from current position, matching 1 or 2 specified patterns, until EOF or within a specified maximum record count.


 uvhd dat1/custmas1 r256        - initiate uvhd
 =======================

 #1.  e 77(2),'AB'             - count records with 'AB' in cols 78-79
      ============

 #2a. r0                       - return to begining of file

 #2b. e 77(2),'AB',|,'AL'      - count records with 'AB' OR 'AL' in cols 78-79
      ==================

 #3a. r0

 #3b. e 77(2),'BC','LTD'       - count records with 'BC' in 78-79
      ==================         & 'LTD' anywhere in record

 #4.  e 77(2),'BC',0(256),'LTD'  - same as above
      =========================

 #5.  e 77(2),'BC',,'LTD'        - WRONG (would be interpreted same as below)
      ===================

      e 77(2),'BC',77(2),'LTD'   - op3 omitted would be same as this (WRONG)
      ========================

--> q <-- quit dat1/custmas1


 uvhd dat1/custmast.dat r257    - investigate a D-ISAM demo file
 ===========================      (recsize 257 bytes)

 #6.  e 256(1),x'00'            - count records with x'00' in byte 256
      ==============

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4F1. uvhd tutorial 'a' - Accumulate

Accumulate numeric fields


 #0. uvhd dat1/custmas1 r256 - execute uvhd on demofile #1, layout page '4A2'
     =======================
                      10        20        30        40        50        60
 r#    1 0123456789012345678901234567890123456789012345678901234567890123
       0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
         3333332222454545444244545524542222233332445442544422222222224444
         130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
      64 IMO          BC V9S1H1    604-754-5531                  ........
         4442222222222442535343222233323332333322222222222222222200000000
         9DF00000000002306931810000604D754D55310000000000000000000000C000
     128 .........W0....`........)X|..f3.....\.......................f...
         0000000005300016000000002570063100095000000000000000000000016000
         0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
     192 .4\...V}.......................f.....<........f.C
         1350005700000000880000000018000680001300000000694222222222222222
         24C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000

 #1. a 120(5p)         <-- Acum 5 byte Packed field at offset 120
     =========           - from current record until EOF

     --> a 120(5p) --> acum total=1294541 from 32 recs of 32 read  <-- result
         ========================================================

 #2. 1                 <-- return to begin file before each acum below
     ===

 #3. a 120(5p),,77(2),'BC'              <-- acum if 'BC' in bytes 77-78
     =====================

 #4. a 120(5p),,77(2),'AB',|,'YK'       <-- acum if 'AB' or 'YK', omit 2nd 77(2)
     ============================

 #5. a 120(5p),,77(2),'BC',90(3),!'604' <-- acum if 'AB' and area code not=604
     ==================================

crossfoot option 'x'


 #6. ax12 120(5p)  <-- option 'x' to crossfoot & accumulate
     ============    - crossfoots 12 5 byte packed fields from 120(5p) to 175(5p)

     --> ax12 120(5p) --> acum total=9969793 from 32 recs of 32 read <-- result
         ===========================================================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4F2. uvhd tutorial 'a' - Accumulate

accumulate unpacked fields


 #0. uvhd dat1/sales2 r64  - execute uvhd on demofile #2, layout page '4A3'
     ====================
      rec#=1 rsize=0 fptr=1280 fsize=1280 rcount=20
                      10        20        30        40        50        60
 r#    1 0123456789012345678901234567890123456789012345678901234567890123
       0 130140    21 990802 IN111001  HAM001  000020 0000101 000002020 .

 #1. a 38(6)   <-- acum 6 bytes, assume unpacked Ascii, +sign x'3_', -sign x'7_'
     =======     - ASCII signs Micro Focus COBOL compatible, +/- also recognized

     --> a 38(6) --> acum total=100 from 20 recs of 20 read  <-- result
         ==================================================

 #2. a 38(6ze) <-- acum 6 byte Zoned Ebcdic, +sign x'C_' or x'F_', -sign x'D_'
     =========

 #2a. a 38(6)  <-- may omit 'ze' for unpacked EBCDIC fields
      ========   - uvhd will default 'ze' since you would have coded option
                   'a' on the command line to translate ebcdic to Ascii

 #3. a 38(6zx) <-- same for ASCII file with EBCDIC signs vs Micro Focus signs
     =========   - zone +sign x'C_', -sign x'D_' (vs + x'3_' & - x'7_')

use '!' to exclude Total records

If your file has total records (with amount in same columns), you can use the '!' condition to exclude them & acum the detail record amounts. Suppose the amount field is cols 50-57 & a Total record is identified by a 'T' in col 70.


 uvhd in1fix/taxfile r192
 ========================

 --> a 50(8)                <-- would acum the Total rec as well as Detail records
     =======

 --> a 50(8),,70(1),!'T'    <-- Excludes the Total record
     ===================      - acumukating detail amounts only

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4G1. uvhd tutorial - WRITING (selecting)

The 'w' command writes Unformatted records to a file for test files, etc. You may specify a number of records from the current position or records matching a specified pattern. This is an easy way to select specified records from a file & append LineFeeds to allow printing (of mainframe type files).


 uvhd dat1/custmas1 r256   <-- initiate uvhd
 =======================

 #1. w5r80t2      <-- write 2 records from current position
     =======        - option 'r80' Record-size for output records
                    - option 't2' append lineFeed in last byte
                      (so we can use vi,uvlp12,etc on output file)
     >>> 5 recs written to tmp/custmas1_961116_104901W

 #2. w 77(2),'AB',|,'AL'     - write(select) recs with 'AB' or 'AL' cols 78-79
     ===================       (from current position until EOF)
     >>> 3 recs written to tmp/custmas1_961116_104901W

 #3. q                       - quit uvhd

 #4. ls -l tmp               - investigate the output filename assigned
 -rw-rw-r--   1 uvu      group       8192 Nov 16 10:40 custmas1
 -rw-rw-r--   1 uvu      group       5331 Nov 16 10:47 custmas1_961116_104600P
 -rw-rw-r--   1 uvu      group        400 Nov 16 10:49 custmas1_961116_104901W

 #5. vi tmp/custmas1*P   - use vi to inspect the file contents
 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANAIMO          BC
 132588    GEECOE GENERATOR SERVICESUNIT 170 - 2851 SIMPSON  RICHMOND         BC
 208060    E&L TRUCKING             LAND & CATTLE LTD        WARBURG          AB
 211140  D FORD NEW HOLLAND         BOX 1, 440 ELLIS ROAD    WINTERBURN       AL

 #6a. ws10               - Write Select every 10th record
      ====

 #6b. ws4 77(2),'BC'     - Write Select every 4th record with 'BC' in cols 78-79
      ==============

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4G2. uvhd tutorial - WRITING (selecting)

Options for Write command

a1
  • translate to ASCII, write command output records
c1
  • convert unprintable chars in write output records to periods
d#
  • displacement to 1st byte to be written
  • combine with r# (record-size) to write parts of records to output file
n1
  • insert variable recsize as 4 numerics at BEGIN write output
n2
  • insert variable recsize as 4 numerics at END write output
r#
  • record size for fixed-length output, omit for RDWz2/z4
t1
  • append Carriage-Return as last byte of write output records (for MAC)
t2
  • append Line-Feed as last byte of write records (Unix/Linux)
t3
  • append both CR & LF as last 2 bytes of write records (Windows/DOS)
t4
  • append terminators after Last-Non-Blank, else at end specified rec-size
Note
  • may use multi-bit combinations, for example 't7' = t1+t2+t4
    (to append CR+LF after last non-blank)
z#
  • write RDW format (2 or 4 byte prefixes with recsize in binary)
z2
  • prefix 2 bytes only, recsize EXCLUDES prefix size
z4
  • prefix 4 bytes, recsize 1st 2, 3&4 nulls, recsize INCLUDES prefix
z1
  • (add 1 bit) = z3/z5 Little-end binary, z2/z4 default BIG-end binary

'lw' close write file command

 --> lw <-- may follow write command with 'lw' command to close file for separate
            output files or omit for combined outputs from multi write commands

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4H1. uvhd tutorial - PRINTING

The 'p' command writes formatted records to a file for subsequent printing via lp, uvlp, etc. You may specify a number of records from the current position, or records matching a specified pattern (up to a maximum number). The 'p' command creates a file in the 'tmp' subdir of the current directory (the 'tmp' subdir will be created if it does not already exist).

      filename assigned: tmp/inputfilename.yymmddhhmmP
            for example: tmp/custmas1_961116_095502P

 uvhd dat1/custmas1 r256   - initiate uvhd
 =======================

 #1. p2                   - print 2 records from the current position
     ==
                 >>> 2 recs printed to tmp/custmas1_961116_104604P

 #2. p 77(2),'AB'         - print records with 'AB' in columns 78-79
     ============           ('AB' is the province code for 'ALBERTA')
                 >>> 3 recs printed to tmp/custmas1_961116_104604P

 #3. p3 0(6),>'200000'    - print 1st 3 records with 1st 6 bytes > 200000

 #4. q                    - quit uvhd
     =

 #5. ls -l tmp            - investigate the output filename assigned
     =========
 -rw-rw-r--   1 uvu      group       8192 Nov 16 10:40 custmas1
 -rw-rw-r--   1 uvu      group       5331 Nov 16 10:47 custmas1_961116_104604P

 #6. lp tmp/custmas1*P         - print the output file
     =================           (same display as original uvhd)
Note
  • Print (& Iprint,Write) commands create a separate file for each command
  • prior to Feb 2009, they did not, outputs were combined in 1 file
  • there was a command line option (w1) to combine Writes into 1 file
  • w1 removed in 2010 since 'lc' command provided to Close write files

'lp' close write file command

 --> lp <-- may follow print command with 'lp' command to close file for separate
            output files or omit for combined outputs from multi print commands

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4H2. uvhd tutorial - IMMEDIATE PRINTING

The 'p' command with option 'i' writes formatted records to a file for Immediate printing via the 'uvlp12' script (issued by uvhd using the 'system' shell command). This script is documented in uvlist.doc & is stored at /home/uvadm/sf/uvlp12. If desired you may modify the uvhd program to replace the 'uvlp12' script with the UNIX 'lp' or whatever print command you desire.

The print command creates a file in the 'tmp' subdirectory & the executes the uvlp12 (or lp) for example:

format: uvlp12 tmp/inputfilename.yymmddhhmmP

 example: uvlp12 tmp/custmas1_970110_154905P

You may specify a number of records from the current position, or records matching a specified pattern (optionally within specified columns).


 uvhd dat1/custmas1 r256    - initiate uvhd
 =======================

 #1. p2i                   - print 2 records (immediately) from current position
     ===
     >>> 2 recs printed to tmp/custmas1_970110_160006P

 #2. p5i 77(2),!'BC'       - print (5 recs max) searching from current position
     ===============         for records with province codes NOT= 'BC'
     >>> 5 recs printed to tmp/custmas1_970110_160006P

 #3. q                     - quit uvhd
    =

notes

The uvhd program uses the 'system' command to execute the 'uvlp12' shell script (see uvlp12 documented in uvlist.doc). If required you could change the command by editing the program & recompiling, or via environmental variables. This was discussed early in this documentation but briefly:

 export UVLPDEST=-dlaser2     <-- setup printer dest for all 'uvlp' scripts
 export UVHDPRINT=uvlp12      <-- the default uvlp12 script
 export UVHDPRINT=uvlp12L      <-- use this to print 100 char lines Landscape

'uvlp12L' is recommended if you use the 'l100' option on your iprint commands, for example:

 --> p5l100i            <-- prints next 5 records, 100 chars per line
                            Landscape at 12 cpi to fit 11" across
 --> p5i                <-- would default to 64 chars per line
                            (possibly modified by 'l' command line option)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4I1. uvhd tutorial - Translate

The 't' command will translate to Ascii,Ebcdic,Upper,Lower,Characters,or Periods (depending on options a,e,u,l,c,p).

ta
  • translate entire current record to Ascii
t99e
  • translate ALL records (from current to EOF) to Ebcdic
tl 0(120)
  • translate 1st 120 bytes of current record to Lower case
tc1
  • translate unprintable Characters to blanks EXCEPT LineFeeds x'0A'
    (c2=except CR x'0D', c4=except FF x'0C', c8=except tab x'09')
tc15
  • translate to Chars, except LFs,CRs,FFs,Tabs (1+2+4+8=15)

Translate Tutorial


 cp dat1/custmas1 tmp/cm1   - copy test file to tmp subdir
 ========================     (since we will modify)

 uvhd tmp/cm1 r256u         - initiate uvhd
 ==================         - option 'u' required to modify records

 #1a. te 0(120)        - translate 1st 120 bytes of 1st record to Ebcdic
      =========

 #1b. ta 0(120)        - translate 1st 120 bytes of 1st record back to Ascii
      =========

 #2a. t99l 10(25)      - translate bytes 10-34 of all(32) records to Lower case
      ===========
Note
  • see this demo on next page (using 80 byte custmas6 vs 256 byte custmas1)

 #2b. 1                - reset file pointer back to record #1

 #2c. t99u 0(120)      - translate 1st 120 of all(32) records to Upper case
      ===========

 #2d. 1                - reset file pointer back to record #1

 #3a. tc               - translate any unprintable Chars to blanks
      ===                (entire current record)

 #3b. x                - rollback current record (undo translate above)
      ===

 #4a. tc4              - translate any unprintable Chars to blanks
      ===                (except for FormFeeds x'0C')

 #3b. x                - rollback current record (undo translate above)
      ===

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4I2. uvhd tutorial - Translate

translate example - to lower case

We will show you how you can use uvhd to translate 1 field (or all fields) in all (or some) records of a data file. We will use test/demo file /home/uvadm/dat1/custmas6, which has 32 records, but we will show only the 1st 3 & last 3, before & after the translate.

demo data file dat1/custmas6 - BEFORE translate

 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANAIMO          BC
 132588    GEECOE GENERATOR SERVICESUNIT 170 - 2851 SIMPSON  RICHMOND         BC
 139923    JOHNSTONE BOILER & TANKS 1250 EAST PENDER STREET  VANCOUVER        BC
                 - - - 1st 3 & last 3 of 32 records - - -
 402875    HULL, DON & SONS LTD.    BOX 1297                 PRINCE GEORGE    BC
 403887  D MILNER, LARRY            BOX 28 RAU ROAD R.R.8    QUESNEL          BC
 406082    PRECAM RENTALS LTD:      10116-94TH AVE           FORT ST. JOHN    BC

Op. Instrns. to translate to lower


 #1. cp dat1/custmas6 tmp/cm6   <-- copy/rename test file to tmp subdir
     ========================     - do NOT update any files in dat1/... dir

 #2. uvhd tmp/cm6 r80u  <-- run uvhd on N&A 80 byte records with Update intent
     =================    - need option 'u' for any update command
                          - shows 1st record (usual uvhd behavior)
                       10        20        30        40        50        60
     r#     1 0123456789012345678901234567890123456789012345678901234567890123
            0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
           64 IMO          BC.

 #3. --> t99l 10(25)    <-- translate to Lower case bytes 10-34 of all/32 records
         ===========      - '99' or any high number to process all records
                          - option 'l' specifies 'l'ower case translate
                          - could omit 10(25) to translate entire record

 #4. more tmp/cm6       <-- display records after translate to lower case
     ============

demo data file tmp/cm6 - AFTER translate

 130140    evergreen motors ltd.    1815 BOWEN ROAD          NANAIMO          BC
 132588    geecoe generator servicesUNIT 170 - 2851 SIMPSON  RICHMOND         BC
 139923    johnstone boiler & tanks 1250 EAST PENDER STREET  VANCOUVER        BC
                 - - - 1st 3 & last 3 of 32 records - - -
 402875    hull, don & sons ltd.    BOX 1297                 PRINCE GEORGE    BC
 403887  D milner, larry            BOX 28 RAU ROAD R.R.8    QUESNEL          BC
 406082    precam rentals ltd:      10116-94TH AVE           FORT ST. JOHN    BC

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4J1. uvhd tutorial - CHECK SEQUENCE

The 'c' command checks the sequence on a specified field & displays the first record not in sequence (or EOF all OK). You may specify option 'd' for descending (vs default ascending), option 'e' to consider equal fields to be out of sequence, or option 'i' to check the increment (i1,i10,etc).

For this tutorial, we will use 'g' (generate seq#s) to create a test file, then 'u' to create an intentional error, then 'c' to check the sequence.


 #1. cp dat1/test100 tmp      <-- copy a test file to a tmp subdir
     ===================

 #2. uvhd tmp/test100 r40uh2  <-- start uvhd, specifying the filename,
     =======================      record size 'r40', update option 'u',
                                  & option 'h2' to force hex display

 a. --> g100i10 30(4),'0010'  <-- insert seq#s in cols 31-34, incrmnt 10
        ====================

 b. --> r51                   <-- goto record #51
        ===

 c. --> u 30(4),'0515'        <-- change seq# to '0515' (from '0510')
        ==============
 d. --> r1                    <-- reposition to rec#1 (begin file)
        ==

 e. --> c 30(4)               <-- check sequence --> will be OK
        =======

 f. --> ci10 30(4)            <-- check sequence increment 10
        ==========              - will get error as follows:
                      10        20        30        40        50        60
    r#    51 0123456789012345678901234567890123456789012345678901234567890123
        2000 0051 tf/test100 fifty one     0515     .
             3333276276773332666772666222223333222220
             0051046F45341000696490FE500000051500000A

ci10 30(4) ERROR, 1st out of sequence record above

 g. --> cc                    <-- continue sequence checking
        ==                      - will get a 2nd error (not shown)
 h. --> cc                    <-- continue sequence checking
        ==                      - will now get to EOF (rec#100) OK

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4J2. uvhd tutorial - Generate Sequence Numbers

command 'g' generates sequence numbers. You can specify a starting value and an increment (other than the default 1). You can also specify constants to be inserted before & after the initial value (for the 1st record).

Note
  • must specify 'u' option on command line (like update)

 #1. cp dat1/test100 tmp      <-- copy a test file to tmp subdir
     ===================        - test100 has 100 * 40 byte records

 #2. uvhd tmp/test100 r40u    <-- start uvhd specifying filename,
     =====================        record size & update option

 a. --> g10 30(4),'0001'      <-- sequence# 1st 10 records
        ================        - insert seq# in bytes 30-33
                                - initial value 0001, increment by 1 (default)
     0001 tf/test100 one           0001
     0002 tf/test100 two           0002
                     - - - etc - - -
     0009 tf/test100 nine          0009
     0010 tf/test100 ten           0010
 b. --> r1                    <-- return to rec #1 (begin file)

 c. --> g10i10 30(6),'#0010.' <-- sequence# 1st 10 records
        ====================    - inserts seq# in bytes 31-34
                                - inserts '#' prior & '.' after seq#
                                - increments by 10 (option 'i10')
     0001 tf/test100 one           #0010.
     0002 tf/test100 two           #0011.
                     - - - etc - - -
     0009 tf/test100 nine          #0018.
     0010 tf/test100 ten           #0019.
 d. --> r1                    <-- return to rec #1 (begin file)

 e. --> g100 30(4),'0020',0(3),'002' <-- sequence# up to 100 records max
        ============================   - insert seq# in bytes 30-33
        - qualified, only records that have '002' in 1st 3 bytes (twenties)
        - initial value 0020, increment by 1 (default)
     0001 tf/test100 one
                     - - - etc - - -
     0019 tf/test100 nineteen
     0020 tf/test100 twenty        0020
     0021 tf/test100 twenty one    0021
                     - - - etc - - -
     0028 tf/test100 twenty eight  0028
     0029 tf/test100 twenty nine   0029
     0030 tf/test100 thirty
                     - - - etc - - -
     0100 tf/test100 one hundred

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4K1. uvhd tutorial 'v' - scan/replace

'v' (scan/replace) searches the specified record field, searching for a specified pattern & if found, replacing with a specified replacement pattern.


 cp dat1/custmas1 tmp/cm1   - copy test file to tmp (since scan/rep modifies)
 ========================

 #1. uvhd dat1/custmas1 r256u   - initiate uvhd
     ========================   - option u required for update or scan/replace
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000

 #2. v 10(25),'LTD.','LIMITED' - replace 'LTD' with 'LIMITED' anywhere in 10-34
     =========================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LIMITED 1815 BOWEN ROAD          NANA
             3333332222454545444244545524444544233332445442544422222222224444
             130140000056527255E0DF4F230C9D94540181502F75E02F140000000000E1E1
Note
  • will lose any data pushed beyond byte 34 (fixed length record fields)

 #3a. 5            - goto record #5 (also known to contain 'LTD.')

 #3b. vv           - repeat last 'v' scan/replace command
      ===

 #4a. 1                        - return to rec#1

 #4b. v99 10(25),'LTD.','LIMITED' <-- same change on 99 (all) records (or EOF)
      ===========================

 #5a. 1                            - return to rec#1

 #5b. v99 'LTD.','LIMITED'         - big mistake for fixed length record layouts
                                   - defaults to entire record

 #5c. v99 0(256),'LTD.','LIMITED'  - same as this, entire record would be shifted

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4K2. uvhd tutorial 'v' - scan/replace

scan/replace vs update

  1. 'u' updates a fixed field (op1) with constant data (op2) which must be the same length as the op1 field defined.

  2. 'v' scans the op1 record field for the op2 constant data & if found, replaces the op2 data with the op3 replacement data.

  3. Both 'u' & 'v' allow extra fields & constants to qualify the update. 'u' allows 2 qualifiers, but 'v' allows only 1 since there are 3 max constants allowed & 'v' requires 2 for scan/replace.

  4. 'v' allows the search & replacement data to be of different lengths, which causes the remainder of the op1 data field to be truncated or blank filled.

  5. 'v' can be dangerous for fixed length fields. You must be sure that op1 defines a field such as Name & Address where it is OK to shift data. Be sure you define only 1 field since you don't want to shift data outside of the intended field.

  6. 'v' can be most effective for delimited variable length text files, since it is OK to shift multiple fields in these file types. But note that uvhd will never change record lengths. Any attempt to shift data past the original record length will be truncated.

  7. If your 'scan/rep's require increasing the record length, you can NOT do it with 'uvhd'. Use the uvcopy utility which can do anything. See the 'uvcopy vs uvhd' comparison on page '6C1'.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4L1. uvhd tutorial - Move fields within records

Move Example - create Telephone list

You might use the 'move' instruction to reformat existing files into new files. Be sure to copy/rename file to avoid dstruction of the original file. Here is an example: reformatting Customer N&A records into a Telephone list.

 Existing customer Name&Address layout is: 00-05 cust, 10-34 cust-name,
 35-89 address, 90-91 tel#, 120-239 24 x 5 byte packed fields, 240-255 unused.

New Telephone-List layout: 00-05 cust, 10-34 cust-name, 35-46 telephone# We will move the telephone# to follow the customer-name, blank fill to byte 64, & write text records, max recsize 64, with LineFeed after last non-blank. Here are a few sample output records desired:

 130140    EVERGREEN MOTORS LTD.         250-754-5531
 132588    GEECOE GENERATOR SERVICES     604-278-4488
 139923    JOHNSTONE BOILER & TANKS      604-320-1845

 #1. cp dat1/custmas1 tmp/cm1 <-- 1st copy custmas1, rename
     ========================   - cm1 is a temp file for moves
                                - will Write desired file & rename to 'tel-list'

 #2. uvhd tmp/cm1 r256u   <-- start uvhd, with option u to allow Moves
     ==================

 #2a. m99 35(5),'    '    <-- create space after cust-name (prior to tel#)
      ================
 #2b. 1                   <-- return to 1st record in file

 #2c. m99 40(24),90(12)   <-- Move tel# after cust-name & blank to 64
      =================
 #2d. 1                   <-- return to 1st record in file

 #2e. w99r64t6            <-- Write max recsize 64
      =========             - option 't6' appends a LineFeed after last non-blank

 #2f. q (quit)
      ========

 #3. w99r64t6   <-- Write, Recsize 64, Textfile
     ========     - option 't6' appends LF after last nonblank
Note
  • Writes to the tmp/... subdir with same name appending _date_time stamp
  • for example: tmp/cm1_101208_164357W

 #4. cp tmp/cm1_101208_164357W dat1/tel-list
     =======================================
     - copy the tmp/... file renaming as desired

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4L2. Move Example - create Telephone list

Alternative solution

You might think we could shorten the 1st solution above if we blank fill to the end of the original 256 byte & insert a LineFeed after the moved tel#. This would allow us to rename the file immediately to the desired result & avoid having to write a tmp/... file. We might try this as follows:


 #1. cp dat1/custmas1 dat1/tel-list <-- copy custmas1, rename as desired
     ==============================

 #2. uvhd dat1/tel-list r256u  <-- start uvhd, with option u to allow Moves
     ========================

 #2a. m99 35(5),'    '    <-- create space after cust-name (prior to tel#)
      ================
 #2b. 1                   <-- return to 1st record in file

 #2c. m99 40(216),90(12)  <-- Move tel# after cust-name & blank to end 256
      ==================
 #2d. 1                   <-- return to 1st record in file

 #2e. m99 52(1),x'0A'     <-- insert LineFeed after tel#
      ===============
 #2f. 1                   <-- return to 1st record in file

 #2g. m99 255(1),x'0A'    <-- insert LineFeed in last byte of original 256
      ===============

 #2h. q (quit)
      ========

We have avoided having to Write the tmp/... file, but we will have a blank 204 byte record between our desired records. #2e made these separate records vs prepended on our desired records. You could drop with the editor as follows:


 #3. vi dat1/tel-list
     ================

 #3a. :g/^   /d      <-- drop records with 3 blanks at begining
      =========        - '^' means at begining
                       - desired records have cust# at begining

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4L3. Move Example - create Telephone list

2nd Alternative solution

'uvcp' is a better solution for reformating records (such as the above reformatting a customer Name & Address file into a Telephone-List.

 uvcp "fili1=dat1/custmas1,rcs=256,typ=RSF,filo1=dat1/tel-list,rcs=52,typ=LSTt\
 ,clr=35(5),mvc=40(12)90"
 ==============================================================================

3rd Alternative solution

BUT, it would make more sense to use 'uvsort' to reformat AND sort by customer- name as would be expected for telephone lists.

 uvsort "fili1=dat1/custmas1,rcs=256,typ=RSF,filo1=dat1/tel-list,rcs=52,typ=LSTt\
 ,clr=35(5),mvc=40(12)90,key1=10(25)"
 ==============================================================================

notes

  1. We have used the '\' to continue the command onto a 2nd line for our documentation. You can key as all 1 line.

  2. uvcp allows no blanks in the command, so do not key any blanks at the begining of the continued line. We put the ',' separator at begining.

  3. Input 'typ=RSF' means 'Record Sequential Fixed' (no Linefeeds).

  4. Output 'typ=LSTt' means 'Line Sequential Terminated'. Option 't' scans back & inserts the LineFeed after the last non-blank.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4L4. Move Example - create Telephone list

4th Alternative - uvcopy

For this simple telephone list, uvcp & uvsort are much simpler & shorter, BUT for really complex reformatting, you would use the 'uvcopy' utility. The uvcopy instructions are coded in a separate 'parameter file' which is called by uvcopy from the command line.

You can enter the uvcopy instructions with the editor, or you might copy an existing job & modify with the editor.


 #1. cp pf/demo/copy1 pf/demo/cm2tellist  <-- copy a 'skeleton' uvcopy job
     ===================================    - rename as desired

 #2. vi pf/demo/cm2tellist   <-- edit/modify instructions (as below)
     =====================
 # cm2tellist - reformat Customer Master to a Telephone List
 #            - see www.uvsoftware.ca/uvhd.htm#4E4
 # uvcopy alternative solution to uvhd, uvcp,& uvsort (simpler solutions)
 # - but uvcopy would be used for really complex reformatting jobs
 #
 fili1=?dat1/custmas1,typ=RSF,rcs=256
 filo1=?dat1/tellist,typ=LSTt,rcs=64
 @run
       opn   all                    open files
 # begin loop to get, reformat,& 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'
       clr   b35(5),' '             clear 35-39 (space before tel#)
       mvf   b40(216),a90(12)       move tel# after name & blank to end of record
 #     ---   -----,-----            <-- add more instrns for complex reformats
 #-----------------------------
       put   filo1,b0               write record to output file
       skp   loop                   return to get next record
 eof   cls   all                    close files
       eoj                          end job

 #3. uvcopy cm2tellist   <-- execute the uvcopy job
     =================     - filenames coded on fili1=... & filo1=...

 #3a. uvcopy cm2tellist,fili1=dat1/custmas1,filo1=dat1/tellist
      ========================================================
      - may code filenames on command line (overriding names in job)
Note

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4M1. uvhd tutorial - move Numeric

n
  • move Numeric to a specified field from a 2nd field or a numeric value
  • will right adjust & zero left fill
  • may qualify moves by 1 or 2 patterns in other specified bytes

n 64(9z),120(5p) <-- move Numeric (n), unpacks 5 bytes into 9 bytes Zoned

n 130(5p),64(9z) <-- move Numeric (n), 9 zoned bytes to 5 packed bytes)

n 51(4b),120(5p) <-- move Numeric, 5 bytes packed to 4 bytes binary

n 140(5p),123456 <-- move Numeric value (length omitted) to 5 bytes packed

n 64(9ze),120(5p) <-- move Numeric, unpacks 5 bytes into 9 bytes Zoned EBCDIC

 n 120(5p),0,,77(2),='BC' <-- clear 5 bytes packed (move 0) if province 'BC'
                            - conditional moves via qualifiers in op3-op6
 n99 120(5p),0 <-- clear this yr Jan sales in all records (99 means 999999999)
                 - use m99/n99 to move on all records until EOF reached

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4N1. uvhd tutorial - DROPPING records

The 'd' drop command copies to a temporary file, dropping records via a specified pattern (or record# range), copies the remaining records back, & reopens the new file. Actually drop writes 3 date/time stamped files to the tmp/subdir within your current working directory:

  1. tmp/filename_yyyymmdd_hhmmssB - Backup file (all records)
  2. tmp/filename_yyyymmdd_hhmmssC - Corrected file (after drops)
  3. tmp/filename_yyyymmdd_hhmmssD - Dropped records file

After 3 files copied to $UVTMPDIR/ (default tmp/), the 'C' file is copied back overwriting original, reopened as the new input file, & a prompt issued for next command.

drop tutorial

Given
  • dat1/custmas1 file of customer master Name&Address&Sales file
Required
  • drop all records for Yukon 'YK' in bytes 77-78 (cols 78-79)
  • 1st copy dat1/custmas1 to tmp1/ so you don't change demo file

 #1. mkdir tmp1 tmp    <-- ensure your current dir has subdirs tmp1 & tmp
     ==============

 #2. cp $UV/dat1/custmas1 tmp1  <-- copy demo file to tmp1/...
     =========================

 #3. uvhd /home/uvadm/tmp1/custmas1 r256u   <-- run uvhd with Update option
     ====================================
 version=20140304 records=32 rsize=256 fsize=8192
                      10        20        30        40        50        60
 r#        1 1234567890123456789012345678901234567890123456789012345678901234
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}.......
             0000000005300016000000002570063100095000000000000000013570000000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0000C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
 rec#=1 rsize=256 fptr=0 fsize=8192 rcount=32

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4N2. uvhd tutorial - DROPPING records

drop tutorial (continued)


 #4. --> d 78(2),'YK'  <-- Drop records with 'YK' in cols 78-79
         ============
 tmp/custmas1_140304_145149B closed, 32 records written
 tmp/custmas1_140304_145149C closed, 29 records written
 tmp/custmas1_140304_145149D closed, 3 records written

32 Backup, 29 Correct(not Dropped), 3 Dropped rec#=1 rsize=256 fptr=0 fsize=7424 rcount=29


 #5. --> q  <-- Quit
        ====

closing filesize 7424 NOT= opening filesize 8192 OK if d(delete) or z(truncate) used ? acknowledge y


 #6. --> y  <-- must acknowledge with 'y'
       =====

other drop command examples

You could have multiple conditions on the Drop command, examples:


 #4a. --> d 78(2),'YK',|,'NJ',|,'NY'  Drop if 'YK','NJ', OR 'NY' in 78-79
          ==========================

 #4b. --> d 78(2),'AL',,'CALGARY'     Drop if 'AL' in 78-79 AND CALGARY anywhere
          =======================

 #4c. --> d 78(2),'AL',,!'CALGARY'    Drop if 'AL' in 78-79 AND NOT CALGARY
          ========================
Note
  • AND is the default for multiple conditions (unless '|' OR specified)
  • omitting start(length) for 2nd field defaults SAME as 1st
    if constant length is the same (as in #4a.)
  • omitting start(length) for 2nd field assumes entire record
    if constant length is DIFFERENT (as in #4b.)
  • could have had a 3rd condition in 4b & 4c if desired
 'drop' is safe, because it makes a complete backup in tmp/filename_date_timeB.
 You can restore original file if the drop did not work as intended, for example:
 - for this example that would be:

 #7. cp tmp/custmas1_140304_145149B tmp1/custmas1
     ============================================

The 'dropped' records are saved in tmp/filename_date_timeD, in case you have a use for them, & so you could inspect them as follows:


 #8. uvhd tmp/custmas1_140304_145149D r256
     =====================================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4N3. uvhd tutorial - DROPPING records

drop ex#2 - flag records to be dropped

If the records you wish to drop do not have existing unique patterns that can be specified on the drop command, you can use the update command to flag the records to be dropped. For example we could flag records in our dat1/custmas1 file with an '*' in column 7 (an unused byte after customer#).

For our demo, we will arbitrarily flag record #1,10,& 20 with '*' column 7; then run drop to drop recs with '*' in column 7. In a real life situation you would probably be searching for certain conditions and deciding which records to flag. You can repeat the flagging quickly using 'uu' (repeat last update).


 #1. cp dat1/custmas1 tmp1/custmas1   <-- copy demo file to tmp1 subcdir
     ==============================       (dont want to change demo file)

 #2. uvhd tmp1/custmas1 r256u    <-- run uvhd with Update option
     ========================
 #2a. --> u 6(1),'*'          <-- flag with '*' col 7 after cust#
         ==========
 #2b. --> 10                  <-- goto record #10
 #2c. --> uu                  <-- repeat flag update
          ===
 #2d. --> 20                  <-- goto record #20
 #2e. --> uu                  <-- repeat flag update
          ===
 #2f. --> d 6(1),'*'          <-- drop records with '*' col 7
          ==========
          - writes out 3 files to tmp/... (Backiup, Corrected, dropped)
          - then reads Corrected file back in, reopens,& prompts for next command
 #2e. --> q
         ===

 #3. l tmp        <-- list tmp subdir to see Backup, Corrected,& Dropped files
     =====
      tmp/custmas1_140304_145149B <-- Backup file (original, all records)
      tmp/custmas1_140304_145149C <-- Corrected file (after records dropped)
      tmp/custmas1_140304_145149D <-- Dropped records file
Note
  • if mistakes were made, you can restore the Backup file, modify the
    drop flags, & try again.

 #4. cp tmp/custmas1_140304_145149B tmp1/custmas1 <-- restore Backup file
     ============================================

 #5. uvhd tmp1/custmas1 r256u    <-- re-run uvhd to modify drop flags
     ========================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4O1. uvhd tutorial - TRUNCATE file-size

command 'z'
  • truncate (modify) filesize (truncate or extend with x'00's)
  • truncate works only for Unix, Linux,& Windows/SFU
  • NOT for Windows/DOS versions (uvhd.exe)
z100000
  • truncate file to 100,000 bytes
Note
  • you must have specified the 'u' update option on the command line.
  • try the following test/demo

 #1. cp dat1/custmas1 tmp/cm1       - copy test file to tmp subdir
     ========================

 #2. uvhd tmp/cm1 r256u           - enter uvhd with update option 'u'
     ==================
 filename=/home/uvadm/tmp/cm1 options=r256u
 records=32 rsize=256 fsize=8192 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 130140    EVERGREEN MOTORS LTD.    1815 BOWEN ROAD          NANA
             3333332222454545444244545524542222233332445442544422222222224444
             130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
          64 IMO          BC V9S1H1    250-754-5531 LARRY WRENCH     ..4V|...
             4442222222222442535343222233323332333324455525544442222201357000
             9DF00000000002306931810000250D754D55310C12290725E38000000246C000
         128 .........W0....`........)X}..f3.....\.................4V}...f...
             0000000005300016000000002570063100095000000000000000013570016000
             0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
         192 .E|...V}.......................f.....<........f.C 19950531
             0470005700000000880000000018000680001300000000694233333333222222
             35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
 rec#=1 rsize=256 rcount=32 fsize=8192 fptr=0
 null=next,r#=rec,s=search,u=update,x=undo,p=print,i=iprint,w=write,e=count
 ,R#=Recsize,h1=char,h2=hex,g=genseq#,c=chkseq#,t=translate(ta,te,tu,tl,tc,tp)
 ,q=quit,k0=helpoff,k1=helpon,?=HelpScreens --> z4096 <-- truncate command
 Enter command, or ?=Help, or null=NextRecord -->

 #3. --> z4096         <-- truncate file to 4096 bytes
         =====             ===========================
 filesize=4096 recsize=256, rcount=16, remndr=0 OK ? y/n --> y <--

 #4. --> y  <-- enter 'y' to confirm truncate

Note the filesize is displayed as 4096 (vs 8192) & recs count 16 (vs 32).

This command is very handy for dropping the MS-DOS EOF x'1A' from the end of large files, saving a file copy operation, before submitting to apps.

But Be Careful, you can destroy a lot of data if you make a mistake.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

4P1. uvhd tutorial - Close Files

lw/lp cLose Write/Print files

 lw  <-- may follow write command with 'lw' command to close file for separate
         output files or omit for combined outputs from multi write commands

lp <-- similar command close print files for separate or omit for combined

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_5 uvhd - file investigation hexdump utility

Variable-Length files


5A1. demo 5 types of Data-Files (vendormas0,1,2,3,4,5,6)
fixed-length: EBCDIC, fixed ASCII,
variable-length: TEXT, RDW, Micro Focus

5A2. listing of vendor master TEXT file (vendormas2)

5B1. setup to demo uvhd for various filetypes

5C1. demo uvhd for EBCDIC files

5D1. demo uvhd for ASCII Fixed Length

5E1. demo uvhd for Text files

5F1. demo uvhd for RDW (Record Descriptor Word) files
5F3. listRDW1 alternative to uvhd above

5G1. demo uvhd for Micro Focus Fixed-length files (IDXFORMAT1)
5G2. demo uvhd for Micro Focus variable-length files (IDXFORMAT3)
5G3. demo uvhd for Micro Focus variable-length files (IDXFORMAT8)

5H1. Create 6 types of fixed/variable length files using uvcp/uxcp
- use vi editor to create the text file (vendormas2)
- use 'uvcp/uxcp' to convert the text file into 5 other types
uvcp typ=RSF
  • for vendormas0 Fixed length EBCDIC file
uvcp typ=RSF
  • for vendormas1 Fixed length 64 bytes ASCII file
uvcp typ=RDW
  • for vendormas3 RDW variable length file
uvcp typ=IDXf1
  • for vendormas4 Micro Focus fixed-length Indexed file
uvxp typ=IDXf3v
  • for vendormas5 Micro Focus varlth 2 part .dat & .idx
uvxp typ=IDXf8v
  • for vendormas6 Micro Focus varlth single partition file

5I0. using uvhd (free) to convert file types (vs 'uvcp' part of VU pkg)
- Write command has options to specify output file type
5I1.  convert Text to Fixed-length 64 byte records with LineFeed last byte
5I2.  convert Text to variable-length RDW (with rec-size in binary prefixes)
5I3.  convert RDW to Text (dropping binary prefixes, inserting LineFeeds)
5I4.  convert EBCDIC RDW to ASCII RDW (or Text)

5J1. STL files added Feb 2016
- STandard Language data files for AIX COBOL

Studying &/or performing the tutorials in Part 5 will give you a good understanding of how uvhd can help you investigate & convert between the various file types. This is especially important if you are interested in mainframe conversions or file transfers between mainframes & Unix/Linux systems.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5A1. using uvhd with Variable-Length files

demo Data-Files - Fixed,Text,RDW,IDX

We will descibe the 7 types of files using vendormas0,1,2,3,4,5,6 examples. Type '0' identifies a Fixed-length file from a mainframe, which would be EBCDIC, with no LineFeeds.

dat1/vendormas0
  • Fixed length file from a mainframe (64 byte records)
  • EBCDIC with no LineFeeds
  • cannot be listed with normal Unix/Linux utilties
dat1/vendormas1
  • Fixed length file (64 bytes)
  • translated to ASCII
  • period inserted in 63rd byte to indicate End of Record
  • LineFeed inserted in 64th byte for convenience
    so you can use Unix/Linux utilities (vi,lp,cat,more,etc)
dat1/vendormas2
  • Text file with LineFeed after the last non-blank
  • can use Unix/Linux utilities (vi,lp,cat,more,etc)
  • Micro Focus COBOL 'ORGANIZATION LINE SEQUENTIAL'
  • I created this Text file with the vi editor
    Then used uvcp to convert it to the other 4 types (see '5H1')
dat1/vendormas3
  • RDW (Record Descriptor Word) file with 4 byte record prefixes
  • record-size binary in 1st 2 bytes, nulls in 3rd & 4th byte
  • file type option 'z4' for uvhd, uvhdcob, uvcp, uvcopy, etc
  • RDW must be used when variable lth files FTP'd from mainframe
dat1/vendormas4
  • Fixed length Indexed files for Micro Focus COBOL (IDXFORMAT1)
  • 2 parts vendormas4.dat (Data) & vendormas4.idx (Index)
dat1/vendormas5
  • variable length files for Micro Focus COBOL (IDXFORMAT3)
  • file header record 128 for IDXFORMAT3
  • record-size binary in 1st 2 bytes
  • various record types coded in 1st 2 bits
  • x'40' = data record, x'03' = system, x'02' = deleted
  • file type option 'v' for uvhd & uvhdcob
  • option 'typ=IDXf3/IDXf8' for uxcp, uxsort,& uxcopy
  • see details re IDXf3/f8 at uvhd.htm#5G1
dat1/vendormas6
  • variable length files for Micro Focus COBOL (IDXFORMAT8)
  • file header record 1024 for IDXFORMAT8
  • single part vendormas6.dat has both Data & Index
  • otherwise similar to IDXFORMAT3

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5A2. using uvhd with Variable-Length files

dat1/vendormas2


 vendor# type vendor-name
 =========================================
 DELL10 M  Dell Inc.
 HP0010 M  Hewlett Packard
 IBM010 M  International Business Machines
 MFC010 M  Micro Focus COBOL
 MS0010 M  Microsoft Corp.
 REDH10 M  Red Hat Linux
 SUN010 M  Sun Microsystems Ltd
 UVSI10 M  UV Software Inc.

notes re data-file listings

We list only the Text file (suffix '2'), since only the text file could be listed with normal unix/linux utilities (require LineFeeds & no binary data).

I created this Text file with the vi editor; then used uvcp to convert it to the other 4 types (see '5H1')

We will use uvhd to display or list the other filetypes on the following pages.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5B1. using uvhd with Variable-Length files

setup to demo uvhd for various filetypes

We will demo uvhd using 5 different formats of the vendor master file listed above. You can do these demos using the 'uvadm' login, or in your home directory if you copy the demo files.


 #1. login uvadm --> /home/uvadm  <-- can demo in uvadm homedir
     ===========================

OR login to your homedir & copy demo files


 #1. login yourself --> /home/yourhomedir  <-- to copy demo files to your homedir
     ====================================

 #2a. mkdir dat1        <-- make subdir for data files
      ==========

 #2b. mkdir tmp         <-- subdir for output files from Print & Write commands
      =========

 #3. cp /home/uvadm/dat1/vendormas* dat1  <-- copy all vendormas* files
     ===================================      (vendormas0,1,2,3,4,5,6)

OR download VUdemofiles from internet

If you downloaded uvhd (vs buying the Vancouver Utilities package), you can also download 'VUdemofiles.zip' from the internet as documented on page '4A1'.

OR re-create demo files with uvcp/uxcp

See '5H1' to see how you can use uvcp/uxcp to create the various types of fixed/variable/Indexed file formats from the text file version (vendormas2).

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5C1. using uvhd with Variable-Length files

demo uvhd for EBCDIC files


 #0. uvhd dat1/vendormas0 r64a     <-- options 'r64' & 'a'
     ===================*=*===
     - option 'r64' defines the record size (ommission defaults to 256)
     - option 'a' translates ebcdic to Ascii of character line
       (zone & digit lines show EBCDIC codes)
 filename=/home/uvadm/dat1/vendormas0 options=ar64
 records=8 rsize=64 fsize=512 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.
             CCDDFF4D44C8994C984444444444444444444444444444444444444444444444
             453310040045330953B000000000000000000000000000000000000000000000
 rec#=1 rsize=64 rcount=8 fsize=512 fptr=0
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard
             CDFFFF4D44C8A98AA4D889898444444444444444444444444444444444444444
             8700100400856353307132194000000000000000000000000000000000000000
 rec#=2 rsize=64 rcount=8 fsize=512 fptr=64
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
           0 IBM010 M  International Business Machines
             CCDFFF4D44C9A8998A899894CAA898AA4D888898A44444444444444444444444
             9240100400953595139651302429552204138955200000000000000000000000
 rec#=3 rsize=64 rcount=8 fsize=512 fptr=128
 Enter command, or ?=Help, or null=NextRecord -->

demo uvhd for various filetypes

  1. We will show only 1st 3 records (of 8 total) to save space.

  2. We will show all 8 records for type RDW (page '5F1'), which is more interesting since it shows the binary record-size prefixes.

  3. Option 'a' translates ebcdic to Ascii for displaying the character line, but the zones & digits lines show the EBCDIC values (in vertical hex).

  4. For example, the 1st byte (of DELL10) is 'D' or x'C4' (in horizontal hex). For ASCII (on the next page), the 'D' is x'44'.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5D1. using uvhd with Variable-Length files

demo uvhd for ASCII Fixed Length


 #1. uvhd dat1/vendormas1 r64h2  <-- options 'r64' & 'h2'
     ===================*======
     - option 'r64' defines the record size
     - option 'h2' forces display of zones & digits vertical hex lines
       (defaults to non-display since all ASCII characters)
 filename=/home/uvadm/dat1/vendormas1 options=r64h2
 records=8 rsize=64 fsize=512 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.                                           ..
             4444332422466624662222222222222222222222222222222222222222222220
             45CC100D0045CC09E3E0000000000000000000000000000000000000000000EA
 rec#=1 rsize=64 rcount=8 fsize=512 fptr=0
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard                                     ..
             4533332422467667725666676222222222222222222222222222222222222220
             8000100D00857C5440013B1240000000000000000000000000000000000000EA
 rec#=2 rsize=64 rcount=8 fsize=512 fptr=64
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
           0 IBM010 M  International Business Machines                     ..
             4443332422467676676666624776667724666666722222222222222222222220
             92D0100D009E452E149FE1C02539E5330D1389E53000000000000000000000EA
 rec#=3 rsize=64 rcount=8 fsize=512 fptr=128
 Enter command, or ?=Help, or null=NextRecord -->
  1. Note that last 2 bytes of each record show as '..' 2 periods.

  2. I inserted the 1st '.' period simply to mark the end of the record (except for the LineFeed which is the actual last byte of Text records)

  3. The LineFeed x'0A' is displayed as a '.' period since uvhd displays all unprintable bytes on the character line as '.' periods.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5E1. using uvhd with Variable-Length files

demo uvhd for Text files


 #2. uvhd dat1/vendormas2 th2    <-- note options 't' & 'h2'
     ===================*====
     - option 't' for Text files (variable length terminated by LineFeed)
     - option 'h2' forces display of zones & digits vertical hex lines
 filename=/home/uvadm/dat1/vendormas2 options=th2
 records=8 rsize=20 fsize=225 fsize%rsize(rmndr)=5
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.
             44443324224666246620
             45CC100D0045CC09E3EA
 rec#=1 rsize=20 rcount=8 fsize=225 fptr=0
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard
             453333242246766772566667620
             8000100D00857C5440013B1240A
 rec#=2 rsize=27 rcount=8 fsize=225 fptr=20
 Enter command, or ?=Help, or null=NextRecord -->
  1. This Text file is the 1st variable-length file of the 5 file types (Fixed EBCDIC, fixed ASCII, Text, RDW, Micro Focus variable-length).

  2. Note the last byte of each record is x'0A' LineFeed (text record terminator).

  3. The record-length is displayed below each hexdump. For the 1st 3 records rsize=20, rsize=27,& rsize=42.

    notes re Variable-Length files

  4. As of Nov 2010, on startup for Variable-Length record files, uvhd builds an Index of record#s & file-pointers for subsequent use by the 'f#' (find) command to quickly find records by their record# (an easy calculation for Fixed-Length record files).

  5. The Index is built by reading thru the entire file & creating a memory table of record#s & file-pointers at 1% intervals (reducing sequential search times).

  6. Building the Index also allows uvhd to display the correct total record count (otherwise impossible for variable length files).

  7. The Index allows us to use the 'f#' (find command) to find any record by its true record# in variable-length files. Without find Index, you could use 'r#' for a desired record# but it would be incorrect, since r# is for Fixed-Length files & calculates based on the current record-size.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5F1. using uvhd with Variable-Length files

demo uvhd for 'RDW' files


 uvhd dat1/vendormas3 z4  <-- option 'z4' for recsize in 4 byte binary prefix
 =======================

--> p8 <-- print 8 records to tmp/vendormas1_yymmdd_hhmmssP


 uvlp12 tmp/vendormas3_100607_160344P  <-- list Print command output
 ====================================
 uvhd filename=/home/uvadm/dat1/vendormas3
 options=z4 lastmod=2010060708 today=20100607160344 print=p8
 records=8 rsize=23 fsize=249 fsize%rsize(rmndr)=19
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ....DELL10 M  Dell Inc.
             01004444332422466624662
             070045CC100D0045CC09E3E
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 ....HP0010 M  Hewlett Packard
             010045333324224676677256666762
             0E008000100D00857C5440013B1240
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
           0 .-..IBM010 M  International Business Machines
             020044433324224676766766666247766677246666667
             0D0092D0100D009E452E149FE1C02539E5330D1389E53
                      10        20        30        40        50        60
 r#        4 0123456789012345678901234567890123456789012345678901234567890123
           0 ....MFC010 M  Micro Focus COBOL
             0100444333242246676246677244444
             0F00D630100D00D932F06F35303F2FC
                      10        20        30        40        50        60
 r#        5 0123456789012345678901234567890123456789012345678901234567890123
           0 ....MS0010 M  Microsoft Corp.
             01004533332422466767667246772
             0D00D300100D00D932F3F6403F20E
                      10        20        30        40        50        60
 r#        6 0123456789012345678901234567890123456789012345678901234567890123
           0 ....REDH10 M  Red Hat Linux
             010054443324225662467246677
             0B002548100D0025408140C9E58
                      10        20        30        40        50        60
 r#        7 0123456789012345678901234567890123456789012345678901234567890123
           0 ."..SUN010 M  Sun Microsystems Ltd
             0200554333242257624667677776672476
             020035E0100D0035E0D932F39345D30C44
                      10        20        30        40        50        60
 r#        8 0123456789012345678901234567890123456789012345678901234567890123
           0 ....UVSI10 M  UV Software Inc.
             010055543324225525667767624662
             0E005639100D005603F64712509E3E

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5F2. using uvhd with Variable-Length files

notes re RDW files

  1. The display for RDW looks different than the prior file types, because we used the 'print' command vs the 'browse' command. 'p8' prints first 8 records to a file which we inserted here. We could have used 'p99' if we were not sure how many but wanted them all.

  2. Note the record sizes displayed on each of the 8 records above. Record-Sizes: #1=23, #2=30, #3=45, #4=31, #5=29, #6=27, #7=34, #8=30.

  3. For RDW files the recsize is stored in a 4 byte record-prefix (binary in 1st 2 bytes, 3&4 null).

  4. Record sizes in hexadecimal & decimal are: #1=x'17'=23, #2=x'1E'=30, #3=x'2D'=45, #4=x'1F'=31, #5=x'1D'=29, #6=x'1B'=27, #7=x'22'=34, #8=x'1E'=30.

  5. For variable lth files, the record count would be wrong, without building an Index on startup, which uvhd now does since November 2010. Prior to the Index the record# was calculated at each record by dividing the file-size by the record-size.

  6. Building the Index on startup speeds up subsequent finds by record#. Startup reads to EOF storing file-pointers & record#s at 1% filesize intervals. This also locks in the correct record count on all future screens headings. Use 'f#' to find records by their actual record# in Variable-Length files (vs r# for Fixed-length files).

  7. When files are FTP'd from a mainframe, any variable length files should be FTP'd with the RDW option.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5F3. using uvhd with Variable-Length files

listRDW1 alternative to uvhd above

When you want to list an RDW file, an alternative to 'uvhd' could be 'uvcopy listRDW1', which will provide a more compact listing & it shows the record-size converted to decimal (vs hexadecimal by uvhd).


 #1. uvcopy listRDW1,fili1=dat1/vendormas3   <-- list in vertical hexadecimal
     =====================================
     - by default writes output file to tmp/... (with same name as input)

 #2. uvlp12 tmp/vendormas3     <-- list report file created by listRDW1
     =====================
           1         2         3         4         5         6         7
 01234567890123456789012345678901234567890123456789012345678901234567890123456789
 rec# rcsz <---------------- record data (1st 64 bytes) ------------------>
 0001 0019 DELL10 M  Dell Inc.
           4444332422466624662
           45CC100D0045CC09E3E
 0002 0026 HP0010 M  Hewlett Packard
           4533332422467667725666676
           8000100D00857C5440013B124
 0003 0041 IBM010 M  International Business Machines
           44433324224676766766666247766677246666667
           92D0100D009E452E149FE1C02539E5330D1389E53
 0004 0027 MFC010 M  Micro Focus COBOL
           444333242246676246677244444
           D630100D00D932F06F35303F2FC
 0005 0025 MS0010 M  Microsoft Corp.
           4533332422466767667246772
           D300100D00D932F3F6403F20E
 0006 0023 REDH10 M  Red Hat Linux
           54443324225662467246677
           2548100D0025408140C9E58
 0007 0030 SUN010 M  Sun Microsystems Ltd
           554333242257624667677776672476
           35E0100D0035E0D932F39345D30C44
 0008 0026 UVSI10 M  UV Software Inc.
           55543324225525667767624662
           5639100D005603F64712509E3E

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5G1. using uvhd with Micro Focus COBOL files

uvhd demo for Micro Focus IDXFORMAT1 Fixed-Length files


 uvhd /home/uvadm/dat1/vendormas4.dat r64
 ========================================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.                                            .
             4444332422466624662222222222222222222222222222222222222222222220
             45CC100D0045CC09E3E00000000000000000000000000000000000000000000A
 rec#=1 rsize=64 fptr=0 fsize=512 rcount=8 -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
          64 HP0010 M  Hewlett Packard                                      .
             4533332422467667725666676222222222222222222222222222222222222220
             8000100D00857C5440013B12400000000000000000000000000000000000000A
 rec#=2 rsize=64 fptr=64 fsize=512 rcount=8 -->
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
         128 IBM010 M  International Business Machines                      .
             4443332422467676676666624776667724666666722222222222222222222220
             92D0100D009E452E149FE1C02539E5330D1389E530000000000000000000000A
 rec#=3 rsize=64 fptr=128 fsize=512 rcount=8 --> q <-- enter 'q' to quit

Notes re IDXFORMAT1 fixed-length Indexed files

  1. Note that IDXFORMAT1 files have x'0A' in the last byte of the record size. This is the status byte for a valid record (x'00' for a deleted record). x'0A' is the same code as a LineFeed in text files, which means you can use various unix utilities (such as vi, more, lp, grep, etc). BUT, you would need to be very careful using vi to update since deleting or inserting even 1 byte destroys the remainder of the file since the index assumes that all records are exactly the record size loaded.

  2. We can load IDXFORMAT1 files with either 'uvcp' or 'uxcp'. 'uxcp' uses the Micro Focus file handler & the user must have Micro Focus COBOL installed. 'uvcp' uses the D-ISAM file handler & you do not need MF COBOL installed. Here are the 2 commands to load the file (shortening names from vendormas2/4 to vmas2/4 to fit the command on 1 line). Note the difference 'uvcp' & 'typ=ISF' for D-ISAM vs 'uxcp' & typ=IDXf1 for MF IDXFORMAT1.


 uvcp "fili1=dat1/vmas2,typ=LST,rcs=64,filo1=dat1/vmas4,typ=ISF,rcs=63,isk1=0(6)"
 =*=========================================================***==================

 uxcp "fili1=dat1/vmas2,typ=LST,rcs=64,filo1=dat1/vmas4,typ=IDXf1,rcs=63,isk1=0(6)"
 =*=========================================================*****==================
  1. Note that we defined the record-size as 'rcs=63' on the uvcp (or uxcp) used to load the file - so that the physical record-size would be 64 (after loading adds the x'0A'). This is simply a convenience for uvhd which displays files in 64 byte segments.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5G2. using uvhd with Variable-Length files

uvhd demo for Micro Focus variable-length files


 uvhd dat1/vendormas5.dat v  <-- option 'v' for Micro Focus variable-length files
 ==========================      (IDXFORMAT3 for this example)
 filename=/home/uvadm/dat1/vendormas5.dat options=v
 records=9 rsize=128 fsize=436 fsize%rsize(rmndr)=52
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 0~......1006111057582110061110575821.>...................>......
             3700000033333333333333333333333333330300000000000000000003000000
             0E00000010061110575821100611105758210E0200000000100000000E000600
          64 ............................................Xl9x................
             0000000000000000000000000000000000000000000056370000000000000000
             000000000000201000000000000000000000000000008C980000000000000000
 rec#=1 rsize=128 rcount=9 fsize=436 fptr=0 -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 @.DELL10 M  Dell Inc....
             414444332422466624662000
             0345CC100D0045CC09E3E000
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
           0 @.HP0010 M  Hewlett Packard
             4145333324224676677256666762
             0A8000100D00857C5440013B1240

demo uvhd for IDXf3/IDXf8 files

  1. This is a variable length files for Micro Focus COBOL.

  2. The first record is the 'file header record'. See the layout at uvcp.htm#J4 or on the Micro Focus COBOL website.

  3. The file header record is identified by x'3_' in 1st 4 bits vs data records which have x'4_' in 1st 4 bits.

  4. The record-size is coded in the right hand 12 bits of 1st 2 bytes. The file header records is x'_07E' (7*16+14=128). The 1st data record is x'_013' (1*16+3=19 bytes). The 2nd data record is x'_01A' (1*16+10=26 bytes).

  5. Note that vendormas5 is a Micro Focus IDXFORMAT3 variable length Indexed file with 2 partitions (vendormas5.dat & vendormas5.idx). We are investigating the data partition (vendormas5.dat). If desired, you could also investigate the Index partition as follows:


 uvhd dat1/vendormas5.idx   <-- investigate Index partition (binary file)
 ========================     - omit options to display 256 byte chunks
  1. The Vancouver Utilities (uxcopy,uxsort,uxcp) can handle these files and refers to them as IDXf3 and IDXf8.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5G3. using uvhd with Variable-Length files

uvhd demo for Micro Focus IDXFORMAT8


 uvhd /home/uvadm/dat1/vendormas6.dat v
 ======================================
 now=20121120:1324 uvhd /home/uvadm/dat1/vendormas6.dat v
 version=20120908 records=10 rsize=1024 fsize=3408
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 3.......1211201109473212112011094732.>...................@......
             3F00000033333333333333333333333333330300000000000000000004000000
             3E00000012112011094732121120110947320E02001800001060000000000600
          64 ............................................X.;.X.;............P
             0000000000000000000000000000000000000000000050305030000000000005
             0000000800002210000000000000000000000000000988B288B20000000000D0
         128 .......P........................................................
             00000005000000000000000000000000000000000000000F0000000000000000
             000000D04244010400000040000000C0000000000000003E0000000000000000
                      --- omitting 768 bytes of header record ---
                                 (all x'00' nulls)
         960 ................................................................
             0000000000000000000000000000000000000000000000000000000000000000
             0000000000000000000000000000000000000000000000000000000000000000
 rec#=1 rsize=1024 fptr=0 fsize=3408 rcount=10 -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
        3144 @.DELL10 M  Dell Inc....
             414444332422466624662000
             0345CC100D0045CC09E3E000
 rec#=2 rsize=24 fptr=3144 fsize=3408 rcount=10 -->
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
        3168 @.HP0010 M  Hewlett Packard
             4145333324224676677256666762
             0A8000100D00857C5440013B1240
 rec#=3 rsize=28 fptr=3168 fsize=3408 rcount=10 -->

Notes re IDXFORMAT3/8 differences

  1. The uvhd display is similar except that the IDXFORMAT8 header record is 1024 bytes vs 128 for IDXFORMAT3

  2. You use the same option 'v' to identify both IDXFORMAT3 & IDXFORMAT8

  3. IDXFORMAT8 files have only 1 partition (.dat) vs 2 parts for IDXFORMAT3 (.dat & .idx).

  4. IDXFORMAT8 allows files > 2 gigs (IDXFORMAT3 does not)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5H1. using uvhd with various file types

creating deno files with uvcp/uxcp

Here is how I created the 6 types of fixed/variable length files. First I used the vi editor to create the text file (vendormas2). Then I used 'uvcp' to create vendormas0 (EBCDIC fixed), vendormas1 (ASCII fixed), vendormas3 (RDW) & vendormas4 (IDXFORMAT1). Finally I used 'uxcp' to create vendormas5 (Micro Focus IDXFORMAT3) & vendormas6 (Micro Focus IDXFORMAT8). Note that only 'uxcp' has the file handler for Micro Focus variable length files.


 #1. vi dat1/vendormas2
     ==================
      DELL10 M  Dell Inc.
      HP0010 M  Hewlett Packard
      IBM010 M  International Business Machines
      MFC010 M  Micro Focus COBOL
      MS0010 M  Microsoft Corp.
      REDH10 M  Red Hat Linux
      SUN010 M  Sun Microsystems Ltd
      UVSI10 M  UV Software Inc.

 #2. uvcp "fili1=dat1/vendormas2,typ=LST,rcs=64\
          ,filo1=dat1/vendormas0,typ=RSF,tre=0(64)"
     ==========================*=========*********=

 #3. uvcp "fili1=dat1/vendormas2,typ=LST,rcs=64,filo1=dat1/vendormas1,typ=RSF"
     ===============================================================*=====***=

 #4. uvcp "fili1=dat1/vendormas2,typ=LST,rcs=64,filo1=dat1/vendormas3,typ=RDW"
     ===============================================================*=====***=

 #5. uxcp "fili1=dat1/vendormas2,typ=LST,rcs=64\
          ,filo1=dat1/vendormas4,typ=IDXf1,isk1=0(6)"
     ****======================*=====*****===========

 #6. uxcp "fili1=dat1/vendormas2,typ=LST,rcs=64\
          ,filo1=dat1/vendormas5,typ=IDXf3v,isk1=0(6)"
     ****======================*=====******===========

 #7. uxcp "fili1=dat1/vendormas2,typ=LST,rcs=64\
          ,filo1=dat1/vendormas6,typ=IDXf8v,isk1=0(6)"
     ****======================*=====******===========

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5H2. using uvhd with various file types

Notes re uvcp/uxcp file types

  1. Note the output file 'typ's (after filo1=...) are:

typ=RSF
  • vendormas0 Fixed length (EBCDIC)
typ=RSF
  • vendormas1 Fixed length (ASCII)
typ=RDW
  • vendormas3 RDW variable length
  • RDW files have binary record size in 1st 2 bytes each record
typ=IDXf1
  • vendormas4 Micro Focus Fixed length
typ=IDXf3v
  • vendormas5 Micro Focus variable length
  • 2 parts vendormas5.dat (Data) & vendormas5.idx (Index)
typ=IDXf8v
  • vendormas6 Micro Focus variable length
  • single part vendormas6.dat has both data & index
  1. Note 'tre=0(64)' translates ASCII to EBCDIC (vendormas0)

  2. Note 'isk1=0(6)' specifies the key for Indexed files (vendormas4,5,6)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5I0. using uvhd with Variable-Length files

using uvhd to convert file types

On the prior page, we showed you how we used the Text file version (vendormas2) to create the other file types (Fixed,RDW,& Micro Focus variable) using 'uvcp', which is part of the Vancouver Utilities package.

We could also use 'uvhd' to convert between file types. This could be useful to you if you do not have the Vancouver Utilities package, since 'uvhd' is a free download. We will demo 4 uvhd conversions on next 4 pages: (Text to Fixed, Text to RDW, RDW to Text, EBCDIC RDW to ASCII Text).

5I1. uvhd convert Text to Fixed-length


 #1. uvhd dat1/vendormas2 t   <-- Text file input to Write Fixed-length output
     ======================
 filename=/home/uvadm/dat1/vendormas2 options=t
 records=8 rsize=20 fsize=225 fsize%rsize(rmndr)=5
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.
 rec#=1 rsize=20 rcount=8 fsize=225 fptr=0
 Enter command, or ?=Help, or null=NextRecord --> wr63t2  <-- Write command

 #2. --> wr63t2  <-- Write with option 'r63' recsize & 't2' append LineFeed
     ==========

 #3. uvhd tmp/vendormas2_100814_123641W r64h2  <-- verify output as expected
     ========================================
 filename=/home/uvadm/tmp/vendormas2_100814_123641W options=r64h2
 records=8 rsize=64 fsize=512 fsize%rsize(rmndr)=0
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.                                            .
             4444332422466624662222222222222222222222222222222222222222222220
             45CC100D0045CC09E3E00000000000000000000000000000000000000000000A
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard                                      .
             4533332422467667725666676222222222222222222222222222222222222220
             8000100D00857C5440013B12400000000000000000000000000000000000000A

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5I2. using uvhd with Variable-Length files

uvhd convert Text to RDW variable-length


 #1. uvhd dat1/vendormas2 t   <-- Text file input to Write RDW var-lth output
     ======================
 filename=/home/uvadm/dat1/vendormas2 options=t
 records=8 rsize=20 fsize=225 fsize%rsize(rmndr)=5
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc.
 rec#=1 rsize=20 rcount=8 fsize=225 fptr=0
 Enter command, or ?=Help, or null=NextRecord --> wz4  <-- Write command

 #2. --> wz4  <-- Write with option 'z4' for RDW var-lth output
     =======

 #3. uvhd tmp/vendormas2_100814_123305W z4   <-- verify output as expected
     =====================================     - option 'z4' for RDW
 filename=/home/uvadm/tmp/vendormas2_100814_123305W options=z4
 records=8 rsize=24 fsize=257 fsize%rsize(rmndr)=17
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ....DELL10 M  Dell Inc.
             010044443324224666246622
             080045CC100D0045CC09E3E0
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 ....HP0010 M  Hewlett Packard
             0100453333242246766772566667622
             0F008000100D00857C5440013B12400
Note
  • If you wish to save the Write output file, you would of course rename it.
  • For example, I could have created the RDW demo file (vendormas3) as above
    and I could have saved it as follows:

 #4. cp tmp/vendormas2_100814_123305W dat1/vendormas3
     ================================================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5I3. using uvhd with Variable-Length files

uvhd convert RDW to TEXT


 #1. uvhd dat1/vendormas2 z4  <-- z4 RDW input for Text output (Write below)
     =======================
 filename=/home/uvadm/dat1/vendormas3 options=z4
 records=8 rsize=23 fsize=249 fsize%rsize(rmndr)=19
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ....DELL10 M  Dell Inc.
             01004444332422466624662
             070045CC100D0045CC09E3E
 rec#=1 rsize=23 rcount=8 fsize=249 fptr=0
 Enter command, or ?=Help, or null=NextRecord --> wt6 <-- Write command

 #2. --> wt6   <-- Write command with option 't6' (t2+t4=t6)
         ===       't2' = append LineFeed,
                   't6' = after last non-blank (vs at end fixed length)
                      10        20        30        40        50        60
 r#        8 0123456789012345678901234567890123456789012345678901234567890123
           0 ....UVSI10 M  UV Software Inc.
             010055543324225525667767624662
             0E005639100D005603F64712509E3E
 wt6 8 records written to: tmp/vendormas3_100817_111250W

Now use uvhd to verify the output file is as expected as follows:


 #3. uvhd tmp/vendormas2_100814_123305W t  <-- option 't' to read Text output
     ====================================
 filename=/home/uvadm/tmp/vendormas3_100817_111250W options=th2
 records=8 rsize=20 fsize=224 fsize%rsize(rmndr)=4
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc..
             44443324224666246620
             45CC100D0045CC09E3EA
 rec#=1 rsize=20 rcount=8 fsize=224 fptr=0
 Enter command, or ?=Help, or null=NextRecord -->
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard.
             45333324224676677256666760
             8000100D00857C5440013B124A
 rec#=2 rsize=26 rcount=8 fsize=224 fptr=20
 Enter command, or ?=Help, or null=NextRecord -->

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5I4. using uvhd with Variable-Length files

convert/translate EBCDIC RDW to ASCII TEXT


 #1. uvhd dat1/vendormas2 z4a1 <-- option z4 RDW input for Text output from Write
     =========================   - option 'a1' to show character line as ASCII
                                   (does not actual translate the data yet)
 filename=/home/uvadm/dat1/vendormas3e options=z4a
 records=8 rsize=23 fsize=249 fsize%rsize(rmndr)=19
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ....DELL10 M  Dell Inc.
             0100CCDDFF4D44C8994C984          <-- Note EBCDIC zones
             0700453310040045330953B          <-- Note EBCDIC digits
 rec#=1 rsize=23 rcount=8 fsize=249 fptr=0
 Enter command, or ?=Help, or null=NextRecord -->

 #2. --> wt6a1  <-- Write with option 't6' to write Text LF after last non-blank
                  - and option 'a1' to translate EBCDIC to ASCII
 wt6a1 8 records written to: tmp/vendormas3e_100817_205332W

Now use uvhd to verify the output file is as expected as follows:


 #3. uvhd tmp/vendormas3e_100817_205332W t  <-- option 't' to read Text output
     =====================================
 filename=/home/uvadm/tmp/vendormas3e_100817_205332W options=th2
 records=8 rsize=20 fsize=224 fsize%rsize(rmndr)=4
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 DELL10 M  Dell Inc..
             44443324224666246620
             45CC100D0045CC09E3EA
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
           0 HP0010 M  Hewlett Packard.
             45333324224676677256666760
             8000100D00857C5440013B124A
Note
  • we could have written the output file as RDW but translated from
    EBCDIC to ASCII as follows:

 #2. --> wz4a1  <-- Write with option 'z4' to write RDW format
                  - and option 'a1' to translate EBCDIC to ASCII

You could use the ASCII to EBCDIC option 'e1' if you need to return unix/ASCII files to mainframe/EBCDIC files.


 #2. --> wz4e1  <-- Write with option 'z4' to write RDW format
                  - and option 'e1' to translate ASCII to EBCDIC

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J1. uvhd - Data file Utility

file type STL

File 'typ=STL' is the STandard Language file system used by AIX COBOL, added to uvhd,uvcp,uvsort,uvcopy in February 2016. We provide "INPUT ONLY". You can use 'uvhd' to investigate STL records & uvcp/uvsort/uvcopy to convert to other file types (LSTt,RSF,RST,RDW,RDW,RSV,etc).

There are STL 3 subtypes Sequential,Indexed,& Relative, coded as x2,x4,& x8 for uvhd. We provide demo files for each type.

uvhd examples


 uvhd dat1/testSTLs x2    <-- display data records in STL Sequential file
 =====================      - option 'x2' indicates STL Sequential

 uvhd dat1/testSTLi x4    <-- display data records in STL Indexed file
 =====================      - option 'x4' indicates STL Indexed

 uvhd dat1/testSTLr x8    <-- display data records in STL Relative file
 =====================      - option 'x8' indicates STL relative

uvcp examples

Here are uvcp examples converting the 3 demo files provided in $UV/dat1/... We will convert them to 'typ=LSTt' which can be easily checked with vi.


 uvcp "fili1=dat1/testSTLs,typ=SLTs,rcs=4096,filo1=tmp/teststls,typ=LSTt"
 =======================================================================
 - convert 'typ=STLs' Sequential to 'typ=LSTt' Line Sequential

 uvcp "fili1=dat1/testSTLi,typ=SLTi,rcs=4096,filo1=tmp/teststli,typ=LSTt"
 =======================================================================
 - convert 'typ=STLi' Indexed to 'typ=LSTt' Line Sequential

 uvcp "fili1=dat1/testSTLr,typ=SLTr,rcs=4096,filo1=tmp/teststlr,typ=LSTt"
 =======================================================================
 - convert 'typ=STLr' Relative to 'typ=LSTt' Line Sequential

We specify 'rcs=4096' or a size you know is larger than the largest record expected. Record size specified by rcs=... will init I/O areas to blanks, The actual record size is specified in the file header &/or as a prefix on each record & could vary from record to record.

Output 'typ=LSTt' inserts a LineFeed x'0A' after the last nonblank, truncating records depending on data present. So the output records could vary from 4096 bytes down to 1 byte.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J2. file typ=STL

STL file formats

These are complex file formats with file headers & record headers. By default uvhd will display only the valid data records, bypassing file headers, deleted data records,& system records (in Indexed & Relative files). File headers are 112 bytes for sequential & 2048 bytes for Indexed & Relative files. System records (Indexed & Relative files) are 4096 bytes.

If desired, there are options to display deleted data records, file headers,& system records (y4=deleted,y1=header,y2=system,y7=all). There is also option j4 to display only deleted data records (bypassing valid data records).

Here is a uvhd (hexdump) of the STL sequential demo file provided. Since I know this demo file contains only 2 80 byte data records and the total file-size (including file headers & data records) is 288 bytes, I will specify that as the record size to see all on 1 screen.


 uvhd dat1/testSTLs r288
 =======================
              10        20        30        40        50        60
     1 0123456789012345678901234567890123456789012345678901234567890123
     0 ...p ...STLS....................................................
       0007210055450000000000000000000000000000000000000000000000000000
       0000054034C31234000100000000000000000000000000000000000000000000
    64 .......P.......P.......P....................... ...Pinseql----bb
       0000000500000005000000050000000000010000000000020005667676222266
       00000000000000000000000000000002000000000000001000009E351CDDDD22
   128 bbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhh
       6666666666666666666666666666666666666666666666666666666666666666
       2222222233333333334444444444555555555566666666667777777777888888
   192 hhhx...P...Pinseq2----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeff
       6667000500056676732222666666666666666666666666666666666666666666
       8888000000009E3512DDDD222222222233333333334444444444555555555566
   256 ffffffffgggggggggghhhhhhhhhx...P
       66666666666666666666666666670005
       66666666777777777788888888880000

The 1st record prefix starts at file displacement 112 (uvhd 1st line 64 + 48 from 2nd line) which is x'00000070' matching the 1st 4 bytes in the file header.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J3. file typ=STL

uvhd display - STLs Sequential


 uvhd dat1/testSTLs x2    <-- option 'x2' for STL Sequential records
 =====================
 rec#=1 rsize=88 fptr=112 fsize=288 rcount=3
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
         112 ...Pinseql----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff
             0005667676222266666666666666666666666666666666666666666666666666
             00009E351CDDDD22222222223333333333444444444455555555556666666666
          64 gggggggggghhhhhhhhhx...P
             666666666666666666670005
             777777777788888888880000
 rec#=2 rsize=88 fptr=200 fsize=288 rcount=3
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
         200 ...Pinseq2----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff
             0005667673222266666666666666666666666666666666666666666666666666
             00009E3512DDDD22222222223333333333444444444455555555556666666666
          64 gggggggggghhhhhhhhhx...P
             666666666666666666670005
             777777777788888888880000

The data records are preceded & followed by the record length in binary x'00000050' (horizontal hex vs vertical hex in uvhd) - is decimal 80 (5*16) The x'50' (recsize 80) conincides with the ASCII code for letter 'P'.

Note that 'uvhd' shows the record prefixes & suffixes, but 'uvcp' will extract only the data records.

By default uvhd bypasses STL file headers. Note that the file displacement to data record #1 is 112 bytes (the length of a STL Sequential file header).

option y1 to display STLs file header


 uvhd dat1/testSTLs x2y1   <-- option 'x2' for STL Sequential records
 =======================     - option 'y1' to show file header
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 ...p ...STLS....................................................
             0007210055450000000000000000000000000000000000000000000000000000
             0000054034C31234000100000000000000000000000000000000000000000000
          64 .......[.......[.......[.......................N
             000000050000000500000005000000000001000000000004
             0000000B0000000B0000000B0000000A000000000000004E
 rec#=1 rsize=112 fptr=0 fsize=1102 records=11

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J4. file typ=STL

STLi Indexed file format

The file headers for STL Indexed (& Relative) files are 2048 bytes or more. They also contain system records for Indexes which are always 4096 bytes aand are identified by x'20' in 1st byte. uvhd will automatically bypass file headers & system records, but if you wanted to see them you could use uvhd with the default file type (fixed records of 256 bytes).


 uvhd dat1/testSTLi r256
 =======================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 .... ...STLI..................................................i0
             0000210055440000000000000000001000000000000000000000000000001063
             0080054034C90000000000020000008000000000000000000000000000010D90
          64 ................................................................
             0000000000000000000000000000000000000000000000000000000000000000
             0000000000000000000000000000000000000000000000000000000012340001
         128 ...............................P.......P.......P................
             0000000000000010000000000000000500000005000000050000000000000000
             0000000000000000000100000000000000000000000000000000000000000000
               ------ data omitted to end of file header 2048 bytes ------
                      10        20        30        40        50        60
 r#        9 0123456789012345678901234567890123456789012345678901234567890123
        2048  .............................................._................
             2000000000000000000000000000000000000010000000150000001B00000011
             000A0000000000800000000000000000000000800000008F0000008E0000009D
          64 .......|...............:.......................W................
             000000170000001D00000013000000190000001F000000150000000000000000
             0000009C0000009B000000AA000000A9000000A8000000B70000000000000000
               ---- data omitted to end system INDEX record 4096 bytes ----
                      10        20        30        40        50        60
 r#       25 0123456789012345678901234567890123456789012345678901234567890123
        6144 @..Tinseql----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff
             4005667676222266666666666666666666666666666666666666666666666666
             00049E351CDDDD22222222223333333333444444444455555555556666666666
          64 gggggggggghhhhhhhhhx@..Tinseq2----bbbbbbbbbbccccccccccdddddddddd
             6666666666666666666740056676732222666666666666666666666666666666
             7777777777888888888800049E3512DDDD222222222233333333334444444444
         128 eeeeeeeeeeffffffffffgggggggggghhhhhhhhhx
             6666666666666666666666666666666666666667
             5555555555666666666677777777778888888888

The Indexed & Relative files file header records are 2048 bytes or larger. See file hdr size in 1st 4 bytes x'00000800' = 8 * 256 = 20148 bytes.

The record at 2048 begins with x'200000A'. x'20' identifies this as a system record which is always 4096 bytes & is bypassed.

The 1st data record begins at 2048 + 4096 = 6144 bytes & begins with x'40000054' The x'40' identifies a valid data record, Deleted records would be x'80'. The x'000054' is the record length including the 4 byte record hdr (5*16)+(1*4) = 84

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J5. file typ=STL

uvhd display - STLi Indexed


 uvhd dat1/testSTLi x4    <-- option 'x4' for STL Indexed records
 =====================
 rec#=1 rsize=84 fptr=6144 fsize=6312 rcount=75
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
        6144 @..Tinseql----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff
             4005667676222266666666666666666666666666666666666666666666666666
             00049E351CDDDD22222222223333333333444444444455555555556666666666
          64 gggggggggghhhhhhhhhx
             66666666666666666667
             77777777778888888888
 rec#=2 rsize=84 fptr=6228 fsize=6312 rcount=75
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
        6228 @..Tinseq2----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff
             4005667673222266666666666666666666666666666666666666666666666666
             00049E3512DDDD22222222223333333333444444444455555555556666666666
          64 gggggggggghhhhhhhhhx
             66666666666666666667
             77777777778888888888

Each data record is preceded by a 4 byte record header x'40000054' in this case. x'000054' is the record length including the 4 byte record hdr (5*16)+(1*4) = 84. The x'40' identifies a valid data record vs deleted records.

Note the file displacement to data record #1 is 6144 bytes (file header 2048 + system Index record 4096).

By default uvhd bypasses deleted records, file header records & system records, But there are options to show these records as follows:

 uvhd dat1/testSTLi x4      option 'x4' - show only valid data records
                                          in STL Indexed files

uvhd dat1/testSTLi x4y4 option 'y4' - also show Deleted records

uvhd dat1/testSTLi x4y1 option 'y1' - also show file header (2048 bytes)

uvhd dat1/testSTLi x4y2 option 'y2' - also show System records (4096 bytes)

uvhd dat1/testSTLi x4y7 option 'y7' - show All records

 uvhd dat1/testSTLi x4y4j4  option 'j4' - inhibit showing valid data records
                             - use 'j4' (with x4y4) to see only deleted records
                               in STL Indexed files

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J6. file typ=STL

Demo option 'y7' show file hdr, system,& deleted records


 uvhd dat1/testSTLi2 x4y7  <-- option 'y7' show All records in Indexed files 'x4'
 ========================
 records=6 deleted=1 rsize=2048 fsize=6524
 rec#=1 rsize=2048 fptr=0 fsize=6524 records=6 deleted=1
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 .... ...STLI...................................................p
             0000210055440000000000000000001000000000000000000000000000001007
             0080054034C900000000000A0000008000000000000000000000000000010B10
             <------- showing only 1st 64 bytes of 2048 file header -------->
 rec#=2 rsize=4096 fptr=2048 fsize=6524 records=6 deleted=1
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
        2048  .............................................._...............|
             2000000000000000000000000000000000000010000000150000001100000017
             00070000000000800000000000000000000000800000008F0000009D0000009C
             <------- showing only 1st 64 bytes of 4096 System record ------>
 rec#=3 rsize=95 fptr=6144 fsize=6524 records=6 deleted=1
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
        6144 @.._000000001ISAM               <-- 1st data record
             4005333333333454422222222222222222222222222222222222222222222222
             000F000000001931D00000000000000000000000000000000000000000000000
          64                       000000001
             2222222222222222222222333333333
             0000000000000000000000000000001
 rec#=4 rsize=95 fptr=6239 fsize=6524 records=6 deleted=1
                      10        20        30        40        50        60
 r#        4 0123456789012345678901234567890123456789012345678901234567890123
        6239 @.._000000002ISAM               <-- valid data x'40' 1st byte
             4005333333333454422222222222222222222222222222222222222222222222
             000F000000002931D00000000000000000000000000000000000000000000000
          64                       000000002
             2222222222222222222222333333333
             0000000000000000000000000000002
 rec#=5 rsize=95 fptr=6334 fsize=6524 records=6 deleted=1
                      10        20        30        40        50        60
 r#        5 0123456789012345678901234567890123456789012345678901234567890123
        6334 ..._..................._....... <-- Deleted record x'80' 1st byte
             8005000000000000000000050000000000000000000000000000000000000000
             000F0000000000000000000F0000000000000000000000000000000000000000
          64 ...............................
             0000000000000000000000000000000
             0000000000000000000000000000000

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J7. file typ=STL

STLr Relative file format

The file headers for STL Relative files are also 2048 bytesor more & are also followed by a system record of 4096 bytes. uvhd will automatically bypass the file headers, but if you wanted to see them you could use uvhd with the default file type (fixed records of 256 bytes).


 uvhd dat1/testSTLr r256
 =======================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 .... ...STLI....................................................
             000021005544000000000000000000100000000000000000000000000000100F
             0080054034C90000000000020000008000000000000000000000000000010BC0
          64 ................................................................
             0000000000000000000000000000000000000000000000000000000000000000
             0000000000000000000000000000000000000000000000000000000012340001
         128 ...............................T.......T.......T................
             0000000000000010000000000000000500000005000000050000000000010000
             0000000000000000000100000000000400000004000000040000000400000000
               ------ data omitted to end of file header 2048 bytes ------
                      10        20        30        40        50        60
 r#        9 0123456789012345678901234567890123456789012345678901234567890123
        2048  ..............................................c...............)
             2000000000000000000000000000000000000010000000160000001C00000012
             000A000000000080000000000000000000000080000000830000008600000099
          64 .......................R.......................{................
             000000180000001E000000150000001B00000011000000170000000000000000
             0000009C0000009F000000A2000000A5000000B8000000BB0000000000000000
               ---- data omitted to end system INDEX record 4096 bytes ----
                      10        20        30        40        50        60
 r#       25 0123456789012345678901234567890123456789012345678901234567890123
        6144 @..X....inseql----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffff
             4005000066767622226666666666666666666666666666666666666666666666
             000800019E351CDDDD2222222222333333333344444444445555555555666666
          64 ffffgggggggggghhhhhhhhhx@..X....inseq2----bbbbbbbbbbccccccccccdd
             6666666666666666666666674005000066767322226666666666666666666666
             666677777777778888888888000800029E3512DDDD2222222222333333333344
         128 ddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhx
             666666666666666666666666666666666666666666666667
             444444445555555555666666666677777777778888888888

Relative file header records are 2048 bytes or larger. See file hdr size in 1st 4 bytes x'00000800' = 8 * 256 = 20148 bytes.

The record at 2048 begins with x'200000A'. x'20' identifies this as a system record which is always 4096 bytes & is bypassed.

The 1st data record begins at 2048 + 4096 = 6144 bytes & begins with x'40000058' The x'40' identifies a valid data record, Deleted records would be x'80'. x'000058' is the record length including an 8 byte record hdr (5*16)+(1*8) = 88.

Relative records have a binary record number in the next 4 bytes of the 8 byte hdr. x'00000001' - for 1st record, x'00000002' for 2nd, etc

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

5J8. file typ=STL

uvhd display - STLr Relative


 uvhd dat1/testSTLr x8    <-- option 'x8' for STL Relative records
 =====================
 rec#=1 rsize=88 fptr=6144 fsize=6320 rcount=71
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
        6144 @..X....inseql----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffff
             4005000066767622226666666666666666666666666666666666666666666666
             000800019E351CDDDD2222222222333333333344444444445555555555666666
          64 ffffgggggggggghhhhhhhhhx
             666666666666666666666667
             666677777777778888888888
 rec#=2 rsize=88 fptr=6232 fsize=6320 rcount=71
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
        6232 @..X....inseq2----bbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffff
             4005000066767322226666666666666666666666666666666666666666666666
             000800029E3512DDDD2222222222333333333344444444445555555555666666
          64 ffffgggggggggghhhhhhhhhx
             666666666666666666666667
             666677777777778888888888
 Each Relative record preceded by 8 bytes x'4000005800000001' for 1st record.
x'40000058'
  • the x'40' identifies an active data record (not deleted)
  • the x'000058' is the record length including the 8 byte prefix
x'00000001'
  • record number in binary (for 1st record)
  • you can see x'00000002' for 2nd record

By default uvhd bypasses deleted records, file header records & system records, But there are options to show these records as follows:

 uvhd dat1/testSTLr x8      option 'x8' - show only valid data records
                                          in STL Relative files

uvhd dat1/testSTLr x8y4 option 'y4' - also show Deleted records

uvhd dat1/testSTLr x8y1 option 'y1' - also show file header (2048 bytes)

uvhd dat1/testSTLr x8y2 option 'y2' - also show System records (4096 bytes)

uvhd dat1/testSTLr x8y7 option 'y7' - show All records

 uvhd dat1/testSTLr x8y4j4  option 'j4' - inhibit showing valid data records
                             - use 'j4' (with x8y4) to see only deleted records
                               in STL Relative files

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_6 uvhd - file investigation hexdump utility

Part 6 - Tips using uvhd


6A1. finding Record-Size in a fixed length file

6B1. using the NOT= (!) condition

6C1. Searching for information in binary files, for example:
- finding the Version of '/bin/ksh' (Korn shell executable program)
 6D1. When your problem is too complex for 'uvhd'
     - use 'uvcopy' which can do anything you can imagine.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

6A1. uvhd: Miscellaneous Tips

finding Record-Size in a fixed length file


 uvhd tf/test100    <-- test100 to demo finding correct recsize
 ===============      - recsize defaults to 256 when not spcfd on cmd line

WARNING: rcsz does not divide evenly into filesize

 filename=/home/uvadm/dat1/test100 options=
 records=15 rsize=256 fsize=4000 fsize%rsize(rmndr)=160
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 0001 tf/test100 one                   ..0002 tf/test100 two
             3333276276773332666222222222222222222200333327627677333277622222
             0001046F45341000FE50000000000000000000DA0002046F4534100047F00000
          64               ..0003 tf/test100 three                 ..0004 tf/
             2222222222222200333327627677333276766222222222222222220033332762
             00000000000000DA0003046F453410004825500000000000000000DA0004046F
         128 test100 four                  ..0005 tf/test100 five
             7677333266772222222222222222220033332762767733326676222222222222
             453410006F52000000000000000000DA0005046F453410006965000000000000
         192       ..0006 tf/test100 six                   ..0007 tf/test100
             2222220033332762767733327672222222222222222222003333276276773332
             000000DA0006046F453410003980000000000000000000DA0007046F45341000
 filesize NOT multiple of recsize, 160 bytes remain
 rec#=1 rsize=256 rcount=15 fsize=4000 fptr=0
 If Text file (with LineFeeds),  quit/restart with option 't'
 If Variable (IDXFORMAT3/8,RDW), quit/restart with optn v,or z
 If Fixed length records, change recsize now via command 'R' (R256 current)
 next evenly divisible record sizes lower/higher are --> R250/R400
 OR you may continue (ignoring these warnings) -->

finding record-size in fixed length files

  1. Display the 1st block of 256 bytes (default when option 'r' not spcfd)

  2. Use the 'R' command to test your perception of the correct record-size, based on repeating patterns (in 1st 256 bytes ?)

  1. If no repeating patterns in 1st 256, then recsize is probably > 256

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

6B1. uvhd: Miscellaneous Tips

using the NOT= (!) condition

The NOT EQUAL '!' condition can be quite useful. You could use it to verify field contents. For example if all records should have 'BC' in cols 78-79, you could use the following search to verify:

s 77(2),!'BC'
  • verify all records have 'BC' in cols 78-79
  • should reach EOF with nomatch (if match use ss for next)

Also note that when you use the <!> conditions, the field length must match the pattern length, if the pattern length is greater than 1. If the pattern length is 1 you can search any field length.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

6C1. uvhd tips & applications

Searching for information in binary files

Example
  • find the version of an executable program 'ksh' (Korn shell)

 #1. uvhd /bin/ksh   <-- initiate uvhd on the 'ksh' program
     =============
 filename=/bin/ksh options=
 records=4325 rsize=256 fsize=1107216 fsize%rsize(rmndr)=16
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 .ELF..............>......D@.....@.......P...........@.8...@.....
             74440000000000000030000014400000400000005D1000000000403000401010
             F5C621100000000020E0100004000000000000000D000000000000809000F0E0
          64 ........@.......@.@.....@.@.....................................
             00000000400000004040000040400000F0000000F00000000000000000000000
             6000500000000000000000000000000081000000810000008000000030004000
         128 8.......8.@.....8.@.............................................
             3000000030400000304000001000000010000000000000000000000000000000
             820000008200000082000000C0000000C0000000100000001000500000000000
         192 ..@.......@......~.......~........ .......................p.....
             0040000000400000D7100000D710000000200000000000000810000008700000
             00000000000000004E0000004E00000000000000100060000000000000000000
 rec#=1 rsize=256 rcount=4325 fsize=1107216 fptr=0
 Enter command, or ?=Help, or null=NextRecord --> s 'Version' <-- Search command

 #2. --> s 'Version'   <-- enter 's' Search command for 'Version'
     ===============
                      10        20        30        40        50        60
 r#     4233 0123456789012345678901234567890123456789012345678901234567890123
           0 `5..1.......1...................................................
             63CA300099CA3000000000000000000000000000000000000000000000000000
             053C10000BEC1000000000000000000000000000000000000000000000000000
          64 ................................................................
             1000FFFF00000000000000000000000000000000000000000000000000000000
             0000FFFF00000000000000000000000000000000000000000000000000000000
         128 X................................@(#)$Id: Version M 1993-12-28 r
             5000000000000000000000000000000004222246325677666242333323323327
             82000000000000000000000000000000A0839494A065239FE0D01993D12D2802
         192  $..............................@.J.............................
             220000000000000000000000000000004C400000000000000000000000000000
             040A000000000000000000000000000003A00000100000000000000000000000
 found--> s 'Version' <--at byte# 170 of record# 4233
 rec#=4233 rsize=256 rcount=4325 fsize=1107216 fptr=1083392
 Enter command, or ?=Help, or null=NextRecord -->
Note
  • You can see the result is 'version M 1993-12-28'

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

6D1. uvhd: When to use 'uvcopy' (vs uvhd)

uvcopy vs uvhd

  1. uvhd is very convenient since it is interactive & easy to learn with 26 help screens containing many examples.

  2. But when your problem is too complex for 'uvhd', use 'uvcopy' which can do anything you can imagine.

  3. uvcopy is the solution to any problem you can not solve with uvhd. uvcopy is an incredibly powerful utility that can do anything you might require re data manipulation in raw data files.

  4. Of course uvcopy is harder to learn, but there is lots of documentation and many examples. All of the instructions are documented in uvcopy3.htm. Please see HTML documentation on the website https://www.uvsoftware.ca or in the dochtml subdir on the distribution CD.

  5. Also note that uvcopy (or uvcp or uvsort) are more appropriate for batch jobs (repetitive work) because you can code them in scripts which might also execute COBOL programs or be scheduled by 'cron'.

    Things uvcopy can do that uvhd can not

  6. Record layout changes. uvhd is good for updating specified fields with new data, But uvcopy is much better for record layout changes when you want to move fields & change record size.

  7. Multi-File I/O. Uvcopy allows 8 input files & 40 output files.

  8. Indexed file access in key sequence.

  9. Creating Indexed files.

  10. Unpacking packed fields, converting Binary to Numeric, etc. As of Jan 2011, uvhd can also do this, because a 'move Numeric' command was added to uvhd.

  11. Special translates. uvhd can translate betwee EBCDIC/ASCII & UPPER/lower. uvcopy provides these & allows you to create your own translate tables from a supplied neutral translate table.

  12. uvcopy (or uvcp or uvsort) can be used in shell scripts.

  13. Sorting files, uvsort is the easiest to use, but uvcopy can also sort.

  14. Reporting & Accumulating. uvcopy & uvqrpg are much better ay this. The enumerate/count & accumulate commands of uvhd are limited to 1 field. Also note the 'tbl' feature of both uvcopy & uvqrpg which builds tables based on any specified argument (up to 48 bytes) with up to 6 accumulators & dumps the tables in sorted sequence at end of job. See TABLEjobs.htm.

    Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

    Visitor Counters for ThisYear and LastYear