UVdemos1 - Contents


Part_0 Introduction & Overview of UVdemos1
- Preliminary to UVdemos2 & all Vancouver Utilities
- Prospects may be given a userid/password to evaluate online
- These tutorials are great training for anybody less than a professional.
- We teach the fundamentals as well as the Vancouver Utilities
- files & directories, bits & bytes, ASCII coding, hexadecimal, etc
- unix/linux command line utilities (ls,cd,cat,more,head,vi/vim,etc)
- vi & vim editor command summary

Part_1 Login procedure to run demos, exercises, & tutorials
- preparation to run OnLine OR OffLine
- profile changes to run Demos or JCL conversions
- tree diagrams of demo directories & files
- Linux Command Summary

Part_2 Compiling & Executing C programs & Equivalent uvcopy jobs
- Educational programs for beginners
- should be fun learning to work with unix/linux tools on the command line
- random number generation for lottery numbers & Shakespearean insults
- programs to test limits for 16, 32,& 64 bit integers (19 decimal digits)
  ---------- Part 2 programs -----------
 lotto1.c - C program to generate Random Numbers
 uvlotto1 - uvcopy equivalent of lotto1.c program
 countcode1 - Count Lines of code in programming languages such as C & uvcopy jobs
 insult2.c - C program to generate Random Insults
 test64a.c - test 64 bit limits - start# 1 & multiply by 16
 test64b.c - like test64a, but accepts start# & multiplier
 testint1 - uvcopy equivalent of test64a.c
 test64c.c - converts any 1 decimal number to short, int,& long values
 hexcalc1 - convert numbers from decimal to binary or binary to decimal
  - displayed in hexadecimal
 datedemo1 - convert dates between Calendar, Julian,& days-since-1900
  - fun way to calculate your age in days or weekday you were born on
 lesson2.c - C program tutorial, great way to learn & understand C progamming
  - copies a file modifications controlled by options Mod0,1,2,3,4,5
 lesson3.c - an exercise for you - copy/rename & add Mod6 changes to
  calculate Record-Length & append on output lines as "RL=999"
 bugs1.c - tutorial for debugging C programs, 3 bugs for you to find & correct
  - crashes caused by divide by zero, unitialized pointer, buffer overflow
  - using 'gdb' to find crash reason with 'bt' (BackTrace) & set Breakpoints
 skeleton1.c - suggested starting point to write your own program to modify files
  - supplies I/O framework, insert your instructions where marked
 exercise1 - copy skeleton1.c to exercise1.c & modify to copy a file adding sequence#s
  - setup new working directory, make subdirs for src,bin,tf,tmp,sf,etc
 table1.bsh - script to generate random numbers & table summary counts

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

UVdemos1 Contents (continued)


Part_3 Game: quiz2c - Multiple-Choice quiz game written in the C programming language
- source code $HOME/demo/src/quiz2c.c compiled to executable $HOME/demo/bin/quiz2c
- Allows Multiple Quiz files, we provide over 50 as of March 2021 & will expand
- saves game result files in your current directory ./quiz1r/...
- records are date/time stamped with player names & score results,
- can compare results of competitions with friends & family.
- can download more quizfiles from the internet & reformat for quiz2c
  using the uvcopy scripts provided
- You could also makeup your own quizfiles in a simple textfile format
  & reformat with the scripts provided to the format expected by quiz2c
-----------------------------------------------------------------------
 Game: wordle - from: Github user "HUYTD" www.theregister.com/2022/02/02/bash_wordle
  - with some enhancements
- changed max_guess from 6 to 12 & allowing "Q" or "q" quit before max
- added arg1 "learn" to show the word at begining to assist learning wordle
- changed ASCII color codes to more meaningful symbols $GREEN, $YELLOW, etc

Part_4 More serious uvcopy jobs & tutorials to do real work at unix/linux sites
- converting delimited files to fixed-fields & reverse with 1 instruction
- using demo test-files of Canadian Provinces & US Congress members
- insert 1 or a few instructions into 'copy1' framework job for file I/O
- create table summaries of provinces & populations with 2 instructions
  or summarize US Congress members by party, house/senate, sex, etc

Part_5 uvfix1 - easy way to run uvcopy for whatever data manipulation is required
- solicits instructions interactively, no need to edit into a framework
- examples that are impossible or hard to do with editors
  such as creating scripts with fields in desired column locations
- uvfix1 automatically saves the created job in case you want to rerun
uvfixA - alternate job to process all files in a directory (vs 1 at a time)

Part_6 Pre-Programmed utility jobs for data search/replace beyond unix tools
- mass changes to all files in directories of programs, scripts,& documentation
- search/replace depending on multiple patterns present &/or not present
- table summaries based on keywords & offsets to target words
- these tools can save many hours of manual editing

Part_7 Demonstrates some of the many powerful features of uvcopy that might
provide solutions to various problems that come up at any computer site.
We illustrate uvcopy capabilities that go beyond Unix/Linux utilities.

Part_8 uvcopy DEBUGGER - activated with Run OPtion 'd'
- append on the command line, for example: uvcopy jobname,rop=d

8A1. Debug demo session#1 - using uvcopy fixUSstates1 & testfile USstates.csv
8B1.  Debug Command Summary (group1) - Display Data-Areas, Counters, Registers
 'd' (or 'p') to Display (or Print) Data Areas (a,b,c...x,y,z)
 'a' (or 'c') to display Accumulators (or Counters)
8C1.  Debug Command Summary (group2) - Breakpoints & Gotos
 Debug session#2 using extendsales1 to demo Registers (tables in memory)
 I/O files for extendsales1 uvcopy job (to demo debugging).
- productmaster (tabled), salesitems (input), salesextended (output)
8C6.   Debug session#3 to demo Breakpoints & Gotos
8C7.  debug session#4 - demo using only 'goto's without setting breakpoints
8C8.  debug session#4 - Why product# ERRORs cause description '~~~~~~~~~'
8D1.  Debug Command 'x' to Display Hexadecimal data

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

UVdemos1 Contents (continued)


Part_9 - Linux Applications & Vancouver Utilities

9A1. Useful Tools for Linux Administrators
9B1. vim - Vi IMproved, powerful editor for Linux, Unix,& Windows
9C1. .vimrc - Run Control file to customize vim behaviour
- highlighting, cursor position, yank buffers, tabstop, spell check
- listing of .vimrc used at UV Software
9D1.  create script to copy ".vimrc" to all homedirs & execute
 create script to chown .vimrc for each user & execute
 add exception words to vim's spellfile
- while editing with :set spell, ]s, & zg commands
- or with separate file of words to be added with script
 create a script (with uvfix1) to copy .vimrc to all user homedirs.
9E1.  create another script to set the permissions so users can update their .vimrc

9G1. multicol1 - list file of exception words multi-columns across
- general purpose utility for any file with short lines
9H1. repage1 - reformat paragraphs with no LineFeeds to specified line width
- example for documents or emails with long paragraphs enable print as text files
- demo splits pararaphs with long lines to lines with max 90 chars/line.

20A1. Links to other Vancouver Utilities Documentation
- UVdemos2 uvhd uvsort uvcp uvcopy uvtrain uvhelp etc

20B1. uvcopy Instruction summary
- over 100 instructions documented at uvsoftware.ca/uvcopy3.htm

Feedback Invited

Please let me know if you find any bugs, errors in the documentation, or instructions that are not clear & need more explanation. Please send email to owen@uvsoftware.ca

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

Part_0. Introduction to Linux & the Vancouver Utilities

0A1. UVdemos1 - Preliminary to UVdemos2

'UVdemos1' is an easy way to learn Unix/Linux command line tools, vi/vim editors, a little C programming,& become familiar with the Vancouver Utilities. UVdemos1 was inspired by my grandchildren. I wanted to allow them to login to my website & run Linux commands, learn the vi editor, the C compiler & runsimpler UV demos without having to download & install the Vancouver Utilities.

I have selected some tutorials & demos that should interest any unix/linux user:

 $HOME/demo holds a subset of Vancouver Utilities for easier demos.
 $HOME/demo/src - contains a few C programs you can compile & execute
 - helloworld.c lotto1.c insult2.c test64a.c test64b.c test64c.c quiz2c.c

We will introduce you to 'uvcopy' a Vancouver Utility program (written in C) that makes it easy to perform whatever data manipulations you might require much simpler than writing C programs. You can use any unix editor to pepare an instruction file to be interpreted by uvcopy (no compile required).

See over 100 powerful instructions at uvsoftware.ca/uvcopy3.htm. For example 'uvcopy uvlotto1' creates the same output as 'lotto1.c' with only 16 instructions (vs 49 for lotto1.c). The uvcopy instructions are much easier to learn & understand than C programming. You get the power of mainframe assembly without the complexity.

More importantly, uvcopy can do things that unix system utilities can not do, since it was developed to replace mainframe computer utilities. For example, uvcopy understands packed decimal fields, Indexed files, & column addressing which was heavily used by mainframe utilities, but almost non-existent on unix.

'right-click' on links to other documents

Be sure to 'right-click' when you want to follow HTML links to other documents (such as the uvsoftware.ca/uvcopy3.htm link to uvcopy instructions).

To avoid losing your place in this UVdemos1.doc, it is best to 'right-click' on the desired links & open in a 'new-tab'. This allows you to leave the other document open if desired & switch easily between multiple documents.

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

0A2. UVdemos1 - Introduction to the Vancouver Utilities

Free On-Line Test/Demo

On request, UV Software can provide a userid & password, so you can login & run the demos online - saving having to download, install, compile, setup directories, & profiles on your machine.

Your userid will be in the range of 'uvsoft01' to 'uvsoft99'. In this documentation we will refer to your userid as 'uvsoftxx' for OnLine logins or 'userxx' for OffLine users on their machines. Passwords will be 'passxx'. You will use 'ssh' (Secure SHell) for OnLine logins to the UV Software website & your usual login procedures if you have downloaded & installed Vanocuver Utilities on your machine.

Exercises & Tutorials

If you perform the step by step tutorials & compare your outputs to the expected outputs (usually listed following the executions), We think that you will soon understand these utilities & be able to use them for your own purposes.

Training for Newbies

These tutorials are a great training for anybody less than an experienced professional. We are teaching the fundamentals of data processing as well as the Vancouver Utilities.

This document tries not to assume a lot of unix knowledge, but see the following links for other tutorials & books on Unix/Linux Command Line Tools & the vi editor.

Internet Tutorials - CLI tools


 https://www.ubuntu.com/tutorials/command-line-for-beginners#1-overvie
 ========================================================================

 https://guru99.com/unix-linux-tutorial.html
 ============================================

And you can find a lot more online tutorials by googling with keywords such as: "Unix Linux command line utility tutorials".

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

0A3. UVdemos1 - Introduction to the Vancouver Utilities

Books - CLI Tools, shell scripts, vi/vim, C programming

Learning the Bash Shell - Cameron Needham - O'Reilly Press

The Linux Command Line - William Shotts

The C Programming Language - Kernighan & Ritchie

C Reference Manual
  • Harbison & Steele

Learning the vi editor - Arnolds & Lamb - O'Reilly press

Learning the vi & vim editor - Arnolds & Lamb - O'Reilly press

Graduate to UVdemos2

After completing the tutorials in UVdemos1, you can graduate to UVdemos2.htm. UVdemos2 was written assuming you had downloaded/installed the VU package on your machine & copied the demo subdir to your $HOME. But you could run the UVdemos2 tutorials using your ssh userid/password on the UV Software website.

Feedback Invited

Please let me know if you find any bugs, errors in the documentation, or instructions that are not clear & need more explanation. Please send email to owen@uvsoftware.ca

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

0A4. UVdemos1 - Introduction to the Vancouver Utilities

Useful Tools for IT Professionals

Have you sometimes wished you had an easier more powerful way to make mass changes in a file or in All files in a directory ?

If so, then see 'Part_5' uvfix1 & uvfixA to modify 1 or all files in a directory. 'uvfix1' & 'uvfixA' are interactive utilities that solicit your instructions & automatically write outputs to a temp directory for inspection & copy back if OK.

You can do complex data manipulation with only 1 instruction - such as converting delimited files to fixed fields or vice versa. You can apply more qualifiers to mass changes than your can with unix system utilities.

Your instructions & the uvcopy framework with I/O directory/file name are saved in case you later need to repeat or modify & repeat.

Useful Tools for Linux Administrators

Please see 'Part_9' for a good example of how useful the Vancouver Utilities can be to Linux System Administrators.

Page '9C1' lists a .vimrc file that greatly enhances the capabilities of 'vim' (highlight search words & cursor line, remember cursor position, spell check, etc).

Page '9D1' shows you how to use uvfix1 to create a script to copy .vimrc to all user homedirs. The script is generated automatically from 'ls /home >tmp/users' as input to 'uvfix1' that creates a 'cp $APPSADM/env/vimrc /home/userxx' for each user.

Page '9E1' shows you how to create another script to set the permissions so that the users can customize their .vimrc file if they so desire.

These tools save me a lot of time (vs creating scripts with editor only). I have 60 userids (because I setup a sperate login for each client). Many commercial Unix/Linux sites have hundreds of users.

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

Part_1. UVdemos1 - Introduction to the Vancouver Utilities

UVdemos1 - Part 1 - Contents


1A1. Preparation to Run UVdemos1 Demos & Tutorials
- run OnLine with userid/password form UV Software
- OR Offline if you have downloaded,installed,compiled on your machine

1A2. login & list the directories in your homedir/...
- appsadm, archive, demo, doc, testdata1, testlibs1, upload, uvadm
- you will change into demo/... to run the demos & tutorials

1A3. 'tree' utility to diagram directory & subdirs

1A4. Profiles, Environmental-Variables, Aliases
.bash_profile EXPORTs define locations of Libraries & Data
ALIASes cdc/cdd/cdl/cdm for easy change to directories (3 keystorkes)
Links to listings of bash_profile & common_profile in other documents.

1A5. ssh Guest Login to UV Software website to run UVdemos1
- without having to download & install Vancouver Utilities on your machine
 OR if you have downloaded & installed VU on your machine
- copy $UV/demo/* to your $HOME/demo/... & cdm ($HOME/demo) to run

1B1. Directories & Files relevant to UVdemos1

1C1. Recommended Command Line Working Procedures
- Working-Directory with files in sub-directories

1C2. tmp/... subdir in Working-Directory
- temporary & inter-step files in tmp subdirs
- keep your working directory clean

1C3. File Naming Conventions
- make filenames unique by appending 1,2,3,etc
- easy to find desired filenames searching with ls,find,grep,vi,etc

1D1. Printing UVdemos1.pdf Guide for Tutorials
- suggest using hardcopy guide for notes & screen free for commands
- can print the .pdf version with Windows word or Linux Libre Office

1D2. UVdemos1.doc can only be printed with uvlp13D
- 'uvlp13D' is a UV Software script that calls the uvlist.c program
  (printing with other tools would not respect page *ejects)
  UVdemos1.pdf is provided, so can print with Browsers & Windows tools

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

UVdemos1 - Part 1 Contents (continued)

 1E1. Linux Command Summary for Beginners
      - Online Guest Login to review Linux Commands
 1E2. Basic Linux Commands (cd,ls,cat,more,head,tail,etc
 1E3  Copy/Rename (cp/mv) practical example
      - copy/rename/modify existing program to create new program
 1E4. clear, date, echo, history, repeat command from history
      - compress/uncompress 'tar' & 'zip'
 1E5. find files, grep (search files for data contents)
      df (Display Free space), du (Disk Usage, sizes of files & directories)
 1E6. Networking, whois, host, dig, ping, ifconfig
      - find IP address for domain-name OR the reverse (dig -x)
 1E7. Compress & Uncompress with: tar, gzip, gunzip
      Exercise - create tar file, copy to 2nd directory & untar
 1E8. Compress & Uncompress with: zip & unzip
      Exercise - create zip file, copy to 2nd directory & unzip
 1E9. File Permissions, User & Group Management
      chmod,chown, useradd,usermod,userdel, groupadd,groupdel
 1E10. Disk Management (fdisk,mkfs,mount)
       Process Management (ps, kill, sleep, bg, fg)
 1E11. Package Management (apt install/uipdate/remove)
       System Administration (uname, free, top, shutdown, reboot)

1F1. Vi & Vim Editors - command summary
- Two modes of operation - Command & Insert
- cursor movement
1F2.  Insert, Add, Change, Delete, Copy, Move
- i, a/A, r/R, cw, o, x, dd, p,
1F3.  Search, Substitute, undo, join, read file
 /, n, s, g, u, J, :r
1F4.  Mark lines to copy, move, delete
m a-z (set Marks 'a' to 'z')
 'a,'b,etc (address marked lines for copy/move/delete)
1F5.  Registers a-z, Yank lines to Registers to Put elsewhere
 in same file or quit, read new file,& Put registers anywhere
1F6.  Write & Quit
 vi/vim references on Internet or Books

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

1A1. UVdemos1 - Introduction to the Vancouver Utilities

Run UVdemos1 OnLine - with userid/password from UV Software

No preparation is required if you are evaluating the Vancouver utilities with a userid/password assigned to your from UV Software.

Note that the documentation in UVdemos1 is written giving priority to the OnLine option (vs UVdemos2 which assumes that you have already downloaded, installed, compiled, & setup a user account/login on your machine).

But since we recommend all users should start their learning experience with UVdemos1, we have tried to write the UVdemos1 documentation for both OnLine and OffLine users.

Run UVdemos1 OffLine - Alternative to OnLine Login

Here is the Alternative to 'Running UVdemos1 OnLine', for users that have installed the Vancouver Utilities on their own machines.

As mentioned above, the priority in the UVdemos1 documentation was given to OnLine users evaluating the Utilities the easy way without having to first download, install, compile,& setup users on their own machines.

Whereas the UVdemos2 documentation was written assuming that users would do the download,install,compile,setups on their own machines.

If you have downloaded & installed Vancouver Utilities on your machine, there are some preparations required before you can run the demos

Pre-Requisites to Run UVdemos1 on your machine vs OnLine

  1. Download, Install,& compile the Vancouver Utilities. See the install summary at UVdemos2.htm#1A2 & complete documentation at install.htm

  2. If you wish to setup a new account on your machine to run Vancouver Utilities and the UVdemo, see UVdemos2.htm#1C1, which documents the command-line method of setting up a user account (& requires root permissions).

  3. If you already have a login on your machine, you can setup a 'demo' subdir in your homedir and copy the demo files from $UV/demo/* as documented at UVdemos2.htm#1C2.

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

1A2. Introduction to the Vancouver Utilities

Login to run UVdemos1 & Turorials


 #1. ssh uvsoftxx@uvsoftware.ca  <-- Online userid in range uvsoft00-uvsoft99
     ==========================
     --> passxx                  <-- enter your password at the prompt

 #2. ls -l    <-- List top-level directories in OnLine homedir
     =====
      -rw-rw-r--  1 uvsoftxx uvsoftxx 6900 Jun 15 10:20 .bash_profile
      -rw-rw-r--  1 uvsoftxx uvsoftxx 3149 Sep 11 15:50 1README_env_profiles
      -rw-rw-r--  1 uvsoftxx uvsoftxx 3399 Aug  5 17:22 1README_uvsoftware_demos
      -rw-rw-r--  1 uvsoftxx uvsoftxx 3696 Aug  5 17:15 1README_uvsoftware_download
                     ----- Directories Required for UVdemos -----
      drwxrwxr-x 12 uvsoftxx uvsoftxx 4096 Jun 15 16:58 appsadm
      drwxrwxr-x 30 uvsoftxx uvsoftxx 4096 Jun 15 00:32 demo/... <-- UVdemos files
      drwxrwxr-x  2 uvsoftxx uvsoftxx  305 Jun 15 16:55 upload
      drwxrwxr-x 28 uvsoftxx uvsoftxx 4096 Jun 14 19:54 uvadm
                     ----- additional for JCL conversions ------
      drwxrwxr-x 13 uvsoftxx uvsoftxx  247 Jun 14 19:59 testdata1
      drwxrwxr-x 31 uvsoftxx uvsoftxx 4096 Jun 14 19:55 testlibs1

Alternative Login Off-Line on your machine


 #1a. Login userxx   <-- Alternative Login on your own machine
      ============       if you have downloaded & installed Vancouver Utilities
     --> passxx      <-- enter your password at the prompt

 #2a. ls -l    <-- List top-level directories in your homedir (shown below)
      =====     - see Note2 below replacing 'ls -l' with alias 'l'
      -rw-rw-r--  1 userxx apps 6900 Jun 15 10:20 .bash_profile
      drwxrwxr-x 30 userxx apps 4096 Jun 15 00:32 ........   <-- your other subdirs
      drwxrwxr-x 30 userxx apps 4096 Jun 15 00:32 demo/...   <-- UVdemos files Note1
Note1
  • OffLine users need to copy demo/* files from $UV/demo/* to $HOME/demo/...
Note2
  • 'ls -l' unix command to List dirs/files with Long Option '-l'
  • will be replaced with just 'l' (alias l='ls -l') from now on

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

1A3. Investigate Demo Directories & Files Available

'tree' utility to diagram directory & subdirs

'tree' is great utility to display directory structures. 'tree' is open software created by Steve Baker (ice@mama.indstate.edu).


 #3. tree /home/userxx -L 1   <-- display "tree" diagram of dirs/files
     ======================     - Option "-L 1" for top level only
      /home/userxx
      |-- .bash_profile                <-- active profile (Hidden file)
      |-- 1README_env_profiles
      |-- 1README_uvsoftware_demos     <-- README files
      |-- 1README_uvsoftware_download
      |-- appsadm     <-- administration files
      |   |-- env     <-- subdir holding profiles
      |   |   |-- bash_profile_uv
      |   |   |-- bash_profile_web1
      |   |   |-- bash_profile_web2
      |   |   |-- common_profile_uv
      |   |   |-- common_profile_web1
      |   |   |-- common_profile_web2
      |   `
      |-- demo         <-- superdir for UVdemos (copied from uvadm/demo)
      |   |--          <-- see relevant subdirs further below (bin,dat1,pf,src,tf)
      |-- testlibs1    <-- Suoerdir for JCL conversion LIBrarieS (jcls,procs,parms,etc)
      |-- testdata1    <-- Superdir to Execute JCL scripts on test data files
      |-- cnvdata1     <-- Supedir for DATA file conversions EBCDIC to ASCII
      |-- tmp
      |-- upload       <-- zip files uploaded by UV Software for user downloads
      |   |-- 20200911_uvadm.zip
      |   |-- 20200911_appsadm.zip
      |   |-- 20200911_uvdemos.zip
      `-- uvadm        <-- Vancouver Utilities
Note
  • tree /home/userxx (without option "-L 1") would be 9000 lines long
  • we are showing ".bash_profile", a HIDDEN file, normally not shown
  • we have added a few relevant files from subdir env/... on the 2nd Level
  • "bash_profiles_uv,web1,web2" ONE of which has been copied to .bash_profile
  • "common_profiles_uv,web1,web2" ONE of which is called by .bash_profile
         ** Updating .bash_profile to run UVdemos1 (vs JCL Conversions) *8

You may need to update the '.bash_profile' in your login homedir to run the UVdemos (vs JCL Conversions that some other logins might desire).

UV Software should have set your login default to run the UVdemos (vs JCL conversions), but we document how to switch between demos & JCL conversions on the next page.

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

1A4. Profiles, Environmental-Variables, Aliases

The .bash_profile defines Environmental-Variables RUNLIBS/RUNDATA/CNVDATA/UVDEMOS for the common_profile to define PATHs to scripts, programs,& datafiles. The Variables are also used to define aliases to make it easy to change to the super directories for JCL conversions & for self-training on Linux command line tools.

.bash_profile EXPORTs define locations of Libraries & Data


 export RUNLIBS=$HOME/testlibs1 RUNDATA=$HOME/testdata1 CNVDATA=$HOME/cnvdata1
 #============================================================================
 # - Paths to Libraries & DataFiles for JCL test/demo conversions & executions
 # - see uvsoftware.ca/jclcnv1demo.htm#1B3 for serious migration projects

 export UVDEMOS=$HOME/demo QUIZFILES=$HOME/demo/quiz2f QF=$QUIZFILES
 ==================================================================
 # - Paths to Demos & Tutorials for self training on Linux Command Line Tools
 # - The $UV/demo/... directory can be copied to user's homedir for self-training
 #   on Command Line Tools, vi/vim, C programming, quizgames, uvcopy, etc
 # - $HOME/demo/... already setup for guest login users (no need to download/install VU)
 # - If you download/install Vancouver Utilities, copy $UV/demo/... to your homedir
 # --> cp -r $UV/demo to $HOME/demo <--

ALIASes for easy navigation

The following aliases are defined in the common_profile & in .bashrc for easy navigation - quick changes between the various directories which could have long path names

 alias cdc='cd $CNVDATA'     <-- cd to data conversion super directory
 alias cdd='cd $RUNDATA'     <-- cd to data testing/production super directory
 alias cdl='cd $RUNLIBS'     <-- cd to JCL/COBOL/scripts for mainframe migrations

 alias cdm='cd $HOME/demo'   <-- cd to test/demo directories for self-training
 =========================       on Linux Tools, C programming, games, uvcopy
                               - will use 'cdm' thruout this UVdemos documentation

The variables CNVDATA/RUNDATA/RUNLIBS/UVDEMOS are defined only once in the .bash_profile, then used to define the aliases, which are defined in both the common_profile & .bashrc '.bashrc' or '.bash_aliases' are best, since aliases are lost if you run a subshell.

Listings of .bash_profile & common_profile


 vi $HOME/.bash_profile  - copied/renamed from $APPSADM/env/bash_profile_uv
 ======================  - calls 1 of the following common_profiles

 vi $APPSADM/env/common_profile_uv    - for download/installs on user machines
 =================================
 vi $APPSADM/env/common_profile_web1  - for guest logins to UV Software website
 ===================================

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

1A5. Profiles, Environmental-Variables, Aliases

Login to UV Software website to run UVdemos1


 #1. ssh uvsoftxx@uvsoftware.ca  <-- Online userid in range uvsoft00-uvsoft99
     ==========================
     --> passxx                  <-- enter your password at the prompt

 #2.  cdm --> /home/uvsoftxx/demo (alias cdm='cd $HOME/demo)

Login if Vancouver Utilities downloaded/installed


 #1a. Login userxx   <-- Alternative Login on your own machine
      ============
      --> passxx      <-- enter your password at the prompt

 #2a. cdm  --> /home/userxx/demo, userxx is your login (john,mary,etc)

run the 'tree' utility to explore demo files


 #3. tree . | more  <-- list directory TREE diagram (for '.' current directory demo)
     =============

See relevant files for the test/demos/exercises in UVdemos1 listed on the next page.

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

1B1. UVdemos1 - Introduction to the Vancouver Utilities

subdirs/files in demo/... relevant to UVdemos1 (vs UVdemos2)

 /home/uvadm/demo
 |-- bin/                  <--- compiled C program binaries
 |   |-- bugs1*               - tutorial for debugging C programs
 |   |-- helloworld*          - see source code below under src/...
 |   |-- insult1*             - insults generated by random number selections
 |   |-- insult2*               from 3 columns of old English insult words
 |   |-- lesson2*             - program to help beginners learn C programming
 |   |                          copies a file with options to modify
 |   |-- lotto1*              - Lotto numbers from random number generation
 |   |-- quiz2c.c             - multi-choice quiz program, 51 quiz file choices
 |   |-- skeleton1.c          - copies a text file unchanged, use to create new programs
 |   |                          by copy/rename & insert your coded between read & write
 |   |-- test64a*
 |   |-- test64b*             - test limits of 64 bit integers
 |   `-- test64c*
 |-- dat0/                 <--- .csv files to be converted to fixed layouts
 |   |-- Provinces.csv      <-- to be converted to dat1/Provinces1 & Provinces2
 |   |-- UScongress.csv       - Congress members to demo table summary by party,sex,etc
 |   |-- USstates.csv         - US states, population, capital, capital pop
 |   |-- ...                  - several files not shown (not relevant to UVdemos1)
 |   `
 |-- dat1/                 <--- fixed-field text files converted from dat0/...csv files
 |   |-- CanadaMPs
 |   |-- CanadaProvinces
 |   |-- insults            <-- data file for insult2
 |   |-- nameadrs1            - Name & Address file
 |   |-- productmaster        - product descriptions & prices to extend salesitems
 |   |-- Provinces.csv        - to be converted to Provinces1 & Provinces2
 |   |-- Provinces1         <-- converted from Provinces.csv, all fields 20 bytes apart
 |   |-- Provinces2           - fields reformatted appropriate to content
 |   |-- salesitems           - see uvcopy jobs extendsales1,2,3
 |   |-- UScities             - used to insert capital city population into USstates
 |   |-- UScongress           - used to demo table summary by party, sex, etc
 |   |-- USstatepops          - state populations added to USstates1 & USstates2
 |   |-- USstates.csv         - to be converted to USstates1 & USstates2
 |   |-- USstates1            - state abrev, name, sate pop, capital, capital pop
 |   |-- USstates2            - same with sequence# 01-50
 |   |-- ...                  - several files not shown (not relevant to UVdemos1)
 |   `--
 |-- dat2/                 <--- test/demo data files from mainframes
 |   |--ar.sales.items        - showing just 2 examples
 |   |-- product_master       - sequential file, used to load Indexed file
 |   |-- product_masterI.dat  - Indexed file - DATA partition
 |   |-- product_masterI.idx  - Indexed file - INDEX partition
 |   |-- sales2
 |   |-- sales3               - sales detail files
 |   |-- sales_items
 |   `

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

1B2. UVdemos1 - Introduction to the Vancouver Utilities

               ** subdirs/files in $HOME/demo/... (continued) ***
 |-- dat3/                 <--- subdir/files to demo uvfix1 creating scripts
 |   |-- about.dat3.files     - more mainframe type data files
 |   |-- gl.account.trans     - demos removing trailing spaces & Carriage Returns
 |   |-- product.master1        from 80 byte records FTP'd from mainframe
 |   |-- uvfix.promo          - demo uvfix1 sequence# & drop multi-consecutive blank lines
 |   |-- warranty_master      - demo file with packed/binary fields
 |   `
 |-- dat9/                 <--- subdir/files created by YOUR tutorials (vs our demos)
 |   |-- provinces2         <-- created by pfxx/provincefix2 (user tutorial)
 |   |--                      - or by pfyy/provincefix2 (UV Software's solution)
 |   |-- provinces2a        <-- created by pfxx/provincefix2a (or pfyy/provincefix2a)
 |   |--                      - same as provinces2 with Total population
 |   |-- provinces2.tbl     <-- created by pfxx/provincefixtbl2 (or pfyy/provincetbl2)
 |-- ftps/                 <--- FTP scripts
 |   |-- ftpdemo1a
 |   |-- ftpdemo1b
 |   |-- ftpget1
 |   `-- ftpput1
 |-- parms/                <--- Parm files (used by JCL/scripts)
 |   |-- ftpdemo1
 |   |-- pap100s1
 |   |-- parm200s
 |   `--
 |-- pf/                   <--- uvcopy demo jobs (written by UV Software)
 |   |-- copy1                - skeleton (framework) for creating new uvcopy jobs
 |   |-- extendsales1         - extend dat1/salesitems with price, amount,& description
 |   |-- extendsales2           from dat1/productmaster (tabled in memory, lookup by product#)
 |   |-- extendsales3         - alternate version to get price & description from Indexed file
 |   |-- fixquote1            - convert backquotes to single quotes (test file tf/testfixquote1)
 |   |-- Provincefix1       <-- convert Provinces.csv to Provinces1 fixed 20 apart
 |   |-- Provincefix2       <-- convert Provinces.csv to Provinces2 reformatted
 |   |-- testint1           <-- uvcopy equivalent of C program test64a.c
 |   |-- USstatesfix1         - convert USstates.csv to fixed fields 20 bytes apart
 |   |-- USstatespop1         - add US state capital populations from UScities to USstates
 |   |-- uvlotto1           <-- uvcopy equivalent of C program lotto1.c
 |   `--
 |-- pfxx/                 <--- user written uvcopy job tutorials
 |   |-- copy1                - skeleton (framework) for creating new uvcopy jobs
 |   |-- .........          <-- students create uvcopy jobs by copy/rename/modify copy1
 |   |-- .........              (provincefix1,provincefix2,provincefix2a,provincetbl2)
 |   |-- .........            - may compare to pfyy/uvcopy jobs (by UV Software)
 |   |-- .........              (but don't look until you try)
 |   |--
 |-- pfyy/                 <--- answers to user tutorials
 |   |-- provincefix1         - compare your solutions to UV Software solutions
 |   |-- provincefix2         - minimal version pf/Provincefix2, created from copy1
 |   |-- provincefix2a        - same with total population line added
 |   |-- provincetbl2         - table summary of province counts & populations by Gov Party
 |   |-- UScongresstbl1       - table summaries of congress members by party, sex, etc
 |   |-- UScongresstbl2
 |   |-- UScongresstbl3
 |   `--

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

1B3. UVdemos1 - Introduction to the Vancouver Utilities

               ** subdirs/files in $HOME/demo/... (continued) ***
 |-- quiz2f/               <--- multi-choice quiz files
 |   |-- Animals01
 |   |-- Animals02
 |   |-- ... 47 files omitted - see all 51 on page '3C2'
 |   |-- WorldCapitals01
 |   |-- WorldWar201
 |   `
 |-- sf                    <--- Script Files (written by UV Software)
 |   |-- rename_dat3          - create scripts with column alignment
 |   `--
 |-- sfxx                  <--- Script Files - exercises for UVdemos1 Tutorials
 |   |--                      - students will create their scripts here
 |   |--                      - answers in sfyy (but don't look until you try)
 |   `--
 |-- sfyy                  <--- Script Files - answers to Tutorials
 |   |-- rename_dat3_neat1    - enhance messy scripts - BEFORE alignment
 |   |-- rename_dat3_neat2      enhance messy scripts - AFTER alignment
 |   `--
 |-- src/                  <--- C source programs
 |   |-- bugs1.c              - tutorial for debugging C programs
 |   |-- bugs1save.c          - original with bugs to restore & rerun debug tutorial
 |   |-- helloworld.c       <-- traditional C learner's 1st C program
 |   |-- insult1.c          <-- generate Shakespearean insults by random selection
 |   |                          from 3 columns insult words (hard-coded in program)
 |   |-- insult2.c            - same, using a data file that you can upate
 |   |--                        to create your new modern insults
 |   |-- lesson2.c            - program to help beginners learn C programming
 |   |-- quiz2c.c             - multi-choice quiz program, 51 quiz file choices
 |   |-- skeleton1.c          - copies a text file unchanged, use to create new programs
 |   |-- lotto1.c           <-- random number generator
 |   |-- test64a.c          <-- test 64 bit limits, multiply 1 by 16, repeat to limit
 |   |-- test64b.c            - same as test64a & accepts initial value & multiplier
 |   `-- test64c.c            - solicits 1 value & shows short,int,long conversions
 |   `--
 |-- tf/                   <--- Test Files (similar to dat1/...files)
 |   |-- ...                  - several files not shown (not relevant to UVdemos1)
 |   |-- insults_Owens      <-- alternate files of insults
 |   |-- insults_Shakespeare  - can copy/rename to dat1/insults
 |   |-- rep2d.tbl            - search/replace table for uvcopy rep2d
 |   |-- scan2d.tbl           - search table for uvcopy scan2d
 |   |-- test100              - 0001 one, 0002 two, etc to 0100 one hundred
 |   |-- test20               - similar to max 20 records
 |   |-- testexpandvars1      - test file for uvcopy expandvars1 (expand $VASRIABLEs)
 |   |-- UVdemos1_promo       - test file for uvfix1 (sequence# & reduce multi blank lines to 1)
 |   `--
 |-- tmp/                  <--- uvfix jobs preliminary output to tmp/...
 |   |--                      - for inspection before copy back to desired directory
 |-- tmp1/                    - tmp dirs keep demo/... working directory clean
 |-- tmp2/                    - suggest --> rm -f tmp*/* <-- before each session
Note
  • we are showing ONLY the directories RELEVANT to UVdemos1 (vs UVdemos2)
  • can run UVdemos1 online (with ssh & supplied userid/password)
  • could also run UVdemos2 with ssh online, but documented for offline

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

1C1. Recommended Command Line Working Procedures

Working-Directory - Best Practices

Here are a few demo subdirs/files to illustrate Working-Directory Best-Practices. (most of the demo subdirs/files were shown on pages '1B1' - '1B3')

 /home/userxx/demo/             <-- demo directory for your assigned userid/password
                                  - This is your "WORKING-DIRECTORY"
 |-- dat0/                      <-- data files (just 2 for illustration)
 |   |-- Provinces.csv
 |   `-- UScongress.csv
 |-- dat1/                      <-- data files (just 2 for illustration)
 |   |-- Provinces1
 |   `-- UScongress
 |-- pf/                        <-- uvcopy scripts
 |   |-- Provincefix1
 |   `-- USstatesfix1
 |-- tmp/                       <-- misc output files from various exercises
 |   |-- CanadaMPs_sorted_Prov
 |   |-- Provinces1             <-- output from uvfix1, inspect before copy to a
                                    permanent subdir (allows correction & rerun)
  1. A working-directory with all files in subdirs keeps your working sapce clean & well organized - your subdirs will probably fit on 1 screen, which makes it easy for you to review your project.

  2. You should stay in the working directory - do not change into the subdirs to investigate/edit your files.

  3. Don't waste time by changing into a subdir, looking at 1 file,& changing back out. Of course OK, if you intend to inspect/edit multiple files, but not for 1 or 2.

  4. Staying in your working-directory protects your files, even the infamous 'rm *' will do no harm when all files are in subdirs.

  5. Working-Directory with subdirs allows you to use the same filename for applications that process the same datafile thru multiple stages.

  6. Your working directory should have a temporary subdir. We call it 'tmp' Do not confuse with teh system '/tmp/...' ours is $HOME/demo/tmp/... Use your tmp/... dir for any tentative outputs, that you need to inspect before copying to a permanent subdir.

  7. Many utilities automatically write their output to the tmp/... directory & will make ./tmp/ if it does not exist.

  8. Garbage files (accidentally created) in the working-direcotry, rather then the intended subdir will stand out, so you will notice them, investigate the reason & correct the problem.

  9. Files created in the working directory can occur when there is a mistake in assigning a logical $VARIABLE filename to the physical subdir/filename. You would not notice if you were operating in the subdir with hundreds of files.

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

1C2. Recommended Command Line Working Procedures

tmp/ subdir in Working-Directory

A 'tmp/' subdir in in our working-directory has many uses & benefits. Do not confuse our ./tmp/ subdir in our working-directory with the unix system '/tmp/' at the top of the root file system.

  1. Several Vancouver Utility programs & scripts expect a tmp subdir and some will make it if not present.

  2. 'uvsort' expects a ./tmp/ subdir for merge files unless you define an alternate in the common_profile via 'export SORTDIR=...'

  3. 'uvhd' will make a tmp/ dir (if not present) to store an index for variable length & text files, so you can directly access any record by its record#. uvhd also uses the tmp/ dir for outputs from record write or print selections.

  4. Several Vancouver utility scripts output to the tmp/ subdir. For example 'alldiff2' runs the unix 'diff' command for all files in 2 directories, and writes the output to tmp/... using the 2nd directory-name.dif. Then you can use the editor to investigate the diff report (more flexible than cat/more).

  5. Redirecting large outputs of unix utilities such as 'grep' & then investigating with 'vi' is much more flexible than piping to more or less.

  6. You can use the tmp/ dir for cut & paste between files - edit the 1st file, write out the desired lines to tmp/xxx. Then edit the 2nd file & read the tmp/xxx file into the desired location.

  7. You can use the tmp/... directory like the unix system '|' command that pipes the output of 1 command directly into a 2nd command, when you want to inspect or modify the 1st output before inputting to the 2nd command.

  8. Using a tmp/ subdir for any misc file outputs keeps your working-directory clean & well organized - no garbage file clutter, your subdirs can probably fit on 1 screen.

  9. Any files showing up on your working-directory list will signal an error to be investigated & removed. For example an incorrect variable assignment (export LOGICALNAME=subdir/filename) will cause a program to write the file into the working-directory rather than the intended subdir.

  10. We suggest your clean out your tmp/* dir frequently (at least daily) so you can easily see your current tmp/files vs yesterdays.

  11. These concepts protect your files, even the infamous 'rm *' will do no harm - because you stay in the working directory which has no files.

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

1C3. Recommended Command Line Working Procedures

File Naming Conventions

It is a good idea to append a digit (1,2,3,etc) on the end of filenames. For example: customer1, sales1,etc for data files, Scripts & program files might be named provincefix1,provincefix2,extendsales1,extendsales2,etc.

  1. This makes your file names 'unique' & avoids confusion with other similar names. Better to name your data directory 'data1' to distinguish from common word 'data' which could be part of a filename or often used within a script or program.

  2. You can reliably use 'grep' & 'find' to search for all instances of a filename in any or all of your directories.

  3. You can use 'vi/vim' search command '/' to find all instances of a file or program name when editing your scripts & programs.

  4. It makes it easy to create names for related files. 'customer2' or 'sales2' would be a logical name for a new version of the file. Or you might use 'customer1a', 'sales1a', etc.

  5. Misspell filenames intentionally to make them unique. For example we call our temporary files 'tmp' (& tmp1, tmp2,etc).

  6. Use common prefixes to identify related files. For example we call our Vancouver Utility programs uvcopy,uvsort,uvlist,uvqrpg,uvhd,etc.

    Commenting scripts & programs

When you write a new script or program, you should include comments. You will thank yourself 6 months later when you try to understand your script/program. Here is an example of "opening comments" common to all scripts & programs:

 # Provincefix1 - convert Canadian Provinces file from .csv to fixed fields 20 bytes apart
 #              - uvcopy job stored in $UV/pf/demo/... & in $UV/demo/pf/...
 #              - by Owen Townsend, UV Software, July 2020
 #
 # uvcopy Provincefix1,fili1=dat0/Provinces.csv,filo1=dat1/Provinces1
 # ==================================================================
 #
 #                    ** sample 1st 3 records Input & Output **
 #
 # ABR,Province,Capital,Premier,Government,Population
 # AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
 #
 # ABR                 Province            Capital             Premier             Government          Population
 # AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000

Initial items recommended

  1. First few lines should include the 'FILENAME' of the script/program, a description of "what it does", where script/program stored, author,& date written

  2. Document the operating instruction command line & I/O filenames

  3. Show 2 or 3 lines of I/O data file records

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

1D1. Preparation to Run UVdemos1 Demos & Tutorials

Printing UVdemos1.pdf Guide for Tutorials

We recommend printing UVdemos1.pdf as a guide when you are executing the various demo tutorials. You can highlight the commands to be run & make notes for any errors & unclear explanations you find in the documentation that you could send to UV Software.

Of course if you have 2 terminals or a big screen with 2 big windows, you could have www.uvsoftware.ca/uvdemos1.htm on 1 window & run the demos on a 2nd window.

It is good to have a screen/window for the documentation on the wedbsite to follow the many links to other parts of UVdemos1 & other documents such as the uvcopy instruction documentation at www.uvsoftware.ca/uvcopy3.htm And also good to have the hard-copy for making notes & highlights.

You can download UVdemos1.pdf from the UV Software public website as follows:


 #1. open your internet browser on Linux or Windows
     ==============================================

 #2. control-T (open a new tab) & enter www.uvsoftware.ca/uvdemos1.pdf
     =================================================================

 #3. control-S to Save wherever you wish (could be your Downloads directory)
     =======================================================================

 #4. open your file browser (linux or Windows) & browse to Downloads/...
     ===================================================================

 #5. double click to open Downloads/UVdemos1.pdf
     ===========================================

 #6. control-P to Print to your system printer (about 80 pages Duplex)
     =================================================================

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

1D2. Printing UVdemos1.pdf Guide for Tutorials

printing UVdemos1.doc with 'uvlp13D'

If you have Vancouver Utilities installed on your machine, you can print as follows:


 uvlp13D /home/uvadm/doc/UVdemos1.doc
 ====================================

Cannot print the .doc version without VU on your machine

You can not print UVdemos1.doc unless you have the Vancouver Utilities on your machine, because only the 'uvlist' program recognize the '*eject' controls in UV Software's .doc files for page boundaries, etc. UV Software's .htm files are actually text files & are best printed with 'uvlist' or 1 of the many 'uvlp...' scripts that call uvlist to insert PCL5 printer controls for margins cpi, lpi, type size, Simplex/Duplex, Portrait/Landsacpe, page restart, etc.

 UV Software writes documentation as text files with extension .htm, converts
 them to HTML with a uvcopy job,& uploads to the UV Software public website.
 This documentation was written as UVdemos1.doc & uploaded as uvdemos1.htm
 - not UVdemos1.htm since our convention is all lower-case for HTML filenames.

UVdemos1.doc was also converted to 'UVdemos1.pdf' & uploaded to the public website, so you can download it with your internet browser & print it with Microsoft-Word on Windows or Libre-Office on Linux or any other software that recognizes .pdfs

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

1E1. Linux Command Summary for Beginners

Here is a review of the Linux commands you need to know to perform UVdemos1. If you have 1 of UV Software's guest logins uvsoft01-uvsoft99, you can login, and change to the demo/ directory to run various Linux commands.

For basic Linux commands, we will show a sample of the command that you can run, using some of the test data files available in the demo/ directory of your homedir. See the filenames available listed on pages '1B1' - '1B3'.

Online Guest Login to review Linux Commands


 #1. ssh uvsoftxx@uvsoftware.ca  <-- Online userid in range uvsoft00-uvsoft99
     ==========================
     --> passwordxxx             <-- enter your password at the prompt

 #1a. Login userxx     <-- Alternative Login for your own Linux machine
      ============         if you have downloaded & installed Vancouver Utilities
     --> passwordxxx   <-- enter your password at the prompt

 #2. cd demo    <-- change to the demo/ directory for command exercises
     =======      - or use alias 'cdm' for either online of offline

 #2a. cdm  --> /home/uvsoftxx/demo (alias cdm='cd $HOME/demo)

 #2b. cdm  --> /home/userxx/demo OR 'userxx' if OffLine account

Several sample commands will use demo file $HOME/demo/tf/test100 or test20.

$HOME/demo/tf/test100

     0001 one
     0002 two
     0003 three
      ----- omitting 94 records -----
     0098 ninety eight
     0099 ninety nine
     0100 one hundred
            ** $HOME/demo/tf/test20 **
     0001 one
     0002 two
     0003 three
      ----- omitting 14 records -----
     0018 eightteen
     0019 nineteen
     0020 twenty

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

1E2. Linux Command Summary for Beginners

Basic Linux Commands

We assume you have logged in & your homedir $HOME/demo/... includes the test/demo files that can be seen at uvsoftware.ca/uvdemos1.htm#1B1 - 1B3.


 cd                  <-- change to your homedir, example: /home/uvsoft99
 ===
 cd demo             <-- change to subdir demo, example: /home/uvsoft99/demo
 =======             <-- the following commands & observe outputs

 pwd                 <-- Print Working Directory
 ===                   - sample output --> /home/uvsoftxx/demo

 ls                  <-- list all files & subdirs in the current directory $HOME/demo
 ===                   - lists multiple names per line (about 35 subdirs on 2 or 3 lines)
 ls -l               <-- option '-l' Long listing includes permissions, owner, group, size, date
 =====                 - should see about 35 lines (1 subdir per line)
 l                   <-- alias for 'ls -l' (saving keystrokes for this most used command)
 ===
 l src               <-- list all files in src (source code) directory $HOME/demo/src/...
 =====
 l tf                <-- list files in subdir tf/... $HOME/demo/tf/...
 ====

 cat tf/test100      <-- display contents of tf/test100, will see only last 50 lines,
 ==============        - 1st 50 lines roll off screen, if your screen is 50 lines max
 more tf/test100     <-- use 'more' when records > screen max lines
 ===============       - stops when screen full, press space bar to show next screen
                       - press enter to advance 1 line at a time
 less tf/test100     <-- use 'less' vs'more', for better navigation, arrow keys up or down
 ===============       - may search for patterns /pattern & other commands (see man page)

 cat tf/test20       <-- use 'cat' when you know file contents less than max screen lines
 =============

 cat tf/*            <-- could display all files in tf/... (1600+ lines)
 ========              - would see only last 50 lines
 more tf/*           <-- use 'more' to stop on screen full & enter ':n' for Next file
 =========

 head -10 tf/test100 <-- display 1st 10 lines of tf/test100
 ===================
 head tf/test100     <-- same, since '-10' is the default number of lines to display
 ===============
 head -10 tf/test100 >tmp1/test10  <-- redirect output to a file (vs the screen)
 ================================

 cat tf/test20 tmp1/test10 >tmp1/test30  <-- use 'cat' to combine multiple files into 1 file
 ======================================
 cat tmp1/test30                         <-- display results of command above
 ===============

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

1E3. Linux Command Summary for Beginners

copy & rename - practical example

Here is a practical example using 'cp' & 'mv' (rename). To create a new program, programmers often copy an existing program, renaming & modifying to insert new code, & delete unwanted code. Try the following 'cp' & 'mv' commands. You could also run the compile & execute, but there are many more compile & executes on page '2A1' onwards.


 l src               <-- list files in the src (source code) directory
 =====

 cp src/skeleton1.c src/myprogram.c  <-- copy skeleton1.c renaming appropriately
 ==================================

 vi src/myprogram.c  <-- would then modify program as you desire for new project
 ==================    - BUT, skip this for now, if learning basic Linux commands

 gcc src/myprogram.c -o bin/myprogram  <-- compile source program to executable/binary
 ====================================      from subdir src/... to subdir bin/...

 bin/myprogram       <-- could execute, would be same as skeleton1, which copied a file
 =============         - suggest tf/test100 to tmp/test100

 mkdir mysrc         <-- you could setup your own source directory
 ===========

 mv src/myprogram.c mysrc/ <-- AND, MOVE your program to your new source directory
 =========================

 mv src/myprogram.c src/myprogram1.c  <-- you might later want to rename your program
 ===================================    - using 'mv' as a RENAME in this case

 cp src/myprogram.c src/myprogram1.c  <-- Alternative to 1st copy program to new-name
 ===================================
 rm src/myprogram.c                   <-- then delete the old-name
 ==================

 rm -rf mysrc        <-- might later want to remove your directory & all files within
 ============          - option '-r' Recursive delete files within all subdirs
                       - option 'f' Force even if alias rm='rm -i' would prompt y/n

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

1E4. Linux Command Summary for Beginners

Basic Linux Commands (continued)


 clear               <-- clear the terminal
 =====

 date                <-- display the current system date and time
 ====

 echo $HOME          <-- display value of environmental variable 'HOME'
 ==========            --> HOME=/home/uvsoft99 <-- if you are logged in as 'uvsoft'
 echo $LOGNAME       <-- display your user-name
 =============
 echo $HOSTNAME      <-- display HOST server computer name
 ==============
 echo $HISTSIZE      <-- display your history (previous commands)
 ==============        - default 1000, change by export HISTSIZE=... in profile

 history             <-- print a history list of all commands
 =======               - 1000 lines (default)
 history 40          <-- show only last 40 commands
 ==========
 h                   <-- alias history='h' in UV Software profiles
 ===                   - faster way to show recent comands
 h 20                <-- can repeat recent long commands using --> !999 <--
 ====                  - example: show last 20 & repeat command by number
                       - showing only last 4 below
   523  date
   524  echo $LOGNAME
   525  echo $HOSTNAME  <-- see repeat below using '!' & history command number
   526  echo $HISTSIZE

 !525                <-- repeat 'echo $HOSTNAME' using '!' & history command number
 ====

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

1E5. Linux Command Summary for Beginners

Basic Linux Commands (continued)


 cd $HOME/demo           <-- ensure you are in the demo directory
 =============
 pwd                     <-- confirm --> /home/uvsoftxx/demo
 ===

 find -name sales*       <-- list all filenames that start with "sales"
 =================           found anywhere in the current directory & any subdirs

 find dat2 -name sales*  <-- can restrict search to 1 directory & it subdirs
 ======================

 find dat* -name sales*  <-- or search all directories that start with "dat"
 ======================

 grep 'Owen' dat1/*      <-- list all records containing "Owen"
 ==================          in any file found within subdir dat1/...

 grep 'Owen .* Vancouver' dat*/*   <-- list all records containing "Owen" & "Vancouver"
 ===============================       from any file found in subdirs starting with "dat"...
                                      - allowing any characters between "Owen" & "Vancouver"

 df -h               <-- display free space of mounted file system
 =====

 du -hs              <-- display the size of your current directory
 ======

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

1E6. Linux Command Summary for Beginners

Networking Commands


 whois domainname        <-- display information about any domain
 ================
 whois uvsoftware.ca     <-- try this, creates 70+ lines, some roll off screen
 ===================
 whois uvsoftware.ca | more  <-- pipe to more to stop on screenfull
 ==========================    - press spacebar for next screen

 whois uvsoftware.ca >tmp/whois_uvsw  <-- Alternative, redirect to a tmp/file
 ===================================    - then display with more or vi
 more tmp/whois_uvsw   <-- saving the file allows later review/extract
 ===================

 host domainname         <-- lookup domain to see IP#
 ===============
 host uvsoftware.ca      <-- try this to see IP# of UV Software & its host
 ==================        - creates following 3 line report
 uvsoftware.ca has address 207.244.116.232
 uvsoftware.ca mail is handled by 10 mx1.us.opalstack.com.
 uvsoftware.ca mail is handled by 10 mx2.us.opalstack.com.

 dig domainname          <-- display DNS information of any domain
 ==============
 dig opalstack.com       <-- try this to see IP# of opalstack.com
 =================

 dig -x IP-Address       <-- reverse lookup by IP# to get domain-name
 =================
 dig -x 207.244.116.232  <-- try this
 ======================

 ping domainname or IP#  <-- check connectivity to another computer/device
 ======================
 ping uvsoftware.ca      <-- test connection to UV Software's host/ISP
 ==================        - alias ping='ping -c3' stops after 3 pings
                           - output shown below
 64 bytes from opal10.opalstack.com (207.244.116.232): icmp_seq=1 ttl=54 time=75.1 ms
 64 bytes from opal10.opalstack.com (207.244.116.232): icmp_seq=2 ttl=54 time=74.9 ms
 64 bytes from opal10.opalstack.com (207.244.116.232): icmp_seq=3 ttl=54 time=75.2 ms
 --- uvsoftware.ca ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2003ms

 ifconfig                <-- list all IP addresses of network interface
 ========                  - probably see only the IP# of your modem

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

1E7. Linux Command Summary for Beginners

compress/uncompress with 'tar'


 tar -cvf filename.tar filename <-- tar/compress a file in the Tar archive
 ==============================   - option '-c' to Create tar archive
 tar -xvf filename.tar    <-- uncompress a Tar file
 =====================      - option '-x' to eXtract files from tar archive
 tar -tvf filename.tar    <-- list the content of the Tar file
 =====================      - option '-t' to show filenames in tar file

You can run the following commands if in $HOME/demo/


 #0. rm -f tmp*/*           <-- remove all files from tmp/* tmp1/* tmp2/*
     ============
 #1. cd dat1                <-- change into directory to compress all files
     =======
 #2. tar -cvf dat1.tar *    <-- Create tar archive with all files in dat1/...
     ===================        current directory
 #3. cd ..                  <-- change out of dat1 (back up to $HOME/demo/)

 #4. mkdir tmp1             <-- make tmp1 subdir to extract tar files
 #5. rm -f tmp1/*             - OR remove files if tmp1/ already exists
     ===========
 #6. mv dat1/dat1.tar tmp1  <-- move the dat1.tar file to tmp1/...
     =====================
 #7. cd tmp1                <-- change into tmp1 to uncompress files
     ========
 #8. tar -xvf dat1.tar *    <-- eXtract all files from dat1.tar
     ====================       into the current directory tmp1/...
 #9. l                      <-- list resulting files in tmp1/...
     ===

The main benefit of 'tar' is that it allows you to compress an entire directory tree into 1 file that can be easily backed up &/or moved to another directory or machine for uncompression back to the original directory tree.

'tar' with options '-cvf' compresses only about 20%, add option 'z' to get about 80% compression. Add option 'z' to the above #2 & #3 as follows:


 #2. tar -cvzf dat1.tar *    <-- Create tar archive with option 'z'
     ====================        for 80% compression (vs 20%)

 #8. tar -xvzf dat1.tar *    <-- eXtract from archive created with option 'z'
     =====================

If you had not used option 'z' to create the archive, you could use 'gzip' & 'gunzip' to do the compression & uncompression. gzip/gunzip work on the input file, so the original input file will disappear.


 #2. gzip dat1.tar        <-- compress any file, adds extension '.gz'
     =============          - creates dat1.tar.gz

 #8. gunzip dat1.tar.gz   <-- uncompress any file, removes extension '.gz'
     ==================     - creates dat1.tar

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

1E8. Linux Command Summary for Beginners

compress/uncompress with 'zip'


 zip filename.zip filename <-- compress a single file to a zip
 =========================
 unzip filename.zip        <-- unzip a file
 ==================
 unzip -l filename.zip     <-- display the content of zip archive file
 =====================

You can run the following commands if in $HOME/demo/


 #0. cd $HOME/demo          <-- change to $HOME/demo
     =============            - prior exercise left you in tmp1
 #1. cd dat2                <-- change into directory to compress with zip
     =======
 #2. zip -r dat2.zip *      <-- compress all files to a zip archive
     =================        - option '-r' to create zip archive
 #3. cd ..                  <-- change out of dat2 (back up to $HOME/demo/)

 #4. rm -f tmp2/*           <-- remove files from tmp2/...
     ============
 #5. mv dat2/dat2.tar tmp2  <-- move the dat2.tar file to tmp2/...
     =====================
 #6. cd tmp2                <-- change into tmp2/... to uncompress
     =======
 #7. unzip dat2.zip         <-- uncompress all files with unzip
     ==============             into the current directory tmp2/...
 #8. l                      <-- list resulting files in tmp2/...
     ===

In the past zip (rather than tar) was used to transfer archives to Windows, but Windows 10 does not natively support tar, gzip, gunzip.

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

1E9. Linux Command Summary for Beginners

File Permission Commands


 ls -l filename      <-- check the current permission of any file
 ==============

 chmod 777 filename  <-- assign full(read, write, and execute) permission to everyone
 ==================

 chmod -R 777 dirname <-- assign full permission to the directory and all sub-directories
 ====================

 chmod 766 filename  <-- assign full permission to the owner, and read and write permission to group and others
 ==================

 chmod -x filename   <-- remove the execution permission of any file
 =================

 chown username filename <-- change the ownership of a file
 =======================

 chown user:group filename <-- change the owner and group ownership of a file
 =========================

 chown -R user:group dirname <-- change owner & group of the directory & all sub-dirs
 ===========================
Note
  • you need to use 'sudo' to run chmod/chown commands if you are not the owner of the files
  • your username must be in the /etc/sudoers file
  • you will be prompted for your password (vs root password)

User and Group Management Commands

Note
  • you need to use 'sudo' to run user & group commands

 sudo useradd username    <-- add a new user account
 =====================

 sudo userdel -r username <-- delete a user account
 ========================

 sudo usermod [option] username <-- change the user account information including, group, home directory, shell, expire date
 ==============================

 sudo usermod -aG groupname username <-- add a user to a specific group
 ===================================

 sudo groupadd groupname  <-- create a new group
 =======================

 sudo groupdel groupname  <-- remove a group
 =======================

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

1E10. Linux Command Summary for Beginners

Disk Management Commands


 sudo fdisk -l            <-- list all disk partitions
 =============              - need 'sudo' to run fdisk, mkfs,& mount

 sudo fdisk /dev/sda      <-- create a new partition on /dev/sda device
 ===================

 sudo mkfs.ext4 /dev/sda1 <-- format the partition named /dev/sda1
 ========================

 sudo fsck.ext4 /dev/sda1 <-- check and repair a filesystem for any error
 ========================

 sudo mount /dev/sda1 /mnt <-- mount any partition to any directory
 =========================

 df -h               <-- display free space of mounted file system
 =====
 du -hs              <-- display the size of your current directory
 ======

Process Management Commands


 ps                  <-- display all active processes
 ===                   - will see only 'bash' & 'ps'

 ps -ef | grep processname <-- Display information of specific process
 =========================
 ps -ef | grep bash  <-- Try this, will see all bash shells for all users
 ==================    - due to option -e

 top                 <-- manage and display all processes in realtime
 ===

 kill -9 pid         <-- kill a specific process using process ID
 ===========           - need sudo if you do not own the process

 pidof processname   <-- Get the PID of any process
 =================
 pidof bash          <-- Try this, will see pids of all user bash's
 ==========

 sleep 10 &          <-- sleep 10 seconds '&' runs in background
 ==========            - without '&' your terminal would be tied up for 10 seconds
 bg                  <-- display jobs running in the background
 ===
 [1] 10794           <-- sample display (10794 is pid# of sleep in background)

 fg                  <-- bring background jobs into the forground
 ===
 slep 10             <-- will see 'sleep 10' & prompt returns when 10 seconds up

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

1E11. Linux Command Summary for Beginners

Package Management Command

Note
  • you will need to use 'sudo' to run the following commands
  • and your username must be in the /etc/sudoers file
  • you will be prompted for your password (vs root password)

 sudo apt install packagename <-- install the package on Debian based distributions
 ============================   - UBUNTU is Debian based

 sudo apt remove packagename <-- remove a package on Debian based distributions
 ===========================

 sudo dpkg -l | grep -i installed <-- get a list of all packages on Debian based distributions
 ================================

 sudo dpkg -i packagename.deb     <-- install .deb package
 ============================

 sudo apt update      <-- update the repository on Debian based distributions
 ===============        - follow with 'upgrade' to install the updates

 sudo apt upgrade     <-- upgrade (install updates) for the updated repository
 ================

 sudo apt autoremove  <-- remove all unwanted packages on Debian based distributions
 ===================

SysAdmin commands


 hostnamectl         <-- get system information including, operating system, kernel, and release version.
 ===========

 uname -a            <-- show All info for unix kernel
 ========              - sample display as follows:
 Linux uvsoft5 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

 free                <-- displays free and used memory in the system
 ====                  - sample display as follows:
            total        used        free      shared  buff/cache   available
 Mem:    16351396     1497516    12578584      103536     2275296    14329828
 Swap:   31250428           0    31250428

 top                 <-- display all running processes
 ===

 shutdown -h now     <-- shut down the system
 ===============

 reboot              <-- restart the system
 ======

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

1F1. vi & vim Editors

'vim' is an enhanced version of 'vi', used on most Linux systems. On Linux 'vi' is usually an alias to 'vim'. Use '\vi' if you really want the old 'vi'.

Here is a 'vi/vim' command summary, the minimum essentials you should know. See page '1F6' for links to vi/vim tutorials & vi/vim books.

TWO modes of operation - COMMAND or INSERT

  1. COMMAND mode - cursor movement, read/write files, etc

  2. INSERT mode - enter 1 of 'i,a,A,R,o,cw' to begin insert mode - enter text (insert or replace) - hit ESCAPE to end insert mode & return to command mode

It is most important to understand that vi has TWO modes of operation. Switch to INSERT mode using commands such as the following:

i=insert, a=append, R=replace, o=open new line, cw=change word.

Switch back to command mode using 'ESCAPE'. Make it a habit to hit ESCAPE as soon as you finish text entry. If in doubt (COMMAND or INSERT mode) - hit ESCAPE, it will do no harm if already in command mode (will beep).

starting 'vi' to edit a file


 vi filename   <-- starts vi, reads the file,& displays 1st screen
 ===========       (or blank screen if creating a new file)

CURSOR MOVEMENT

                  k                       up-arrow
                  |                          |
            h <-- . --> l     left-arrow <-- . --> right-arrow
                  |                          |
                  j                     down-arrow
 ^d   - down 1/2 screen
 ^u   -  up  1/2 screen
Note
  • I use '^' to represent the 'control key'
 :1   - goto line# 1
 :500 - goto line# 500
 G    - goto end-of-file
 0    - move cursor to begining of current line
 $    - move cursor to end of current line

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

1F2. vi & vim Editors

INSERT text (ESCAPE to end insert)

i
  • enter insert mode at cursor location
a
  • append text after cursor location
A
  • append text onto the end of the current line
r
  • replace 1 character under the cursor
  • automatically returns to command mode (no need to ESCAPE)
R
  • replace (overwrite) text until ESCAPE
cw
  • change word (from cursor to end of word)
  • ESCAPE to end change & adjust line to new word length
o
  • open (insert) a new line BELOW the cursor
O
  • open (insert) a new line ABOVE the cursor

DELETE commands

x
  • delete character (under cursor)
dd
  • delete current line
D
  • delete from the cursor to end of line

5dd - delete 5 lines (current & next 4 lines below cursor)

COPY lines (YANK & PUT)

yy
  • yank current line (into current buffer)
  • move cursor to line above intended insert point
p
  • put (insert) buffer to line below cursor
 5yy - yank 5 lines into current buffer
     - move cursor to line above intended insert point
 p   - put (insert) buffer (5 lines) below cursor

MOVE lines (DELETE & PUT)

dd
  • delete current line (& store in current buffer)
  • move cursor to line above intended insert point
p
  • put (insert) buffer to line below cursor
 5dd - delete 5 lines (& store in current buffer)
     - move cursor to line above intended insert point
 p   - put (insert) buffer (5 lines) below cursor

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

1F3. vi & vim Editors

search commands

 /xxx - search for xxx anywhere in the file
      - search will wrap around EOF back to cursor location
n
  • repeat previous search (next)

substitution commands

 :1,$ s/xxx/yyy    - substitute 'xxx' with 'yyy'
                   - from 1st line to last line (1,$)
 :%s/xxx/yyy       - substitute 'xxx' with 'yyy'
                   - on ALL lines, '%' same as '1,$'
 :%s/xxx/yyy/g     - substitute 'xxx' with 'yyy'
                   - ALL lines ('%') & ALL occurrences on each line (/g)

Global command - to delete, print, etc

 :g/xxx/d          - on ALL lines (g=global), Delete lines with 'xxx'
 :g/xxx/p          - on ALL lines (g=global), Print lines with 'xxx'

miscellaneous commands

u
  • undo the last change command
U
  • Undo all changes to the current line (since cursor move to it)
 .  - repeat the previous change command
J
  • Join line below cursor onto current line
 :r file2 - read a file into the workspace
            (following the line with the cursor)
 ^+A - increment the number under the cursor
     - cursor can be anywhere on a multi-digit number
     - '^' represents the 'control key'
ga
  • print the ASCII & HEX value of the character under the cursor

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

1F4. vi & vim Editors

MARK lines & copy

m[a-z]
  • mark current line as a,b,c,... (any 1 of 26 alphas)
m a
  • mark current line as mark 'a'
  • can move cursor to some other line
mb
  • mark new current line as mark 'b'
  • no need to leave space between mark command & mark letter
 'a          - goto mark 'a' (addressed by preceding with sungle quote)
             - NO preceding ':' as on following commands
 :'a,'b      - address a range of lines from previously marked a & b
             - may use with 'move' & 'copy' as follows:
 :'a,'b m .  - move lines from mark 'a' thru mark 'b' to follow current line
             - deletes original lines
 :'a,'b co . - copy lines from mark 'a' thru mark 'b' to follow current line
             - preserves original lines

MARK lines, write to tmp/, read into 2nd file

vi dir/file1 <-- edit file1

ma
  • mark desired start line as mark 'a'
  • move cursor to some other line
mb
  • mark desired end line as mark 'b'

 :'a,'b w tmp/file1x  <-- Write selected lines to tmp/...
 ===================
 :q                     - quit editing file1

vi dir/file2 <-- edit file2

 ...         - move cursor to line above desired insert

 :r tmp/file1x        <-- read lines (selected from file1) into file2
 =============
 :wq                    - write & quit

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

1F5. vi & vim Editors

registers a-z

Registers are addressed by preceding '"' double quote vs single quote for marks. Registers are handy for capturing data lines for later insertion as desired.

 "a 5yy   - yank 5 lines into register "a
 "a5yy    - no need to leave space between register ID & Yank number & command
 "a p     - put contents of register "a (following current line)
 "A 2yy   - Append 2 more lines to contents of register "a
            (Upper case register Appends, lower case replaces)

registers to yank lines in file1 & put in file2

You can yank lines into registers (a-z) that will be preserved between files & between logon sessions (since stored in .viminfo file) (a very powerful feature that you should take advantage of).

vi dir/file1 <-- edit file1

 ...         - move cursor to 1st line desired

 "a5yy       - yank 5 lines into register "a
 =====
 :q          - quit editing file1

vi dir/file2 <-- edit file2

 ...         - move cursor to line above desired insert

 "ap         - put lines from register "a into file2
 ===
 :wq                    - write & quit

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

1F6. vi & vim Editors

WRITE & QUIT

 :w  - write workspace back to the file named on the vi entry command
 :w filename  - write workspace to a different file
 :q  - quit vi (warning if changes made without writing)

:wq - write & quit

ZZ
  • write & quit (same as :wq)

:q! - quit without writing

vi/vim internet References


 https://guru99.com/the-vi-editor.html
 ======================================
 - excellent tutorial on 'vim'

 https://guru99.com/unix-linux-tutorial.html (nofollow)
 ============================================
 - many other tutorials on unix/linux

 https://www.labnol.org/internet/learning-vim-for-beginners/28820/
 ===================================================================
 - interactive tutorial, try this FUN way to learn vi/vim

vi/vim recommended Books


 https://www.oreilly.com/library/view/learning-the-vi/1565924266/
 ================================================================
 - Learning the vi editor - Arnolds & Lamb - O'Reilly press

 https://www.oreilly.com/library/view/learning-the-vi/9780596529833/
 ===================================================================
 - Learning the vi & vim editor - Arnolds & Lamb - O'Reilly press

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

Part_2. Running C programs & Equivalent uvcopy jobs

UVdemos1 Part 2 Educational programs - Contents


2A1. lotto1.c - C program to generate Random Numbers
2A2. lotto1.c - source listing of C program
2A3. uvlotto1 - uvcopy job to generate Random Numbers
- uvcopy equivalent of lotto1.c program

2A4. countcode1 - utility to Count Lines of code in programming languages
such as C & uvcopy jobs

2B1. insult2.c - C program to generate Random Insults

2C1. test64a.c - 1st of 4 programs to test integer limits
- test 64 bit limits - start# 1 & multiply by 16
2C2. test64b.c - 2nd of 4 programs to test integer limits
- like test64a, but accepts start# & multiplier

2C3. uvcopy testint1 - 3rd of 4 programs to test integer limits
- uvcopy equivalent to test 64 bit integer limits
2C4. source listing of uvcopy job to test 64 bit integer limits

2C5. test64c.c - 4th of 4 programs to test integer limits

2D1. datedemo1 - convert dates between Calendar, Julian,& days-since-1900
- handy tool to calculate days between 2 dates, etc
- fun way to calculate your age in days or weekday you were born on

2D2. Questions you can answer with datedemo1
- How many days old are you ?
- On which day of the week were you born ?
- How many days to your next birthday ?

2E1. hexcalc1 - convert numbers from decimal to binary or binary to decimal
- displayed in hexadecimal
2E2. hexcalc1 - uvcopy job listing

2F1. lesson2.c - C program tutorial, great way to learn & understand C progamming
- copies a file with command line options to modify output
- run with Mod0,1,2,3,4,5, view output,& relate to C code

2G1. lesson3.c - Exercise for you, Copy lesson2.c to lesson3.c, & Modify
- Instructions for "Mod6" changes to calculate & append Record-Length

2H1. bugs1.c - tutorial for debugging C programs, 3 bugs for you to find & correct
- crashes caused by divide by zero, unitialized pointer, buffer overflow
- using 'gdb' to find crash reason with 'bt' (BackTrace) & set Breakpoints

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

UVdemos1 Part 2 Educational programs - Contents (continued)


2I1. skeleton1.c - suggested starting point to write your own program to modify files
- supplies I/O framework, insert your instructions where marked

2J1. exercise1 - copy skeleton1.c to exercise1.c & modify to copy a file adding sequence#s
- setup new working directory, make subdirs for src,bin,tf,tmp,sf,etc

2K1. table1.bsh - script to run lotto1 gnerate random#s, 100, 1000, or whatever desired
- then table summarize counts for each lotto# 1 to 49

2K2. table1.uv - uvcopy job to table summarize counts of random#s
- called by table1.bsh script

2K3. random100.tbl - report generated by table1.uv in tmp2/random100.tbl
- table summary counts for each of 1-49

2K4. table2.uv - add summarized counts of random#s to original table1 report
- to more clearly show most common random#s
- this job not listed, see in $HOME/demo/pf/table2.uv

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

2A1. Running C programs & Equivalent uvcopy jobs

As mentioned previously, UVdemos1 was inspired by my grandchildren. I wanted to allow them to login to my website with a userid/password & run the C compiler & simpler UV demos without having to download & install the Vancouver Utilities.

I have selected some demos that should interest any unix/linux user:

lotto1.c - C program to generate Random Numbers


 #1. ssh uvsoftxx@uvsoftware.ca  <-- Online userid in range uvsoft00-uvsoft99
     ==========================
     --> passxx                  <-- enter your password at the prompt

 #1a. Login userxx   <-- Alternative Login on your own machine
      ============       if you have downloaded & installed Vancouver Utilities
     --> passxx      <-- enter your password at the prompt

 #2.  cdm --> /home/uvsoftxx/demo (alias cdm='cd $HOME/demo)
      ===
 #2a. cdm  --> /home/userxx/demo  ('userxx' your login name if OffLine account)

 #3. gcc src/lotto1.c -o bin/lotto1 <-- compile source to executable
     ==============================

 #4. lotto1 6 1 49       <-- generate 6 random numbers from 1 to 49 (Canada's Lotto649)
     =============
      39
      14                 <-- sample output
      15
      25
      15
      47

 #5. vi src/lotto1.c   <-- inspect source code if desired
     ===============

The lotto1.c C source program is 95 lines (49 code & 46 /*comments*/) We list it on the next page with minimal /*comments*/

If you are new to Unix/Linux, you might wonder how the system finds executable programs (& scripts) when you enter only the program/script name (as in #4 above) ? Answer - by searching '$PATH' setup by the common_profile when you login.


 #6. echo $PATH  --> results very long, but contains ...:$HOME/demo/bin:...
     ==========

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

2A2. Running C programs & Equivalent uvcopy jobs

Listing of lotto1.c program to generate random numbers

 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <sys/time.h>
 int cycles;           /* arg#1 - random numbers desired         */
 long low;             /* arg#2 - low range                      */
 long high;            /* arg#3 - high range                     */
 int count = 0;        /* counter up to cycles random#s desired  */
 time_t timeseed;      /* seed for srand()                       */
 long rand1;           /* current random# generated              */
 struct timeval tv;    /* for gettimeofday(&tv,0);               */
 suseconds_t micros1;  /* from struct timeval suseconds_t tv_usec*/
 /* mainline for lotto1 */
 int main(int argc, char *argv[])
 {
 /* verify operator entered correct number of arguments   */
 if (argc != 4)
   { printf("--> lotto1 cycles low high <-- ***ERROR***, 3 numeric arguments expected \n");
     printf("--> lotto1   6     1   49  <-- example for Lotto 649\n");
     exit(91);
   }
 /* capture command line arguments */
 cycles = atoi(argv[1]);   /* arg1 random#s desired */
 low    = atol(argv[2]);   /* arg2 low range        */
 high   = atol(argv[3]);   /* arg3 high range       */
 /* get seed for rand() function - using current time */
 /* srand((unsigned) time(&timeseed));                */
 /* time_t seconds gets same seed unless wait 1+ secs */
 /* - use gettimeofday get microseconds for srand seed*/
 gettimeofday(&tv,0);
 micros1 = tv.tv_usec;          /* store local for debug */
 srand((unsigned) tv.tv_usec);  /* get seed using TOD microsecs*/

/* verify low < high */ if (low >= high) { printf("ERROR: low range > highrange\n"); exit(92); }

 /* begin loop to calc & print results */
 while (count < cycles)
   {  rand1 = (rand() % high);
      if (rand1 < low)
        { continue;
        }
      count++;       /* count up to cycles */
      printf("%ld\n",rand1);
   }
 exit(0);
 }

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

2A3. Running C programs & Equivalent uvcopy jobs

uvlotto1 - uvcopy job to generate Random Numbers

'uvlotto1' is a uvcopy job that does the same thing as the 'lotto1' C program, but with only 20 lines of code (& 22 lines of #comments).


 #1. uvcopy uvlotto1   <-- run uvcopy job pf/uvlotto1
     ===============     - same as lotto1.c program
      enter: number of random#s desired, low range, high range
      --> 6,1,49 <-- Example: 6 numbers from 1 to 49 (6/49 lottery)
      random# 1 = 12
      random# 2 = 7
      random# 3 = 3
      random# 4 = 30
      random# 5 = 12
      random# 6 = 47

 #2. vi $UV/pf/uvlotto1    <-- inspect source code for uvcopy job 'uvlotto1'
     ==================      - listed below:
 # uvlotto1 - generate random numbers with uvcopy
 @run
 man10   msg     'enter number,low,high Not entered, enter 3 arguments now'
         msgwa1  ' - OR reply null to default 6,1,49 - OR enter q to quit'
         cmc     $arg1(1),'q'            quit ?
         skp=    man90                   yes - goto EOJ
         fix     a0(20),$arg1,3,','      separate to a0(20),a20(20),a40(20)
         mvnx3   $ca1,a0(20)             convert to binary in $ca1,$ca2,$ca3
         cmn     $ca3,0                  3 arguments entered ?
         skp>    man20
         mvn     $ca1,6
         mvn     $ca2,1
         mvn     $ca3,49
 #
 # begin loop to generate $ca1 random#s between $ca2 & $ca3
 man20   add     $ca5,1                  count loops
 #       =====================
         ran     $ca4,$ca2,$ca3          gen current random# in $ca4
 #       =====================
         msgv1   'random# $ca5 = $ca4'   show current loop count & random#
         cmn     $ca5,$ca1               loop ctr = number requested ?
         skp<    man20                   no - repeat loop
         mvn     $ca5,0                  clear loop ctr for next set
         skp     man10                   return to prompt
 man90   eoj                             End job
Note

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

2A4. Running C programs & Equivalent uvcopy jobs

Counting & Comparing Lines of code for C & uvcopy

We can run a pre-programmed uvcopy utility job 'countcode1' to count Lines of Code for various programming & script languages, for example:


 #1. uvcopy countcode1,fili1=src/lotto1.c   <-- count lines of code & /* comments
     ====================================       in C program src/lotto1.c

 #2. cat tmp/lotto1.counts
     =====================
      countcode1 - count lines of code & comments for scripts,programs,uvcopy jobs,etc
      Host=uvsoft5, User=uvadm, Date=2020/09/03_17:03:30, File=src/games/lotto1.c
      Lines with '#'  col 1   =        4   without =       91
      Lines with '/*' col 1-2 =       46   without =       49
      Lines with all spaces -->        8
      Total Lines ------------>       95

 #3. uvcopy countcode1,fili1=pf/uvlotto1   <-- count lines of code & /* comments
     ===================================       in uvcopy job pf/uvlotto1

 #4. cat tmp/uvlotto1.counts
     =======================
 countcode1 - count lines of code & comments for scripts,programs,uvcopy jobs,etc
 Host=uvsoft5, User=uvadm, Date=2020/09/03_17:02:27, File=pf/demo/uvlotto1
 Lines with '#'  col 1   =       23   without =       20
 Lines with '/*' col 1-2 =        0   without =       43
 Lines with all spaces -->        0
 Total Lines ------------>       43
Note
  • the 4 lines with '#' col 1 of the C program are code (not comments as in uvlotto1)
  • the C program has 49+4 = 53 lines of code & 46 lines of comments
  • the uvcopy job has 20 lines of code & 23 lines of comments

You can run 'uvcopy countcode1' for any other C programs & uvcopy jobs you see

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

2B1. Running C programs & Equivalent uvcopy jobs

insult2.c - C program to generate Random Insults


 #1. gcc src/insult2.c -o bin/insult2 <-- compile source to executable
     ================================

 #2. insult2 5      <-- Execute bin/insult2 to generate 5 insults
     =========
      Thou  jarring,  boil-brained,  hugger-mugger!
      Thou  errant,  idle-headed,  lap-dragon!
      Thou  qualling,  dizzy-eyed,  harpy!
      Thou  impertinent,  fool-born,  fustilarian!
      Thou  wayward,  beef-witted,  baggage!

 #3. vi src/insult2.c   <-- inspect source code if desired (310 lines)
     ================

 #4. vi dat1/insults    <-- inspect the file of insult words
     ===============
 001 # tf/insults_Shakespeare - data file for $UV/src/games/insult2.c
 002 # dat1/insults <-- must copy/rename from tf/insults_Shakepeare
 003 #                - see www.uvsoftware.ca/uvdemos2.htm#Part_11
 004 # - insult2 reads insults from subdir/file = dat1/insults
 005 # - allows multiple files, in dat0/insultsA,B,C,etc, copy 1 to dat1/insults
 006 # - seq# cols 1-3, 3 insult words, 25 bytes each, at columns 6,31,56
 007 # - insult words must start on line 11, preceded by 10 lines of #comments
 008 #
 009 #    1         2         3         4         5         6         7         8
 010 #678901234567890123456789012345678901234567890123456789012345678901234567890
 011  artless                  base-court               apple-john
 012  bawdy                    bat-fowling              baggage
 013  beslubbering             beef-witted              barnacle
 014  bootless                 beetle-headed            bladder
 015  churlish                 boil-brained             boar-pig
 016  cockered                 clapper-clawed           bugbear
 017  clouted                  clay-brained             bum-bailey
 018  craven                   common-kissing           canker-blossom
 019  currish                  crook-pated              clack-dish
 020  dissembling              dizzy-eyed               coxcomb
                  ------- 37 lines omitted -------
 057  wayward                  toad-spotted             vassal
 058  weedy                    unchin-snouted           whey-face
 059  yeasty                   weather-bitten           wagtail

Two versions of the insult program

insult1
  • same as insult2 (demo above), but with the 3 columns of insult words
    hard-coded within the C program
insult2
  • same as insult1, but reads the 3 columns of insult words from a data-file
    which makes it easier for you to change the insults if desired
  • or make up an entirely new insults file.

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

2C1. Running C programs & Equivalent uvcopy jobs

test64a.c - 1st of 4 programs to test integer limits

  1. * $UV/src/testC/test64a.c - test 64 bit limits, hard-coded init 1, multiplier 16
  2. $UV/src/testC/test64b.c - same as test64a & accepts initial value & multiplier
  3. $UV/pf/adm/testint1 - uvcopy job that creates same report as C program test64a.c
  4. $UV/src/testC/test64c.c - solicits 1 value & shows short,int.long conversions

    #1. test64a - test 64 bit limits - start# 1 & mpy 16


 #1. gcc src/test64a.c -o bin/test64a  <-- compile source to executable
     ================================

 #2. test64a   <-- repeat loop (1*16*) until 0 or negative (17 times)
     =======
 test64a.c - test 64 bit long integer limits (19 digits)
 cycle   decimal-value        hex native       hex swapped   back to decimal ,edited
 00 00000000000000000001 0100000000000000 0000000000000001                          1
 01 00000000000000000016 1000000000000000 0000000000000010                         16
 02 00000000000000000256 0001000000000000 0000000000000100                        256
 03 00000000000000004096 0010000000000000 0000000000001000                      4,096
 04 00000000000000065536 0000010000000000 0000000000010000                     65,536
 05 00000000000001048576 0000100000000000 0000000000100000                  1,048,576
 06 00000000000016777216 0000000100000000 0000000001000000                 16,777,216
 07 00000000000268435456 0000001000000000 0000000010000000                268,435,456
 08 00000000004294967296 0000000001000000 0000000100000000              4,294,967,296
 09 00000000068719476736 0000000010000000 0000001000000000             68,719,476,736
 10 00000001099511627776 0000000000010000 0000010000000000          1,099,511,627,776
 11 00000017592186044416 0000000000100000 0000100000000000         17,592,186,044,416
 12 00000281474976710656 0000000000000100 0001000000000000        281,474,976,710,656
 13 00004503599627370496 0000000000001000 0010000000000000      4,503,599,627,370,496
 14 00072057594037927936 0000000000000001 0100000000000000     72,057,594,037,927,936
 15 01152921504606846976 0000000000000010 1000000000000000  1,152,921,504,606,846,976
 16 00000000000000000000 0000000000000000 0000000000000000                          0

 #3. vi $UV/src/testC/test64a.c  <-- inspect source code of C program
     ==========================
     - 160 lines (100 lines of code & 60 lines of /*comments*/)

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

2C2. Running C programs & Equivalent uvcopy jobs

test64b.c - 2nd of 4 programs to test integer limits

  1. $UV/src/testC/test64a.c - test 64 bit limits, hard-coded init 1, multiplier 16
  2. * $UV/src/testC/test64b.c - same as test64a & accepts initial value & multiplier
  3. $UV/pf/adm/testint1 - uvcopy job that creates same report as C program test64a.c
  4. $UV/src/testC/test64c.c - solicits 1 value & shows short,int.long conversions

    #2. test64b - like test64a, but accepts start# & multiplier


 #8a. gcc src/test64b.c -o bin/test64b  <-- compile source to executable
      ================================

 #8b. test64b 1 2   <-- starting from 1, multiply by 2,& repeat until 0 or negative
      ===========     - cycles 64 times as shown below
 test64b.c - test 64 bit limits (like test64a, but enter your start# & multiplier)
 cycle   decimal-value        hex native       hex swapped   back to decimal ,edited
 00 00000000000000000001 0100000000000000 0000000000000001                          1
 01 00000000000000000002 0200000000000000 0000000000000002                          2
 02 00000000000000000004 0400000000000000 0000000000000004                          4
 03 00000000000000000008 0800000000000000 0000000000000008                          8
 04 00000000000000000016 1000000000000000 0000000000000010                         16
 05 00000000000000000032 2000000000000000 0000000000000020                         32
 06 00000000000000000064 4000000000000000 0000000000000040                         64
 07 00000000000000000128 8000000000000000 0000000000000080                        128
 08 00000000000000000256 0001000000000000 0000000000000100                        256
 09 00000000000000000512 0002000000000000 0000000000000200                        512
 10 00000000000000001024 0004000000000000 0000000000000400                      1,024
 11 00000000000000002048 0008000000000000 0000000000000800                      2,048
 12 00000000000000004096 0010000000000000 0000000000001000                      4,096
 13 00000000000000008192 0020000000000000 0000000000002000                      8,192
 14 00000000000000016384 0040000000000000 0000000000004000                     16,384
 15 00000000000000032768 0080000000000000 0000000000008000                     32,768
                ------- 16 bit short limit -------
 16 00000000000000065536 0000010000000000 0000000000010000                     65,536
 17 00000000000000131072 0000020000000000 0000000000020000                    131,072
 18 00000000000000262144 0000040000000000 0000000000040000                    262,144
                         12 lines omitted
 30 00000000001073741824 0000004000000000 0000000040000000              1,073,741,824
 31 00000000002147483648 0000008000000000 0000000080000000              2,147,483,648
                ------- 32 bit int limit -------
 32 00000000004294967296 0000000001000000 0000000100000000              4,294,967,296
 33 00000000008589934592 0000000002000000 0000000200000000              8,589,934,592
                         28 lines omitted
 61 02305843009213693952 0000000000000020 2000000000000000  2,305,843,009,213,693,952
 62 04611686018427387904 0000000000000040 4000000000000000  4,611,686,018,427,387,904
                ------- 64 bit long limit -------
 63 -9223372036854775808 0000000000000080 8000000000000000 -9,223,372,036,854,775,808

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

2C3. Running C programs & Equivalent uvcopy jobs

uvcopy testint1 - 3rd of 4 programs to test integer limits

  1. $UV/src/testC/test64a.c - test 64 bit limits, hard-coded init 1, multiplier 16
  2. $UV/src/testC/test64b.c - same as test64a & accepts initial value & multiplier
  3. * $UV/pf/adm/testint1 - uvcopy job that creates same report as C program test64a.c
  4. $UV/src/testC/test64c.c - solicits 1 value & shows short,int.long conversions

    testint1 - uvcopy job to test 64 bit integer limits

'testint1' is a uvcopy job that creates the same output as the 'test64b.c' C program. You can run it as follows:


 #1. uvcopy testint1       <-- Execute job
     ===============         - writes report to tmp/testint1.H64
      uop=m16   - default multiplier of 16 - 17 cycles to reach limit
      uop=m2    - change multiplier to 2 - 65 cycles to reach limit
      null to accept or enter/override -->   <-- null to accept default m16
      20200621:482406:testint1: EOF filo01 wrts=19 size=1662: tmp/testint1.H64
      EOJ, Output File written to: tmp/testint1.H64
      enter: vi,cat,more,lp,uvlp12,etc (default more) -->   <--null to default to 'more'
      --- OR could inspect later using 'vi' as follows:

 #2. cat tmp/testint1.H64  <-- inspect output file
     ====================
                             ** sample report **
 testint1 - Site=UV_Software, Host=uvsoft5, Login=uvadm, Date=2020/06/19_21:06:36
 cycle   decimal-value        hex native       hex swapped     back to decimal ,edited
 01  00000000000000000001  0100000000000000  0000000000000001                          1
 02  00000000000000000016  1000000000000000  0000000000000010                         16
 03  00000000000000000256  0001000000000000  0000000000000100                        256
 04  00000000000000004096  0010000000000000  0000000000001000                      4,096
 05  00000000000000065536  0000010000000000  0000000000010000                     65,536
 06  00000000000001048576  0000100000000000  0000000000100000                  1,048,576
 07  00000000000016777216  0000000100000000  0000000001000000                 16,777,216
 08  00000000000268435456  0000001000000000  0000000010000000                268,435,456
 09  00000000004294967296  0000000001000000  0000000100000000              4,294,967,296
 10  00000000068719476736  0000000010000000  0000001000000000             68,719,476,736
 11  00000001099511627776  0000000000010000  0000010000000000          1,099,511,627,776
 12  00000017592186044416  0000000000100000  0000100000000000         17,592,186,044,416
 13  00000281474976710656  0000000000000100  0001000000000000        281,474,976,710,656
 14  00004503599627370496  0000000000001000  0010000000000000      4,503,599,627,370,496
 15  00072057594037927936  0000000000000001  0100000000000000     72,057,594,037,927,936
 16  01152921504606846976  0000000000000010  1000000000000000  1,152,921,504,606,846,976
 17  00000000000000000000  0000000000000000  0000000000000000                          0

 #3. vi $UV/pf/adm/testint1  <-- inspect uvcopy job
     ======================    - see listing below:

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

2C4. Running C programs & Equivalent uvcopy jobs

testint1 - uvcopy job to test 64 bit integer limits

 opr='$jobname - uvcopy job to test 64 bit integer limits'
 opr='uop=m16 - default options'
 opr='    m16 - default multiplier of 16 - 17 cycles to reach limit'
 opr='    m2  - changing multiplier to 2 - 65 cycles to reach limit'
 uop=q1m16      # default options
 rop=r1x4       # r1 = prompt for report disposition, x4 = default 'more'
 filo1=?tmp/$jobname.$bits,rcs=128,typ=LSTt
 lodv1=h0(100)
 $jobname - Site=$sitename, Host=$hostname, Login=$logname, Date=$datetime
 cycle   decimal-value        hex native       hex swapped     back to decimal ,edited
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 @run
        opn    all
        wtb    filo1,h0(100),h0(100)    write page headings
        mvn    $ca1,1                   init accumulator
 #
 # begin loop to convert, print, double,& repeat
 man20  clr    b0(80),' '               clear output area
        add    $ca4,1                   count cycles sequence#
        cmn    $ca4,66                  limit safeguard ?
        skp>   man20                    repeat loop until err or 67 cycles
 # convert binary to numeric & back to binary
        mvn    c0(20),$ca1              convert binary to numeric
        mvn    $ca2,c0(20)              convert numeric back to binary
 # edit fields for print output
        mvn    b0(2),$ca4               cycle#
        mvn    b4(20),$ca1              decimal value in 20 bytes
        hxc    b26(16),$ca1             convert to hex display
        mvn    c20(8bs),$ca1            swap Big/Little ends for display
        hxc    b44(16),c20(8)           convert to hex display
        edt    b62(26),$ca2,'z,zzz,zzz,zzz,zzz,zzz,zz9-'
        put    filo1,b0                 write output
 # multiply current value by multiplier & test limit reached
        mpy    $ca1,$uopbm              current * multiplier for next cycle
        skp>   man20                    quit on error reaching 20 digits
        add    $ca5,1                   switch for 1 more cycle to show err
        cmn    $ca5,2                   reached 2nd err ?
        skp<   man20                    return until 2nd err
 #
 man90  cls    all                      close files
        eoj                             end job

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

2C5. Running C programs & Equivalent uvcopy jobs

test64c.c - 4th of 4 programs to test integer limits

  1. $UV/src/testC/test64a.c - test 64 bit limits, hard-coded init 1, multiplier 16
  2. $UV/src/testC/test64b.c - same as test64a & accepts initial value & multiplier
  3. $UV/pf/adm/testint1 - uvcopy job that creates same report as C program test64a.c
  4. * $UV/src/testC/test64c.c - solicits 1 value & shows short,int.long conversions

 #1. gcc src/test64c.c -o bin/test64c  <-- compile source to executable
     ================================

 #2a. test64c 32767   <-- test conversion to binary & back to numeric
      =============
      short: 32767  int: 32767  long: 32767  <-- conversion 32767 max for short
      =====================================

 #2b. test64c 1234567890 <-- 10 digits max for 32 bit int
      ==================
      short: 722  int: 1234567890  long: 1234567890  <-- short conversion garbage
      =============================================

 #2c. test64c 1234567890123456789   <-- 19 digits max for 64 bit long
      ===========================
      short: -32491  int: 2112454933  long: 1234567890123456789
      =========================================================
       - short & int conversions garbage, but long OK for 19 digits

 3. vi $UV/src/testC/test64c.c  <-- inspect source code of C program
     ==========================
     - shortened here to 21 lines of code by omiting 30 lines of front end /*comments*/
       (explanations & examples similar to the above)
      #include <stdio.h>
      #include <stdlib.h>
      int main(int argc, char **argv)
      {
      short s;
      int i;
      long l;
      __int128 ll;  /* no printf format for __int128 */
      printf("test64c.c - test printf max digits for short(16), int(32),& long(64) \n");
      printf(" - short(16) max=32768, int(32) max=...  ,long(64) max=... \n");
      printf(" - enter your number & increase digits until failure for short,int,long\n");
      if (argc != 2)
        { fprintf(stderr, "\n ERROR (no number entered), Usage--> %s number \n", argv[0]);
          return 1;
        }
      s = atoi(argv[1]);
      i = atoi(argv[1]);
      l = atol(argv[1]);
      printf("\n short: %d  int: %d  long: %ld \n",s,i,l);
      return(0);
      }

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

2D1. uvcopy utility jobs you might find useful

datedemo1 - convert between calendar, julian,& days-since-1900

'datedemo1' is an interactive demo job to convert dates between 3 formats, and to add/subtract a number of days from previous days-since-1900, using commands:

  1. 'c' & ccyymmdd - calendar date to be converted to all 3 formats
  2. 'j' & ccyyddd - julian date to be convedrted to all 3 formats
  3. 'n' & number of days since 1900 - to be converted to all 3 formats
  4. '+' or '-' & number of days to add to or subtract from current date

Since UVdemos1 was originally intended to assist my grandchildren to learn about programming & working with unix/linux command line utilities, I tailored the examples to answer questions about his next birthday, such as:

How many days to next birthday & how many total days since Birth Sep 20/2006 ?


 #0. uvcopy datedemo1    <-- initiate interactive date conversion
     ================      - shows Today's dates before prompting for user input
            calendar  julian   days1900  -priordays  # day mth dd yyyy
 Today--->  20200702  2020184   44013       44013    4 Thu Jul 02 2020
 ================================================================================
 c=calendar, j=julian, n=days-since-1900, +/- days, q=quit <-- COMMANDs c,j,n,+,-
 c20200101,  j2020001,     n43830,        +180, -90        <-- EXAMPLEs

 #1. --> c20200920    <-- input 'c' + Calendar date for 14th Birthday Sep 20/2020
         =========      - see below '80' days from Today to 14th birthday

 c20200920  20200920  2020264   44093          80    0 Sun Sep 20 2020
 ================================================================================
 c=calendar, j=julian, n=days-since-1900, +/- days, q=quit <-- COMMANDs c,j,n,+,-
 c20200101,  j2020001,     n43830,        +180, -90        <-- EXAMPLEs

 #2. --> c20060920    <-- input 'c' + Calendar date for Birth on Sep 20/2006
         =========      - see below '5,114' total days old on 14th birthday

 c20060920  20060920  2006263   38979        5114-   3 Wed Sep 20 2006
 ================================================================================
 c=calendar, j=julian, n=days-since-1900, +/- days, q=quit <-- COMMANDs c,j,n,+,-
 c20200101,  j2020001,     n43830,        +180, -90        <-- EXAMPLEs

 #3. --> +5114       <-- might test to see if conversions agree (c,+,-,n,j)
         =====         - +5114 gets us back to 2020 14th birthday from Birth 2006

 +5114      20200920  2020264   44093        5114    0 Sun Sep 20 2020
 ================================================================================
 c=calendar, j=julian, n=days-since-1900, +/- days, q=quit <-- COMMANDs c,j,n,+,-
 c20200101,  j2020001,     n43830,        +180, -90        <-- EXAMPLEs

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

2D2. datedemo1 - convert between calendar, julian,& days-since-1900

Questions you can answer with datedemo1

  1. How many days old are you ?

  2. On which day of the week were you born ?

  3. How many days to your next birthday ?

  4. What other questions can you think of ?

See the uvcopy job stored at $UV/pf/demo/datedemo1. The all-important instruction is 'dat' documented at uvsoftware.ca/uvcopy.htm#dat.

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

2E1. Handy Tools for Unix/Linux

hexcalc1 - convert hex to decimal & decimal to hex

There are 2 versions, hexcalc1 for Little-End machines (Intel) & hexcalc2 for Big-End machines (mainframes). Look at my samples, then try your own conversions.


 uvcopy hexcalc1       <-- run hexcalc1 for Intel (use hexcalc2 for RISC)
 ===============
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> x100
 response--> hex 0000000000000100 = 256 in decimal
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d256
 response--> decimal 256 = 0000000000000100 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d1,000,000
 response--> decimal 1,000,000 = 00000000000F4240 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d1,000,000,000
 response--> decimal 1,000,000,000 = 000000003B9ACA00 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d1,000,000,000,000
 response--> decimal 1,000,000,000,000 = 000000E8D4A51000 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d1,000,000,000,000,000
 response--> decimal 1,000,000,000,000,000 = 00038D7EA4C68000 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> d1,000,000,000,000,000,000
 response--> decimal 1,000,000,000,000,000,000 = 0DE0B6B3A7640000 in hex
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> x0DE0B6B3A7640000
 response--> hex 0DE0B6B3A7640000 = 1,000,000,000,000,000,000 in decimal
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> q
 uvcopy hexcalc1 start 2020/06/22_21:30:17 end 21:33:16 elapsed 002_59_185

 uvcopy hexcalc1    <-- now try your own conversions
 ===============
 enter number with prefix "d" decimal, "x" hex rep, "q" quit
 entry-----> ...    <-- your entries

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

2E2. hexcalc1 - convert hex to decimal & decimal to hex

hexcalc1 - uvcopy job listing

 # hexcalc1 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/util/
 #          - hexadecimal calculator, hex to decimal, or decimal to hex
 # hexcalc1 - Little-End machines (Intel) & hexcalc2 for Big-End (mainframes)
 @run
        msg     'hexcalc1 for Little-End (Intel), hexcalc2 for Big-End (mainframes)'
        msg     'decimal->hex,hex->decimal,ex: d4096->x1000, x1000->d4096'
 #
 # begin loop to solicit numbers for conversion
 man20  msgwa1  'enter number with prefix "d" decimal, "x" hex rep, or "q" quit'
        mvc     a0(80),$arg1            store entry & blank extra w/s
        cmc     a0(1),'d'               dcml to hex ?
        skp=    dtox
        cmc     a0(1),'x'               hex to dcml ?
        skp=    xtod
        cmc     a0(1),'q'               quit ?
        skp=    quit
        msg     'invalid entry, 1st char not "d" or "x"'
        skp     man20
 #
 # convert decimal to hex
 # - max 20 numerics, allow 26 characters in case ','s present
 dtox   mvn     a40(20),a1(26)          drop the 'd' & any ',' commas
        mvn     b00(8bs),a40(20)        cnvrt dcml to binary ('s' switch Intel)
        hxc     b40(16),b00(8b)         cnvrt binary to hex rep
        mvf     b100(80),'decimal ddd = xxx in hex '
        rep     b100(80),'ddd',a1(26)   replace pattern with value
        rep     b100(80),'xxx',b40(16)  always show hex result in 16 bytes
        sqzc1   b100(80),' '            squeeze to 1 blank between words
        msgl2   b100(80)                display result
        skp     man20
 #
 # convert hex to decimal
 xtod   mvc     a40(16),a1              drop prefix
        sqzr    a40(16),' '             right justify
        rep     a40(16),' ','0'         left zero fill
        chx     c00(8),a40(16)          cnvrt hex to binary
        mvn     c40(20),c0(8bs)         cnvrt binary to decimal (switch Intel)
        edt     c60(26),c0(8bs),'z,zzz,zzz,zzz,zzz,zzz,zzz-'
        mvf     c100(80),'hex xxx = ddd in decimal'
        rep     c100(80),'xxx',a40(16)
        rep     c100(80),'ddd',c60(26)
        sqzc1   c100(80),' '            squeeze to 1 blank between words
        msgl2   c100(80)                display result
        skp     man20
 quit   eoj

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

2F1. lesson2.c - C program tutorial to learn & understand C progamming

Note
  • copies a file with modifications controlled by options Mod0,1,2,3,4,5
  • the program listing includes the documentation as /*comments*/
  • see 2nd page instructions to run 6x with Mod0,Mod1,Mod2,Mod3,Mod4,Mod5
  • see 3rd page below for expected outputs
  • see page '2G1' Exercise for you to copy/modify lesson2.c to lesson3.c
 /* lesson2.c - program to help beginners learn C programming                  */
 /*           - by Owen Townsend, www.uvsoftware.ca, April 09/2021             */
 /*      Note - sililariries & differences to lesson1.c & lesson2.c            */
 /*                                                                            */
 /* lesson1.c - copied a file of text records unchanged except appending the   */
 /*             current Mod0-Mod5 suffix of output file tmp1/test100.Mod0-Mod5 */
 /*           - included several COMMENTED OUT lines of instructions           */
 /*             for you to uncomment, recompile, re-execute,& note effects     */
 /*           - so lesson1.c now obsolete, not listed in UVdemos1.doc          */
 /*                                                                            */
 /**lesson2.c - this saves you manual edits to uncomment Mod1-Mod5 instructions*/
 /*           - program tests Mod# 1-5 to control which instructions executed  */
 /*                                                                            */
 /* lesson3.c - Exercize for you, copy lesson2.c to lesson3.c,& modify         */
 /*           - append " RL=999" RecordLength activated by ".Mod6" suffix/code */
 /*           - see "Mod6 Exercize" described further below                    */
 /*                                                                            */
 /* Note - Owen's solution for lesson3.c stored in $UV/src/learnC/lesson3.c    */
 /*      - but don't look until you have tried your best                       */
 /*                                                                            */
 /* cp -r $UV/demo/* $HOME/demo/ <-- assume $UV/demo/... copied to your homedir*/
 /* ============================                                               */
 /* cd $HOME/demo    (or use alias cdm=(cd $HOME/demo)                         */
 /* =============                                                              */
 /*                                                                            */
 /* gcc src/lesson2.c -o bin/lesson2      <-- compile program                  */
 /* ================================                                           */
 /* lesson2 tf/test100 tmp1/test100.Mod0  <-- execute program                  */
 /* ====================================    - Mod0 output before any changes   */
 /*                                                                            */
 /*Note - suffixes on output files control record Modifications as follows:    */
 /*                                                                            */
 /*                       ** Mod1-Mod6 codes **                                */
 /*                                                                            */
 /* Mod0 - before any changes due to uncommenting the Mod_ lines               */
 /*      - all Mods copy the file appending Mod0-Mod6 & a 4 digit sequence#    */
 /* Mod1 - search for "one" & translate to UPPER case "ONE"                    */
 /* Mod2 - COPY ONLY 10 RECORDs to output file                                 */
 /* Mod3 - SELECT EVERY 10TH RECORD to the output file                         */
 /* Mod4 - shorten record by insert null at column 25                          */
 /* Mod5 - shorten record by removing all trailng spaces                       */
 /* Mod6 - append Record-Length as ' RL=999' (999 actual length from strlen()  */

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

 /*                  ** Execute all 5 possible Mods **                           */
 /*                                                                              */
 /* Execute lesson2 for each of Mod0,Mod1,Mod2,Mod3,Mod4,Mod5,Mpd6 & see results */
 /*  - output displayed on screen as well as written to tmp1/test100.Mod0-Mod5   */
 /*  - include prior Mod codes mostly to copy every 10th record for Mods 4,5,6   */
 /*  - results shown on screen for each lesson2 execution                        */
 /*                                                                              */
 /* lesson2 tf/test100 tmp1/test100.Mod0      <-- append Mod# & 4 digit sequence#*/
 /* ====================================                                         */
 /* lesson2 tf/test100 tmp1/test100.Mod1      <-- search "one" & UPPER case ONE  */
 /* ====================================                                         */
 /* lesson2 tf/test100 tmp1/test100.Mod12     <-- COPY ONLY 10 RECORDs to output */
 /* =====================================                                        */
 /* lesson2 tf/test100 tmp1/test100.Mod123    <-- SELECT EVERY 10TH RECORD       */
 /* ======================================                                       */
 /* lesson2 tf/test100 tmp1/test100.Mod1234   <-- shorten inserting null col 25  */
 /* =======================================                                      */
 /* lesson2 tf/test100 tmp1/test100.Mod12345  <-- by removing trailing spaces    */
 /* ========================================                                     */
 /* lesson2 tf/test100 tmp1/test100.Mod123456 <-- append Record-Length RL=999    */
 /* =========================================   - for Mod6 lesson3.c exercise    */
 /*                                                                              */
 /*                 ** Mod6 Exercise for You to program **                       */
 /*                                                                              */
 /* Mod6 is NOT coded in the source code of lesson2.c                            */
 /*  - that is left as an exercise for You to complete                           */
 /*  - Here are a few hints:                                                     */
 /*                                                                              */
 /*  Copy $HOME/demo/src/lesson2.c to src/lesson3.c & modify as follows:         */
 /*  Insert code after "Mod5 - shorten record by removing trailing space"        */
 /*  - strstr() function to test for a '6' in output file suffix ".Mod0123456"   */
 /*  - strlen() function same as you see in the Mod5 code                        */
 /*  - sprintf() function similar to the sprintf in the sequence# code           */
 /*                                                                              */
 /*  Owen 1st tried to insert RL=999 prior to the common seq# & write record     */
 /*  - since I knew I could add 12 for RecordLength & seq# " RL=999 9999"        */
 /*  - but then I had to add another record-area f2rec4 & copy if Mod6 not done  */
 /*                                                                              */
 /*  Better to have "IF Mod6 RL=999" duplicate the seq# & write record code      */
 /*  - & the "ELSE" including the normal sequence# & write record (w/o RL=999)   */
 /*  - Allows "RL=999" at end-rec, no extra record area, or +12 assumption       */
 /*  - replaced +12 with dummy sprintf with ' 9999 RL=999' to get record length  */
 /*                                                                              */
 /*  Owen's solution is stored as lesson3.c in $UV/src/learnC/lesson3.c          */
 /*  - versus lesson2.c in $HOME/demo/src/lesson2.c (where students work)        */
 /*  - BUT, please do NOT look until you have done your best                     */
 /*                                                                              */
 /* If you mess up & want to start over, restore original lesson2.c as follows:  */
 /*                                                                              */
 /*    cp $UV/src/learnC/lesson2.c $HOME/demo/src/                               */
 /*    ===========================================                               */
 /*    cp $UV/src/learnC/lesson2.c src      <-- same since you are in $HOME/demo */
 /*    ===============================                                           */

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

 /*          ** sample outputs for each of Mod0 - Mod5 **              */
 /*                                                                    */
 /* more tmp1/*  <-- can review all output files after all Mods run    */
 /* ===========                                                        */
 /*                                                                    */
 /* 0001 one                                Mod0 0001                  */
 /* 0002 two                                Mod0 0002                  */
 /*   --- 96 lines omitted ---              Mod0                       */
 /* 0099 ninety nine                        Mod0 0099                  */
 /* 0100 one hundred                        Mod0 0100                  */
 /*                                                                    */
 /* 0001 ONE                                Mod1 0001                  */
 /* 0002 two                                Mod1 0002                  */
 /*   --- 96 lines omitted ---              Mod1                       */
 /* 0099 ninety nine                        Mod1 0099                  */
 /* 0100 ONE hundred                        Mod1 0100                  */
 /*                                                                    */
 /* 0001 ONE                                Mod12 0001                 */
 /* 0002 two                                Mod12 0002                 */
 /*   --- 06 lines omitted ---              Mod12                      */
 /* 0009 nine                               Mod12 0009                 */
 /* 0010 ten                                Mod12 0010                 */
 /*                                                                    */
 /* 0010 ten                                Mod123 0001                */
 /* 0020 twenty                             Mod123 0002                */
 /*   --- 06 lines omitted ---              Mod123                     */
 /* 0090 ninety                             Mod123 0009                */
 /* 0100 ONE hundred                        Mod123 0010                */
 /*                                                                    */
 /* 0010 ten                 Mod1234 0001                              */
 /* 0020 twenty              Mod1234 0002                              */
 /*   -- 06 lines omitted -- Mod1234                                   */
 /* 0090 ninety              Mod1234 0009                              */
 /* 0100 ONE hundred         Mod1234 0010                              */
 /*                                                                    */
 /* 0010 ten Mod12345 0001                                             */
 /* 0020 twenty Mod12345 0002                                          */
 /* -6 omitted- Mod12345                                               */
 /* 0090 ninety Mod12345 0009                                          */
 /* 0100 ONE hundred Mod12345 0010                                     */
 /*                                                                    */
 /* 0010 ten Mod0123456 0001 RL=031                                    */
 /* 0020 twenty Mod0123456 0002 RL=034                                 */
 /* -6 omitted- Mod12345                                               */
 /* 0090 ninety Mod0123456 0009 RL=034                                 */
 /* 0100 ONE hundred Mod0123456 0010 RL=039                            */
 /*                                                                    */
 /*Note - the "Mod6" code is NOT included in this src/lesson2.c        */
 /*     - that is an exercise for you to perform                       */
 /*     - see the instrucitons on the page above                       */

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

#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h>

 char f1n[64];         /* input filename                    */
 FILE *f1p;            /* file pointer from fopen           */
 char *f1s;            /* file status from fgets()          */
 /*Note - fgets status char *ptr, but fputs status int      */
 char f1rec[256];      /* input record area                 */
 int f1recs;           /* input record count                */
 char f2n[64];         /* output filename                   */
 FILE *f2p;            /* file pointer from fopen           */
 int f2s;              /* file status from fputs()          */
 char f2rec[256];      /* interim record before sequence#   */
 char f3rec[256];      /* output record with seq# appended  */
 /*Note - might need f4rec for lesson3 allow RL=999 or NOT  */
 int f2recs;           /* output record count               */
 char *pp,*qq;         /* misc char ptrs                    */
 int  ii,jj,kk,ll;     /* misc integers                     */
 char mod[16];         /* Mod0-Mod1 outfilename suffix      */
 char sysrec[100];     /* for system commands more,etc      */
 int main(int argc, char **argv)
 {
 if (argc != 3)
   { printf("usage: lesson2 infilename outfilename \n");
     printf("       ============================== \n");
     printf("example: lesson2 tf/test100 tmp1/test100.Mod0 \n");
     printf("         ==================================== \n");
     return(1);
   }

strcpy(f1n,argv[1]); /* store filenames from command line */ strcpy(f2n,argv[2]);

 f1p = fopen(f1n,"rb");  /* open input file */
 if (!f1p)
   { printf("cant open input file %s \n",f1n);
     return(2);
   }
 f2p = fopen(f2n,"wb");       /* open output file */
 if (!f2p)
   { printf("cant open output file %s \n",f2n);
     return(3);
   }
 /* verify output filename suffix .Mod0 - .Mod5 */
 pp = strstr(f2n,".Mod");
 if (!pp)
   { printf("output filename suffix must be .Mod0 - .mod5 \n");
     return(3);
   }
 if (!(isdigit(pp[4])))
   { printf("output filename suffix .Mod# digit must be 0-5 \n");
     return(3);
   }
 strcpy(mod,pp+1);   /* save suffix Mod0-Mod5 to append on output records */

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

 while (1)
   { /* begin loop to read/write records until EOF or I/O error */
     f1s = fgets(f1rec,256,f1p);  /* get next record            */
     if (f1s <= 0)                /* test EOF (or read error)   */
       { break;
       }
     f1recs++;                    /* inc count for line seq#    */
     /* We will remove the Linefeed from input records & add back on output  */
     /* - so we can append data to existing records to avoid output 2 records*/
     pp = strchr(f1rec,'\n');     /* search for the Linefeed x'0A'    */
     if (pp)                      /* - could code as '\x0A'           */
       { *pp = '\0';              /* replace with null terminator     */
       }
     strcpy(f2rec,f1rec);         /* copy input record to output area */
     /*---------------------------------------------------------------------*/
     /* Mod1 - search for "one" & translate to UPPER case                   */
     if (strstr(mod,"1"))
       { pp = strstr(f2rec,"one");  /* set pointer to 1st char of "one"     */
         if (pp)                    /* pp null if not found inhibits code   */
           { memcpy(pp,"ONE",3);    /* works in this case (not generalized) */
             /* ----------- OR as follows for any 3 char word ------------- */
             *pp = toupper(pp[0]); *(pp+1) = toupper(pp[1]); *(pp+2) = toupper(pp[2]); /* */
           }                        /* */
       }
     /*---------------------------------------------------------------------*/
     /* Mod2 - COPY ONLY 10 RECORDs to output file                          */
     if (strstr(mod,"2"))
       { if (f2recs >= 10)          /* Mod2 uncomment cols 1-2 (not these)  */
           { break; }               /* - leave these cmts after instrns     */
       }
     /*---------------------------------------------------------------------*/
     /* Mod3 - SELECT EVERY 10TH RECORD to the output file                  */
     if (strstr(mod,"3"))
       { if ((f1recs % 10) != 0)    /* Mod3 uncomment col 1-2               */
           { continue; }            /*                                      */
       }
     /*---------------------------------------------------------------------*/
     /* Mod4 - shorten record by insert null at column 25  (one relative)   */
     if (strstr(mod,"4"))
       { f2rec[24] = '\0';          /* insert null at byte 24 zero relative */
       }
     /*---------------------------------------------------------------------*/
     /* Mod5 - shorten record by removing all trailng spaces                */
     if (strstr(mod,"5"))
       { ll = strlen(f2rec);            /* get length of current record     */
         for (ii = ll-1; ii > 0; ii--)  /* for loop                         */
           { if (f2rec[ii] > ' ')       /* when we reach a non blank        */
               { break; }               /* - break the for loop             */
           }                            /*                                  */
         f2rec[ii+1] = '\0';            /* insert null after last non-blank */
       }

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

     /*------------------------------------------------------------------------------*/
     /* Mod6 - append Record-Length 'RL=999' 999 actual length from strlen()         */
     /*      - Mod6 is NOT coded in the source code of lesson2.c                     */
     /*      - Mod6 is left as an exercise for You to complete                       */
     /*      - copy $HOME/demo/src/lesson2.c to src/lesson3.c & modify as follows:   */
     /*                                                                              */
     /*  Insert code after "Mod5 - shorten record by removing trailing space"        */
     /*  - strstr() function to test for a '6' in output file suffix ".Mod0123456"   */
     /*  - strlen() function same as you see in the Mod5 code                        */
     /*  - sprintf() function similar to the sprintf in the sequence# code           */
     /*                                                                              */
     /*  Owen 1st tried to insert RL=999 prior to the common seq# & write record     */
     /*  - since I knew I could add 12 for RecordLength & seq# " RL=999 9999"        */
     /*  - but then I had to add another record-area f2rec4 & copy if Mod6 not done  */
     /*                                                                              */
     /*  Better to have "IF Mod6 RL=999" duplicate the seq# & write record code      */
     /*  - & the "ELSE" including the normal sequence# & write record (w/o RL=999)   */
     /*  - Allows "RL=999" at end-rec, no extra record area, or +12 assumption       */
     /*  - replaced +12 with dummy sprintf with ' 9999 RL=999' to get record length  */
     /*                                                                              */
     /*  Owen's solution is stored as lesson3.c in $UV/src/learnC/lesson3.c          */
     /*  - versus lesson2.c in $HOME/demo/src/lesson2.c (where students work)        */
     /*  - BUT, please do NOT look until you have done your best                     */
     /*                                                                              */
     /* If you mess up & want to start over, restore original lesson2.c as follows:  */
     /*    cp $UV/src/learnC/lesson2.c $HOME/demo/src/                               */
     /*    ===========================================                               */
     /*    cp $UV/src/learnC/lesson2.c src      <-- same since you are in $HOME/demo */
     /*    ===============================                                           */
     /*---------------------------------------------------------------------*/
     /* append sequence# & write current record to output file              */
     f2recs++;                    /* count output records */
     sprintf(f3rec,"%s %s %04d",f2rec,mod,f2recs);
     f2s = fprintf(f2p,"%s\n",f3rec);
     if (f2s <= 0)                /* test EOF (or read error) */
       { break;
       }
   }
 /* close files, display file with system(more) & EOF msg with record count & exit */
 fclose(f1p);
 fclose(f2p);
 sprintf(sysrec,"more %s",f2n);  /* create system command to display output file*/
 system(sysrec);                 /* execute the 'more' command */
 printf("EOF: copied %d records from input %s to %d records in output %s \n",f1recs,f1n,f2recs,f2n);
 return(0);
 }
 /*------------------------ end of lesson2.c --------------------------*/

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

2G1. lesson2 Exercise to Copy lesson2.c to lesson3.c, & Modify

lesson2 Mod6 Exercise for You to program

Mod6 is NOT coded in the source code of lesson2.c. it is left as an exercise for You to complete. Mod6 is described in the comments of lesson2.c listing and here we will show the difference between Mod5 & Mod6 outputs, showing only 1st & last lines:

               ----- Mod5 -----
 /* 0010 ten Mod12345 0001                     */
 /* 0100 ONE hundred Mod12345 0010             */
               ----- Mod6 -----
 /* 0010 ten Mod0123456 0001 RL=031            */
 /* 0100 ONE hundred Mod0123456 0010 RL=039    */

Here are a few hints how to proceed:

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

2G2. lesson2 Exercise to Copy lesson2.c to lesson3.c, & Modify

Guide for lesson2 Mod6 Exercise


 #0a. ssh uvsoftxx@uvsoftware.ca  <-- login assuming a guest login/password
      ==========================
      --> passxx                  <-- enter your password at the prompt
 #0b. cdm      <-- change to the demo director
      ===
 #0c. l src    <-- list programs in $HOME/demo/src/...
      =====

 #1. cp src/lesson2.c src/lesson3.c  <-- copy lesson2.c renaming as lesson3.c
     ==============================

 #2. vi src/lesson3.c  <-- modify as described above
     ================    - search/replace "lesson2" with "lesson3" apropriately

 #3. gcc src/lesson3.c -o bin/lesson2  <-- compile the program
     ================================

 #4a. bin/lesson3 tf/test100 tmp1/test100.Mod12345  <-- test without Mod6
      ============================================
 #4b. cat tmp1/test100.mod12345  <-- check your output
      =========================    - correct, recompile, retest as required

 #5a. bin/lesson3 tf/test100 tmp1/test100.Mod123456  <-- test with Mod6
      =============================================
 #5b. cat tmp1/test100.mod123456  <-- check your output
      ==========================    - correct, recompile, retest as required

optional if required


 #6. cp $UV/src/learnC/lesson2.c $HOME/demo/src/ <-- Restore original lesson2.c
     ===========================================   - if you mess up & want to restart

 #7. vi $UV/src/learnC/lesson3.c  <-- see Owen's solution
     ===========================    - But 1st give it your best shot

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

2H1. bugs1.c - tutorial for debugging C programs

Note
  • C program listing includes documentation as /*comments*/
 /* bugs1.c - to teach beginners about program crashes                 */
 /*         - by Owen Townsend, UV Software, Apr10/2021                */
 /*                                                                    */
 /* bugs1save.c - backup, copy to bugs1.c before changes               */
 /*             - before testing, fixing bugs, recompiling, retesting  */
 /*                                                                    */
 /* cp src/bugs1save.c src/bugs1.c <-- copy master version for debug   */
 /* ==============================                                     */
 /*                                                                    */
 /* gcc src/bugs1.c -o bin/bugs1 -g <-- compile with debug option      */
 /* ===============================                                    */
 /* bugs1   <-- execute (assuming $HOME/demo/bin in $PATH)             */
 /* =====                                                              */
 /*  --> Floating point exception(core dumped) <-- BUG1 divide by zero */
 /*           - fix by setting divisor jj = 2 (any non-zero)           */
 /*                                                                    */
 /* bugs1   <-- re-execute to demo BUG2                                */
 /* =====                                                              */
 /*  --> Segmentation fault (core dumped)                              */
 /*           - fix by defining --> char *qq = aa; <--                 */
 /*                                                                    */
 /* bugs1   <-- re-execute to demo BUG3                                */
 /* =====                                                              */
 /*  --> Segmentation fault (core dumped)                              */
 /*           - fix by redfine bb --> char bb[5000]; <--               */
 /*                                                                    */
 /* --------------------- Debug Strategy ------------------            */
 /* #1. The crash errmsg might be enough for you to see what to change */
 /*     then recompile & re-test OK, But if not use debugger as follows*/
 /* gdb bin/bugs1    <-- debug                                         */
 /* =============                                                      */
 /* --> r   <-- Run the program, will get crash msg (but still in gdb) */
 /* --> bt  <-- Back-Trace, will show you instruciton & line# crashing */
 /*           - usually enough to fix problem, but if not try #2       */
 /*                                                                    */
 /* #2. Set breakpoint at line# crashing & inspect relevant data fields*/
 /*     since this program, so short we set Breakpoint at main()       */
 /* gdb bin/bugs1    <-- debug                                         */
 /* =============                                                      */
 /* --> b main       <-- set Breakpoint at begin main()                */
 /* --> r            <-- Run the program                               */
 /* --> n            <-- Next instruction (execute 1 at a time)        */
 /* --> p xxxx       <-- Print (display) contents of desired fields    */
 /*                    - usually can see & fix problem                 */
 /* --> c            <-- could Continue to next Breakpoint,Crash,exit  */

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

#include"stdio.h" #include"string.h" #include"stdlib.h"

 int ii = 10;
 int jj = 0;         /* change jj=0 to jj=2 to fix BUG1 */
 int kk;
 char aa[10] = "abcdefghi";
 char bb[50];        /* change bb[50] to bb[5000]; to fix BUG2 */
 char *pp = aa;
 char *qq = 0;       /* change *qq = 0 to qq = aa to fix BUG3 */

int main() { printf("bugs1.c - to teach beginners about program crashes \n");

printf("BUG1
  • divide by zero --> kk = ii/jj <-- crash if jj=0 \n");
kk = ii/jj;
    R>
printf("
    kk = ii/jj <-- fixed by changing int jj=0; to int jj=2; \n");
 printf("BUG2 - ununitialized pointer --> char *qq=0; \n");
 strcpy(bb,pp);       /* same as --> strcpy(bb,aa); <-- since pp is pointer to aa */
 strcpy(bb,qq);       /* CRASH since qq is uninitialized (null) pointer */
 printf("       char *qq = aa;  <-- fixed by changing *qq=0; to *qq=aa; \n");
 printf("BUG3 - buffer overflow (copy too much data to too little space) \n");
 printf("     - memcpy(bb,aa,5000); tries to copies 5000 bytes to char bb[50]; \n");
 strcpy(bb,aa);       /* copy 9 bytes of data to a 10 byte area OK  */
 memcpy(bb,aa,5000);  /* copy 5000 bytes to a 10 byte area - CRASH ? */
 printf("       char bb[5000];  <-- fixed byanging char bb[50]; to char bb[5000]; \n");
 printf("fixed all bugs, exiting normally \n");
 exit(0);
 }
 /*------------------------------- end bugs1.c --------------------------------*/

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

2I1. skeleton1.c - I/O framework to write your own program

 /* skeleton1.c - template program for beginners to copy/rename/modify         */
 /*             - copies a file of text records unchanged (a skeleton program) */
 /*               starting framework for you to insert code to modify records  */
 /*               for whatever modifications you might want to make            */
 /*                                                                            */
 /* Master copy of skeleton1 program stored at $UV/src/learnC/skeleton1.c      */
 /* - also stored in the demo directory at $UV/demo/src/...                    */
 /* - copy all $UV/demo/* dirs/files to your $HOME dir (if not already there)  */
 /*                                                                            */
 /* cp -r $UV/demo/* $HOME/demo/ <-- copy all $UV/demo/... to your homedir     */
 /* ============================                                               */
 /* cd $HOME/demo    (or use alias cdm=(cd $HOME/demo)                         */
 /* =============                                                              */
 /* cp src/skeleton1.c src/programx1.c    <-- copy/rename for your project     */
 /* ==================================      - DO NOT MODIFY skeleton1.c        */
 /*                                                                            */
 /* gcc src/programx1.c -o bin/programx1  <-- compile program                  */
 /* ====================================                                       */
 /* programx1 tf/test100 tmp1/test100     <-- execute with test files provided */
 /* =================================                                          */
 /* bin/programx1 tf/test100 tmp1/test100 <-- if $HOME/demo/bin not in $PATH   */
 /* =====================================                                      */
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 char f1n[64];         /* input filename                    */
 FILE *f1p;            /* file pointer from fopen           */
 char *f1s;            /* file status from fgets()          */
 /*Note - fgets status char *ptr, but fputs status int      */
 char f1rec[256];      /* input record area                 */
 int f1recs;           /* input record count                */
 char f2n[64];         /* output filename                   */
 FILE *f2p;            /* file pointer from fopen           */
 int f2s;              /* file status from fputs()          */
 char f2rec[256];      /* output record area                */
 int f2recs;           /* output record count               */
 char *pp,*qq;         /* misc char ptrs                    */
 int  ii,jj;           /* misc integers                     */

char sysrec[100]; /* for system commands (head,more,etc)*/

 int main(int argc, char **argv)
 {
 if (argc != 3)
   { printf("usage: programx1 infilename outfilename \n");
     printf("       ================================ \n");
     printf("example: programx1 tf/test100 tmp1/test100 \n");
     printf("         ================================= \n");
     return(1);
   }

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

 strcpy(f1n,argv[1]);         /* store fieldnames from cmnd line  */
 strcpy(f2n,argv[2]);
 f1p = fopen(f1n,"rb");       /* open input file */
 if (!f1p)
   { printf("cant open input file %s \n",f1n);
     return(2);
   }
 f2p = fopen(f2n,"wb");       /* open output file */
 if (!f2p)
   { printf("cant open output file %s \n",f2n);
     return(3);
   }
 while (1)
   { /* begin loop to read/write records until EOF or I/O error */
     f1s = fgets(f1rec,256,f1p);  /* get next record            */
     if (f1s <= 0)                /* test EOF (or read error)   */
       { break;
       }
     f1recs++;                    /* inc count for line seq#    */
     /*Note - Skeleton program copies input records to output unchanged        */
     /* - you can add code to modify the records before writing to output file */
     /* - we will remove the Linefeed from input records & add back on output  */
     /*   to make it easier for you append data to existing records            */
     pp = strchr(f1rec,'\n');     /* search for the Linefeed x'0A' */
     if (pp)
       { *pp = '\0';              /* replace with null terminator  */
       }
     strcpy(f2rec,f1rec);         /* copy input record to output area */
     /*-----------------------------------------------------------------------*/
     /* You can insert code here to modify records as desired for your project */
     /*-----------------------------------------------------------------------*/
     /* write current record to output file */
     f2s = fprintf(f2p,"%s \n",f2rec);
     if (f2s <= 0)                /* test EOF (or read error) */
       { break;
       }
     f2recs++;                    /* count output records */
   }
 /* close files, display file with system(more) & EOF msg with record count & exit */
 fclose(f1p);
 fclose(f2p);
 sprintf(sysrec,"more %s",f2n);  /* create system command to display output file*/
 system(sysrec);                 /* execute the 'more' command */
 printf("EOF: copied %d records from input %s to %d records in output %s \n",f1recs,f1n,f2recs,f2n);
 return(0);
 }
 /*------------------------ end of skeleton1.c --------------------------*/

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

2J1. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Exercise1

 Here is a project to reinforce both command line tools & C programming.
 - Setup a directory named "exercise1" within your home directory
 - For userid uvsoftxx, the full pathname would be /home/uvsoftxx/exercise1
   and this will be your "working directory" for this exercise/project
 - Change to the working directory & make subdirs for programs,datafiles,scripts, etc
 - Create new program by copying skeleton1, renaming to exercise1,& modifying
 - we suggest appending a sequence# on end of records (similar to lesson2.c)

Instructions are sometimes general, you determine specific commands, consult your shell scripting book as required. We recommend "Learning the bash shell" O'Reilly.


 #01. ssh uvsoftxx@uvsoftware.ca   <-- login to website $HOME is /home/uvsoftxx
      ==========================

 #02. mkdir exercise1  <-- make "working directory" for your project
      ===============

 #03. cd exercise1     <-- change into your working directory
      ============       - full pathname is: /home/uvsoftxx/exercise1

 #04. make subdirs   - listed alphabetically
      ============
      archive - old files - optional, not required for this project
      backup  - file backups - optional
              - archive & backup might be needed for other projects
      bin  - binary (compiled) programs
      pf   - uvcopy jobs (may use later)
      sf   - scripts (may use later after C program)
      src  - Source code for C programs
      tf   - Test Files, data file input for C program
      tmp  - temporary files, output files from various commands
           - keep working directory all subdirs, all files within subdirs
      tmp1 - suggested as output directory for exercise1.c

 #05. tree .   <-- can use 'tree' to list your subdirs & files
      ======     - following shows results when project completed
 exercise1
 |-- bin/
 |   `-- exercise1*   <-- compiled program
 |-- pf/
 |-- sf/exercise1.sh  <-- might make script to execute program
 |-- src/
 |   |-- exercise1.c  <-- source program
 |   `-- lesson2.c
 |-- tf/              <-- Test data Files
 |   `-- test100
 |-- tmp/
 |   |-- test100_210618_062411P <-- hex display from 'uvhd'
 `-- tmp1/
     `-- test100      <-- output file from exercise1

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

2J2. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

copy files required to your working dir


 #06. cp $UV/src/learnC/skeleton1.c src/exercise1.c
      =============================================
      - "UV" is defined in the common_profile called by your .bash_profile
        which is executed when you login
      - If you ssh login with a guest userid uvsoft00-uvsoft99 (uvsoftxx here)
        the common_profile is /home/uvsoftxx/appsadm/env/common_profile_web1
        which defines UV=/home/uvsoftxx/uvadm, so skeleton1.c would be found
        at: /home/uvsoftxx/uvadm/src/learnC/skeleton1.c
      - If you have Vancouver Utiities installed on your own machine
        the common_profile is /home/appsadm/env/common_profile_uv
        which defines UV=/home/uvadm, so skeleton1.c would be found
        at: /home/uvadm/src/learnC/skeleton1.c

 #07a. cp $UV/tf/test100 tf  <-- copy input data file to your TestFile subdir
       ====================

Modify C program


 #08. edit your src/exercise1.c program as suggested below:
      =====================================================
  1. Use the I/O data files suggested in the program tf/test100 & tmp1/test100 - coded as /*comments, must be specifed as arg1 & arg2 when program executed

  2. Remove trailing spaces from existing tf/test100 records - which are space filled to 40 bytes + linefeed x'0A' in 41st byte - could copy code from $UV/src/learnC/lesson2.c 7 lines 257-263 - Line#s might change look for code following "/* Mod5 - shorten record ...

  3. Append 1 space + '#' + 3 digit sequence# at new end of record data - could copy/modify code from $UV/src/learnC/lesson2.c 3 lines 297-299 - Look for start line "/* append sequence# ... (incase line#s change)

  4. You need to add a 3rd record area (suggest f3rec) to reformat shortened f2rec into desired format with sequence# (#0001,etc) which will be written to output

  5. We suggest using /*comments*/ to leave a record of your changes - comment out lines that need to be changed & code revised version below - insert a comment line with reason for change

Note
  • the above is an overview of actions required,
  • see detailed instructions on page '2J4'
  • First understand the Input file with trailing unseen blanks
  • and the output file records with trailing spaces removed
  • see 'uvhd' displays on the next page '2J3'

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

2J3. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Input file tf/test100 sample 1st & last records

      0001 one
      0100 one hundred

Output tmp1/test100 sample 1st & last records

      0001 one #001
      0100 one hundred #0199

use 'uvhd' to see trailing blanks in input file


 uvhd tf/test100 t
 =================
 rec#=1 rsize=40 fptr=0 fsize=4000 records=100
                      10        20        30        4
 r#        1 0123456789012345678901234567890123456789
           0 0001 one                               .
             3333266622222222222222222222222222222220
             00010FE50000000000000000000000000000000A
                   --- 98 records omitted ---
                      10        20        30        4
 r#      100 0123456789012345678901234567890123456789
        3960 0100 one hundred                       .
             3333266626766766222222222222222222222220
             01000FE5085E425400000000000000000000000A

use 'uvhd' to confirm trailing blanks removed from output


 uvhd tmp1/test100 t
 ===================
 rec#=1 rsize=16 fptr=0 fsize=2238 records=100
                      10
 r#        1 0123456789012345
           0 0001 one #0001 .
             3333266622333320
             00010FE50300010A
 rec#=100 rsize=24 fptr=2214 fsize=2238 records=100
                      10        20
 r#      100 012345678901234567890123
        2214 0100 one hundred #0199 .
             333326662676676622333320
             01000FE5085E42540301990A

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

2J4. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Copy code from lesson2.c for Insert into exercise1.c

We will suggest copying code from lesson2.c Because this exercise more about using command line tools & editing than programming in C, but please study & understand the C code (look up instructions in your C book if not obvious)

We will copy code segments to "remove the trailing spaces" & to "sequence number" from lesson2.c & insert into our exercise1.c (copied from skeleton1.c).

Here we will copy the code segments using vim commands "yank" & "put" to "yank" lines from lesson2.c into buffers "a" & "b", and then "put" buffers "a" & "b' into the appropriate place in exercise1.c

For clarity, we will show you the code segments from lesson2.c, but you may need to make a few changes & add some field defintions (where other fields are defined)


 #08.  vi src/lesson2.c  <-- edit lesson2.c to "yank" desired lines into buffers a & b
       ================    - for later "put" into execise1.c
 #08a. :set number         - set line#s to match this documentation
       ===========
 #08b. scroll down until you see following lines
       =========================================
      255  /* Mod5 - shorten record by removing all trailng spaces                */
      256  if (strstr(mod,"5"))
      257    { ll = strlen(f2rec);            /* get length of current record     */
      258      for (ii = ll-1; ii > 0; ii--)  /* for loop                         */
      259        { if (f2rec[ii] > ' ')       /* when we reach a non blank        */
      260            { break; }               /* - break the for loop             */
      261        }                            /*                                  */
      262      f2rec[ii+1] = '\0';            /* insert null after last non-blank */
      263    }
Note
  • you need only lines 255-262, will later delete line 256 & remove "Mod5" word
  • set cursor on line 255 & yank 8 lines into buffer 'a' as follows
  • don't want lines 256 & 263, part of lesson2 logic to test command line filename
  • could optionally remove the '{' & '}'

 #08c. :255    <-- vim command to set cursor on line# 257
       ====
 #08d. "a 8yy  <-- vim command to yank 5 lines into buffer 'a'
       ======
 #08e. scroll down until you see following lines
       =========================================
      297 /* append sequence# & write current record to output file */
      298 f2recs++;                         /* count output records */
      299 sprintf(f3rec,"%s %s %04d",f2rec,mod,f2recs); /* format record seq# */
      300 f2s = fprintf(f2p,"%s\n",f3rec);  /* write record to output file */

 #08f. :297    <-- vim command to set cursor on line# 297
       ====
 #08g. "b 4yy  <-- vim command to yank 4 lines into buffer 'b'
       ======

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

2J5. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Insert code segments from lesson2.c into exercise1.c


 #09.  vi src/exercise1.c  <-- edit our new program to insert code segments
       ==================
 #09a. :set number   <-- vim command to show line#s
       ===========
 #09b. scroll down until you see following lines
       =========================================
      89  strcpy(f2rec,f1rec);               /* copy input record to output area */
      91  /*------------------------------------------------------------------------*/
      92  /* You can insert code here to modify records as desired for your project */
      93  /*------------------------------------------------------------------------*/
      94  f2s = fprintf(f2p,"%s \n",f2rec);  /* write current record to output file */

 #09c. :92   <-- set cursor on line# 92, OR scroll to "/* You can insert ..."
       ===
 #09d. "a p  <-- put code lines from buffer "a" following current line position
       ====
 #09c. :99   <-- set cursor on line# 99, OR scroll to the "}" last line of code inserted
       ===
 #09d. "b p  <-- put code lines from buffer "b" following current line position
       ====
 #09e. :93   <-- set cursor on line# 93, OR scroll up to  "if (strstr(mod,"5");"
 #09f. dd    <-- delete the "if (strstr(mod,"5");" line (part of lesson2.c logic)
       ===

 #09e. confirm result after code isnerts as follows
       ============================================
      89  strcpy(f2rec,f1rec);               /* copy input record to output area */
      91  /*------------------------------------------------------------------------*/
      92  /* You can insert code here to modify records as desired for your project */
      93     { ll = strlen(f2rec);            /* get length of current record     */
      94       for (ii = ll-1; ii > 0; ii--)  /* for loop                         */
      95         { if (f2rec[ii] > ' ')       /* when we reach a non blank        */
      96             { break; }               /* - break the for loop             */
      97         }                            /*                                  */
      98  /* append sequence# & write current record to output file */
      99  f2recs++;                         /* count output records */
     100  sprintf(f3rec,"%s %s %04d",f2rec,mod,f2recs); /* format record seq# */
     101  f2s = fprintf(f2p,"%s\n",f3rec);  /* write record to output file */
     102  /*------------------------------------------------------------------------*/
     103  f2s = fprintf(f2p,"%s \n",f2rec);  /* write current record to output file */

I have inserted blank lines between code segments from exercise1.c & lesson2.c to help you see changes required. Note duplication of "fprintf" write record code. But I suggest you first compile & execute as is, to see some undefined fields that you need to add up front where existing fields defined.

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

2J6. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Compile, Test/Execute,& Repeat until OK


 #10. vi src/exercise1.c   <--- initial edit after copy/rename from skeleton1.c
      ==================   OR - additional edit updates until results OK

 #11. gcc src/exercis1.c -o bin/exercise1   <-- compile your program
      ===================================

 #12. bin/exercise1 tf/test100 tmp1/test100  <-- Execute your program
      =====================================

 #12a. exercise1 tf/test100 tmp1/test100  <-- alternate if ./bin in $PATH
       =================================

 #13.  Check your output file
       ======================
 #13a. vi tmp1/test100    <-- check with editor
       ===============
 #13b. more tmp1/test100  <-- check with more or less (alias)
       =================    - if you left test100 as 100 lines
 #13c. cat tmp1/test100   <-- check with cat if only 10 lines
       ================     - cat convenient for small files (don't need quit)

 #14. Rpeat #09 - #12 until you get desired results

Your program will not execute perfectly on 1st compile & execute. You will learn a lot from the compile/test/debug/correct cycle.

Make a script to execute your program


 #15. vi sf/exercise1.bsh
      ===================
      - edit a script to execute your program
      - appending "bsh" to distinguish from compiled program
      - or you could make up some other name

 #16a. sf/exercise1.bsh
       ================
       - could code the directory
       - then name could be same as bin/exercise1

 #16b. exercise1.bsh
       =============
       - no need to code sf/... since sf is in $PATH in common_profile_web1
Note
  • Bash scripts could be given any extension (or extension omitted)
  • original Bourne shell scripts were given extensins '.sh'
  • we think '.bsh' makes sense for bash shell scripts if desired
  • we use .ksh for the Korn shell (required for JCL conversions)
    because it allows 'autoload functions' for GDG files etc

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

 2J7.     Exercise1 - copy skeleton1.c, rename exercise1.c, modify
 #08.  vi src/lesson2.c  <-- edit lesson2.c to "yank" desired lines into buffers a & b
       ================    - for later "put" into execise1.c
 #08a. :set number         - set line#s to match this documentation
       ===========
 #08b. scroll down until you see following lines
       =========================================

 #08c. :257    <-- vim command to set cursor on line# 257
       ====
 #08d. "a 5yy  <-- vim command to yank 5 lines into buffer 'a'
       ======
 #08e. scroll down until you see following lines
       =========================================
      297 /* append sequence# & write current record to output file */
      298 f2recs++;                         /* count output records */
      299 sprintf(f3rec,"%s %s %04d",f2rec,mod,f2recs); /* format record seq# */
      300 f2s = fprintf(f2p,"%s\n",f3rec);  /* write record to output file */

 #08f. :297    <-- vim command to set cursor on line# 297
       ====
 #08g. "b 4yy  <-- vim command to yank 4 lines into buffer 'b'
       ======

Alternative method to copy/paste code segments

By writing code segments from lesson2.c into tmp/... files for later read into your exercise1.c program. Here is an example for just the 1st code segment to Remove Trailing Spaces (write/read to/from tmp/RTS below).


 #08a. vi $UV/src/learnC/lesson2.c  <-- begin method#2 (write code to tmp/...)
       ===========================
 #08b.  :257           <-- goto line# 257 (1st line of code to copy)
 #08c.  ma             <-- Mark line 257 as Mark 'a
 #08d.  :263           <-- goto line# 263 (last line of code to copy)
 #08e.  'm,. w tmp/RTS <-- Write lines from Mark 'a to current line (.)
 #08f.  :q

 #09a. vi src/exercise1.c
        ==================
 #09b.  :92            <-- goto line# 92 marked with "Insert code here"
 #09c.  :r tmp/RTS     <-- Read code to "Remove Trailing Spaces"
 #09d.  ...            <-- modify for exercise1 (as described above)

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

2J8. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

script writing tips

  1. 1st line should be --> #!/bin/bash <--

  2. 2nd line #comment with filename of script + description of what it does

  3. 3rd+ #comment lines could include command format - especially when arguments required as in this case

  4. Better if Command format coded on "echo ..." lines - displayed when user does not enter correct command & arguments - see many examples in UV scripts in $UV/sf/util/... - such as $UV/sf/dropCR listed below to illustrate these tips

    sample script to illustrate tips above

 #!/bin/bash
 # dropCR - copy 1 file dropping any 'CR's (Carriage Returns x'0D')
 #        - by Owen Townsend, UV Software, June14/2021
 #        - shell script from UVSI stored in: /home/uvadm/sf/util/...
 # dropCRA - alternate script to drop CRs from All files in a directory
 #
 #Note - CR's common on Windows, but can cause problems on Unix/Linux
 #     - Windows records may be terminated with CR & LF x'0D0A'
 #     - Unix/Linux records should be terminated with only LF x'0A'
 #
 echo "dropCR - copy a file dropping any 'CR's (Carriage Returns x'0D')"
 f1="$1"; f2="$2";
 if [[ -f "$f1" && -"$f2" ]]; then :
    else echo "usage: dropCR infile outfile"
         echo "       ====================="
         echo " - arg1 & arg2 must be files (code any subdirs/...)"
         echo " "
         echo "example: dropCR tf/names4 tmp/names4"
         echo "         ==========================="
         exit 1; fi
 #
 tr -d '\r' <$f1 >$f2
 #===================
 echo "$f1 copied to $f2, dropping CRs"
 exit

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

2J9. Exercise1 - copy skeleton1.c, rename exercise1.c, modify

Optional - alias to change into working directory

It is convenient to make an alias to change into your various working-directories. I suggest you might setup alias cde1='cd $HOME/exercise1'


 alias cd='exercise1'   <-- can enter at your login prompt
 ====================     - but effective only to the end of current login session

Better to add to your $HOME/.bashrc (or to $HOME/.bashrc_aliases)


 vi .bashrc    <-- edit .bashrc & add the alias at the end of existing file
 ==========

Not effective until you logout & backin, But you could execute .bashrc with '.'


 . .bashrc       <-- '.' execute .bashrc to make efective immediately
 =========
 source .bashrc  <-- can use 'source' vs '.' (longer but more descriptive)
 ==============

ls option '-a' to see hidden files


 ls -al $HOME <-- use '-a' option to see hidden files
 ============   - may combne with other ls options 'l' for Long listing

 lla $HOME    <-- or use UV Software script 'lla' to save keystrokes
 =========

 lla    <-- omit directory to default to the "current directory"
 ===

Most UV Software scripts are stored in $UV/sf/util/..., inspect with 'vi' or 'cat'


 cat $UV/sf/util/lla  <-- display the 'lla' script
 ===================

Recommended books

You can get help from the code in existing lesson2.c, other demos in www.uvsoftware.ca/uvdemos1.htm#Part_2, & the following books.

Learning the Bash Shell - Cameron Needham - O'Reilly Press

The Linux Command Line - William Shotts

The C Programming Language - Kernighan & Ritchie

C Reference Manual
  • Harbison & Steele

Learning the vi editor - Arnolds & Lamb - O'Reilly press

Learning the vi & vim editor - Arnolds & Lamb - O'Reilly press

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

2K1. Generate Random#s & table summarize counts for each of 1-49

table1.bsh - script to generate random#s & table summarize

 #!/bin/bash
 # table1.bsh - script to run "lotto1" generate random#s AND "uvcopy table1" to table summarize
 #            - script stored at $UV/sf/demo/table1.bsh & $HOME/demo/sf/table1.bsh
 #            - by Owen Townsend, UV Software, July 15/2021
 # 1. lotto1  - generate random numbers to be table summarized by "uvcopy table1"
 #            - C program stored at $UV/src/games/lotto1.c & $HOME/demo/src/lotto1.c
 # 2. uvcopy table1.uv - create table summary from 1st word of each record in a text file
 #                     - uvcopy job stored at $UV/pf/demo/table1.uv & $HOME/demo/pf/table1.uv
 # 3. uvsort  - sort summarized targets by count prior to matching to table1 sorted by target
 # 4. uvcopy table2.uv - add sorted by count summarized targets beside the original table1 sorted by target
 #
 # --> can repeat this script generating various quantities of random#s to be table summarized
 #     & reported with sorted counts to see most common random#s
 #
 nos="$1";
 if ((!nos)); then
    echo "usage: table1.bsh number of random#s to generate with lotto1 for uvcopy table1 summarize"
    echo "example table1.bsh 100  <-- genrate 100 numbers 1-49 for uvcopy table summarize"
    echo "        ==============    - could generate 1000 or whatever desired"
    exit 99; fi
 #
 lotto1 $nos 1 49 > tmp1/random$nos   # generate random#s in tmp1/random100
 #=================================
 #
 uvcopy table1.uv,fili1=tmp1/random$nos,filo1=tmp2/random${nos}.tbl  # input to tmp1/ output in tmp2/
 #=================================================================
 #
 uvsort "fili1=tmp2/random$nos.tbl,rcs=100,typ=LST,filo1=tmp2/random${nos}_sorted\
 ,key1=24(6),del1=31(1)<0,del1=31(1)>9,mvno1=b41(6)a24(6),mvno1=b48(9)a31(9)"
 #================================================================================
 # - sort table1 output by count (vs summarized target already in sequence)
 #
 uvcopy table2.uv,fili1=tmp2/random$nos.tbl,fili2=tmp2/random${nos}_sorted,filo1=tmp3/random${nos}_matched
 #========================================================================================================
 # - add the sorted by count & summarized targets beside the original table1 sorted by target
 # - to clearly show the most common targets in sequence (mode)
 # - could also caluculate average

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

2K2. Generate Random#s & table summarize counts for each of 1-49

table1.uv - create table summary counts random#s 1-49

 # table1.uv - create table summary counts random#s 1-49
 #           - summarizes whatever 1st word of each record in a file
 #           - by Owen Townsend, UV Software, July 14/2021
 #
 # uvcopy table1.uv,fili1=tf/random100,filo1=tmp2/tandom100.tbl  <-- example command
 # ============================================================
 #  - table summarize 1st word from records in tf/random100 file
 #  - output file defaults to tmp2/inputfilename with '.tbl' extension
 #
 # uvcopy table1.uv  <-- same as above, I/O files default as shown above
 # ================    - omit filo1=..., defaults same filename as input in tmp2/...
 #
 # Generate various random# files for input to table1
 #  - using lotto1 program as follows:
 #
 # lotto1 100 1 49 > tmp1/random100    <-- generate 100 random#s in tmp1/random100
 # ================================      - could generate 1000 or whatever desired
 # uvcopy table1.uv,fili1=tmp1/random100  <-- input to table1, output in tmp2/random100.tbl
 # =====================================
 #  - repeat above with various other random# files
 #
 opr='$jobname - ceate table summary from 1st word of all records in a text file'
 rop=r1   # option to view output file at eoj
 fili1=?tf/random100,rcs=256,typ=LST
 filo1=?tmp2/$fili1.tbl,rcs=256,typ=LST
 @run
         opn     all                     open files
 # begin loop to get records, add word to table, until EOF
 man20   get     fili1,a0                get next record
         skp>    man90                   (cc set > at EOF)
         mvc     b0(100),a0              move record area 'a' to area 'b'
         sqzc1   b0(100),' '             squeeze multi spaces to 1 space between words
         fix     c0(30),b0(100),8,' '    fix words 30 bytes apart
         tblt1f1 c0(30),'summary word'   add current record word to table#1 format#1
         skp     man20                   return to get next record
 #
 # EOF - dump table to output file, close files & end job
 man90   tbpt1   filo1,'table summary 1st word all records in $fili1'
         cls     all
         eoj

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

2K3. Generate Random#s & table summarize counts for each of 1-49

table1 report generated by table1.uv

 table1.uv  2021/08/20_17:56:37_509  table summary 1st word all records in tmp1/random100
 tbl#0001  tblt1f1 c0(30)       <----- argument ----->
 line#   1strec#  %      count  summary word
     1         3   1         1  01
     2        53   3         3  03
     3        24   3         3  04
     4        44   1         1  05
     5        25   1         1  06
     6         7   5         5  07
     7        12   3         3  08
     8        88   1         1  09
     9        84   1         1  10
    10        48   4         4  11
    11        17   3         3  12
    12        20   1         1  13
    13        54   2         2  14
    14        85   1         1  15
    15        33   1         1  16
    16        86   2         2  17
    17         2   5         5  20
    18        11   1         1  21
    19         6   1         1  22
    20        68   1         1  23
    21        35   3         3  25
    22        30   2         2  26
    23        36   1         1  27
    24         9   2         2  28
    25        27   4         4  29
    26        55   1         1  30
    27        43   1         1  31
    28        28   4         4  32
    29        26   3         3  33
    30         5   3         3  34
    31        49   3         3  35
    32         1   4         4  36
    33        56   1         1  37
    34        46   2         2  38
    35        15   4         4  39
    36        13   3         3  40
    37         8   1         1  41
    38        73   1         1  42
    39        10   3         3  43
    40        47   3         3  44
    41         4   3         3  45
    42        50   3         3  46
    43        51   2         2  47
    44        39   2         2  49
                 100       100*  *TOTAL*

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

Part_3 Games for Fun & Education

Part 3 Games - Contents


3A1. quiz2c - Multiple Choice quiz game
- multiple quiz files provided (currently 51 & growing).
- you can play on the UV Software website with a guest login userid/password
- all you need is 'ssh' (Secure SHell) standard on Windows 10, Mac, any Unix/Linux
- play with friends, run Total reports to see who is the champion
- quiz2c collects score Result files into a directory ./quiz2r/...
- Result files date/time stamped with playername, quizfilename,& corrects/totals
- quizfiles downloaded from internet sites & reformatted for quiz2c
- you can make up your own quizfiles with editor & reformat with uvcopy job provided
- you can download the quiz2c.c C code, modify,& compile on your own computer.
- an opportunity to learn programming in C (great attraction for young people)
- get experience working on the command line with Linux & UV Software utilities
- Try the game, send me any feedback you may have.

3A2. 51 Quiz Files Available to play with quiz2c (CLI) or on jetpunk.com (GUI)

3A3. GUI for some, but CLI if you want run quiz tournaments & have control over result
files with corrects, wrongs,& percentages correct by quiz & player.

Playing quiz2c is a great way to learn how to use the unix/linux command line tools. And you will learn about shell scripting if you download or make up your own quizzes as shown later in this documentation starting on page '3G1'.


3B1. If you just want to Play the Game - follow the login instructions on page '3B1'
then jump to page '3C2' to see sample game play for 2 players, playing 2 games.

If you want to Learn more about the Directories/Files setup for quiz2c and the Linux command line tools to investigate Directories & Files - then do the investigations on pages '3B2'-3B4, Before playing the game on pages '3C2'-3C6.


3B2. Learn about Linux Directories/Files & command line tools you can use to investigate
the Directories & Files - Before playing the game (starting on '3C2').

3B3. Directories & Files required to play the quiz2c game
- Change to /home/uvsoftxx/demo/... to play the game
- use alias 'cdm' to change to the $HOME/demo/ directory to play the game
- list the subdirs in demo/... & note the subdirs relevant to the quiz game

3B4. Directory Tree diagram to highlight dirs/files most relevant to quiz2c game
- quizfiles available stored in $HOME/demo/quiz2f/...
- your Result files (Questions/Choices/Answers correct or Wrong) will be collected
  in $HOME/demo/quiz2r/... by default

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

Part 3 Games - Contents (continued)

quiz2c Play the Game


3C1. Execute quiz2c to play the game
- quiz2c with no argument defaults the Results directory to ./quiz2r/ if present
- may specify an argument with an alternate Reslts directory (such as Science101)
- Main-menu displayed when the game begins
- switch to shorter Sub-menus for faster play
Sub-Menu options: N N,name F F# P R R# W W# T Z Z# H Q
  (N=Name,F=Files,P=Play,R=Results,W=WrongResults,T=Totals,Z=clearResult,H=Help,Q=Quit)

3C2. suggested competition with a friend
- demo for 2 players, 2 games each,& showing results with %percentage corrects
- 1st player (Owen) playing 1st game
- menu option 'f' to list quiz Files available
- menu option 'f26' to select 26th file from list (Science01)
- menu option 'p' to begin Play (16 Questions, usually 4 Choices A,B,C,D)

3C3. 1st player playing 2nd game (Science02)

3C4. 2nd player playing 1st & 2nd game (Science01 & Science02)

3C5. Check Results for all games played today
- All Results Questions/Choices/Answers right & wrong
- or ONLY for Questions with WRONG answers
- Suggestions for tournament play

3C6. Check Totals by Player with %percent correct
- menu option 't' displays the Totals_Summary_Report

3D1. Tournament Play Concise Game Plan
- for 2 players, playing 2 games each, checking result totals & %correct
- parents/teachers might suggest to children/students

3D2. Results of Tournament demo play

3D3. Parents/Teachers might setup a specific directory to collect student results
(vs the default results directory ./quiz2r/...)

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

Part 3 Games - Contents (continued)

quiz2 Facts you "Need to Know"


3E1. quiz2 Facts you "Need to Know" & "Must Understand"
- especially if you are a parent or teacher directing your children/students
- understanding directories collecting quiz Results & for review
- tournament play same set of quizfiles & run total reports with % correct

3E2. Combining Results of tournament play over multiple days (script 'quiz2combine')
- required because Results are normally reported only for the current day
 Sample tournament begun on April 01/2021 & continued on April 02/2021

3E3. Run script 'quiz2combine' to create consolidated reports for all players
with counts of corrects/wrongs by quizfile & totals with %correct

3E4. Sample Total Report for 3 players playing 2 games each

3E5. Check Results for specified Day before combining all Days
quiz2c quiz2r/yyyymmdd <-- specify prior day to be reported

Quiz file Management for Teachers


3F1. Managing quiz2 Directories/Files for Teachers
- tree diagrams of demo directories/files to help understanding

3F2. Directories/Files Relevant to quiz2c demos

3F3. quiz2 Results Directory default ./quiz2r/...
- Recommend Teachers REMOVE quiz2r/ default directory
- so students force to specify intended directory
  (such as science101, geography200, etc)

3F4. quizzes run over Multiple Days
quiz2combine - script to combine multi-day results to today

3F5. Example: Teacher investigating Results for science101 quiz

3F6. Can Download quiz Results to your computer

3F7. Can Run quiz2 on your computer (vs UV Software website)
- but does require installing Vancouver Utilities on your computer
  (vs all software provided on the UV Software guest login)
 Could Run quiz2 on school servers
 Could Download/Convert &/or Makeup your own quizfiles

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

Part 3 Games - Contents (continued)

Download quizfiles from internet


3G1. Download quiz files from the internet to be reformatted for quiz2c
 "jetpunk.com" is the world's premiere website for hundreds of quiz files
Note - you cannot download directly to a UV Software guest userid/password account
- 1st download onto your computer, then upload to your guest account

3G2. Instructions to Download quizfile to your computer
- then upload to your UV Software guest login & reformat as required for quiz2c
- step by step easy to follow instructions

Converting quizfiles to the format required by quiz2c


3H1. Converting quizfiles to the format required by quiz2c
Directories/Files to reformat New quiz-files
tree diagram of $HOME/demo directory
quiz2d/qf0, qf1, qf2, qf3
quiz2f/Science01, Science02, Science03, etc
quiz2r/20210226R/20210226_114400_Science01_Owen_0014_0016

3H2. Format Rules for Question file/record input to the 'quiz2c' game
 File conversions required for quizfiles downloaded from websites
qf0 ----> qf1 -----------> qf2 ----> qf2 -----------> qf3 ----> /demo/quiz2f/
  copy quiz2reforms1 edit quiz2reforms2 copy (for play)

3H2a. Clarify difference 'uvcopy jobs' vs 'scripts'


3H3. File Formats Illustrated
 Downloaded from jetpunk.com --> qf0 --qf1
- Illustrated with 1st 2 sets of Questions/Choices

3H4. Instructions for each quizfile to be reformatted
- uvcopy scripts provided to convert to the format required by quiz2c
 quiz2reforms1 qf1->qf2 inserts blank lines between groups of Questions & Choices
- edit to append the correct answer on end of Question code cc=?
 quiz2reforms2 qf2->qf3 moves Answers from end of Questions to separate line
- then copy from demo/quiz2d/qf3 up to demo/quiz2f/... ($QUIZFILES) for play

3H5. Instructions to copy from Development to Deployment #9 - #11d
- and play the game to test your conversion & deployment

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

Part 3 Games - Contents (continued)

Listings of scripts used in support of quiz2c


3I1. 'quiz2combine' script to combine Result subdirs to today's date
- allows quiz2 touranments or class tests to continue over more than 1 day

3I2. 'quiz2reforms1' script calling uvcopy 'quiz2reform1' qf1/... --> qf2/...
- inserts blank lines between groups of Questions & Choices
- part of quizfile reformatting procedures on page '3H4'

3I3. 'quiz2reforms2' script calling uvcopy 'quiz2reform2' qf2/... --> qf3/...
- error-checks & moves Answers from end of Questions to separate lines
- part of quizfile reformatting procedures on page '3H4'

3J1. Notes for those Interested in C programming
If you are interested in learning C programming, you can inspect the C code
& modify if you wish, backup copies are available for recovery from disasters.

3K1. Books - Command Line Tools, Scripting,& C programming

Here are some books I recommend for anybody wishing to learn unix/linux command Line Tools and C programming. Anybody working with computers will benefit from learning "command line tools" & perhaps "shell scripting". Learning "C programming" could lead to a career for young people.

  1. Learning the Bash Shell - Cameron Needham - O'Reilly Press
  2. The Linux Command Line - William Shotts
  3. The C Programming Language - Kernighan & Ritchie
  4. C Reference Manual - Harbison & Steele
  5. Learning the vi editor - Arnolds & Lamb - O'Reilly press
  6. Learning the vi & vim editor - Arnolds & Lamb - O'Reilly press

    3L1. wordle game from: Github user "HUYTD" www.theregister.com/2022/02/02/bash_wordle
    - bash script with some enhancements
    - changed max_guess from 6 to 12 & allowing "Q" or "q" quit before max
    - added arg1 "learn" to show the word at begining to assist learning wordle
    - changed ASCII color codes to more meaningful symbols $GREEN, $YELLOW, etc

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

3A1. Games written in C for compile/Execute on Linux

quiz2c - Multiple-Choice Quiz game

'quiz2c' is a multiple choice quiz game that allows you to choose any 1 of several quiz files provided. 'quiz2c' was inspired by my grandson; I was searching for some quiz games written in the C programming language that might interest him. I found one (quiz1c) that had the questions & choices hard-coded within the program, which of course is very limited, so I wrote quiz2c.c which allows an unlimited number of quizfiles.

We currently provide 51 quizfiles to choose from, and will be adding more. Our best source of quiz games is jetpunk.com which bills itself as the world's premiere source of quiz games. Their multi-choice quiz games have a very consistent format that we can download & convert to the format required for our quiz2c program.

You can play the quiz games for free on jetpunk.com using just your web browser. Why did I spend considerable time & effort writing quiz2c.c (2500 line C progam) ?

Besides wanting a program that would inspire my grand-children to learn programming I wanted to have complete control over the quiz-games available & capture the results of playing the games. We capture the results in files identifying the player-name, quiz-file-name, correct answers, total questions, & %percent correct.

We can hold tournaments with several players & create Total reports with results by player for each quizfile & totals by player with %percentages correct.

I can provide a userid & password to my grand-children & other interested friends for them to login & play the game. All they need is the 'ssh' (secure shell) program which is standard software on Windows 10, Mac, Unix or Linux system. I also thought it might be fun for my UV Software clients & prospects.

See www.uvsoftware.ca/uvdemos1.htm#9X9, if you are interested in creating your own quizfiles by downloading from various internet sites & reformatting with the uvcopy tools provided. And/Or you can make up your own quizfiles in an easy to edit format & reformat with the uvcopy jobs provided.

You can run all this on the website with your userid/password, or if you wanted to use quiz2c as a training tool in your organization or School, you could download the UV Software Vancouver Utilities for installation on your own Unix/Linux machine.

quiz2c Feature Summary

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

3A2. Quiz Files Available

Here are the quiz files available for the quiz2c game as of April 2021. Most have been downloaded from jetpunk.com & reformatted for quiz2c & some have been madeup.


 quiz2c FileName                Original Filename on internet of made-up
 ==============================================================================================
 # Animals01           www.jetpunk.com/quizzes/multiple-choice-animal-quiz
 # Animals02           www.jetpunk.com/user-quizzes/176412/life-span-of-animals-multiple-choice
 # Animals03           www.jetpunk.com/user-quizzes/273453/national-animal-by-country-multiple-ch
 # Canada01            www.jetpunk.com/quizzes/canada-multiple-choice-quiz
 # CapitalCities01     www.jetpunk.com/user-quizzes/286897/capitals-of-north-america-multiple-cho
 # CapitalCities02     www.jetpunk.com/user-quizzes/272573/capital-superlatives-multiple-choice
 # Cities01            www.jetpunk.com/user-quizzes/192614/largest-city-multiple-choice
 # Economics01         www.jetpunk.com/user-quizzes/40253/economics-multiple-choice
 # EuropeCapitals01    www.jetpunk.com/user-quizzes/261734/european-capitals-multiple-choice-quiz
 # General01           www.jetpunk.com/quizzes/multiple-choice-general-knowledge-1
 # General02           www.jetpunk.com/quizzes/multiple-choice-general-knowledge-2
 # General03           www.jetpunk.com/quizzes/multiple-choice-general-knowledge-3
 # Geography01         www.jetpunk.com/quizzes/multiple-choice-geography-1
 # Geography02         www.jetpunk.com/quizzes/multiple-choice-geography-2
 # Geography03         www.jetpunk.com/quizzes/multiple-choice-geography-3
 # Harrypotter01       www.jetpunk.com/user-quizzes/149007/harry-potter-multiple-choice
 # History01           www.jetpunk.com/quizzes/history-multiple-choice-1
 # History02           www.jetpunk.com/quizzes/history-multiple-choice-2
 # History03           www.jetpunk.com/quizzes/history-multiple-choice-3
 # HumanBiology02      www.jetpunk.com/user-quizzes/290321/human-biology-multiple-choice-quiz-2
 # HumanBiology03      www.jetpunk.com/user-quizzes/290321/human-biology-multiple-choice-quiz-3
 # Humanbiology01      www.jetpunk.com/user-quizzes/290321/human-biology-multiple-choice-quiz-1
 # Math01              www.jetpunk.com/user-quizzes/176412/mathematics-multiple-choice-1
 # NumberOfThings01    www.jetpunk.com/user-quizzes/145559/number-of-things-multiple-choice
 # ProvinceCapitals01  www.BernatMadeThisQuizThisIsNotAWebsiteButIHaveToPutwww.Something
 # Science01           www.jetpunk.com/quizzes/science-multiple-choice-1
 # Science02           www.jetpunk.com/quizzes/science-multiple-choice-2
 # Science03           www.jetpunk.com/user-quizzes/272573/science-general-knowledge-multiple-cho
 # Science04           www.jetpunk.com/user-quizzes/272573/science-general-knowledge-multiple-cho
 # Space01             www.jetpunk.com/user-quizzes/331477/space-multiple-choice
 # Space02             www.jetpunk.com/user-quizzes/331477/space-multiple-choice-2
 # Space03             www.jetpunk.com/user-quizzes/331477/space-multiple-choice-3
 # Space04             www.jetpunk.com/user-quizzes/331477/space-multiple-choice-4
 # StarWars02          www.jetpunk.com/user-quizzes/121311/star-wars-quotes-multiple-choice-quiz
 # Starwars01          www.jetpunk.com/user-quizzes/305270/star-wars-quiz-multiple-choice
 # StateCapitals01     www.jetpunk.com/user-quizzes/252568/us-state-capitol-multiple-choice
 # Tomhanks01          www.jetpunk.com/user-quizzes/50150/tom-hanks-movies-multiple-choice
 # Ushistory01         www.jetpunk.com/user-quizzes/204335/us-history-multiple-choice-1
 # Uspresidents01      www.jetpunk.com/quizzes/us-presidential-knowledge-multiple-choice
 # WeatherClimate01    www.jetpunk.com/user-quizzes/204335/weather-and-climate-multiple-choice
 # WhatColor01         www.jetpunk.com/quizzes/what-color-is-it-multiple-choice
 # WhichCity02         www.jetpunk.com/user-quizzes/273453/city-by-question-2
 # WhichCountry01      www.jetpunk.com/user-quizzes/273453/country-by-question
 # WhichCountry02      www.jetpunk.com/user-quizzes/273453/country-by-question-2
 # WhichCountry03      www.jetpunk.com/user-quizzes/273453/country-by-question-3
 # WhichCountry04      www.jetpunk.com/user-quizzes/273453/country-by-question-4
 # WhichState01        www.jetpunk.com/user-quizzes/1365040/usa-states-multiple-choice-quiz-2020
 # WhichState03        www.jetpunk.com/user-quizzes/162493/which-state-multiple-choice-quiz
 # Words01             www.jetpunk.com/user-quizzes/176412/which-word-fits-multiple-choice
 # WorldCapitals01     www.jetpunk.com/user-quizzes/155536/multiple-choice-world-capitals
 # WorldWar201         www.jetpunk.com/quizzes/world-war-ii-multiple-choice

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

3A3. Quiz Files Available

can play quizfiles on jetpunk.com

You can play the quizfiles on the originating website (jetpunk.com) using "GUI" (Graphical User Interface) on any internet browser. This might be best for people who have no interest in learning "CLI" (Command Line Interface) required to play quiz2c using 'ssh' (Secure Shell - on Windows10, Mac, linux).

Note that if you access this documentation on the UV Software website at www.uvsoftware.ca/uvdemos1.htm#3A2, you can highlight/capture the URL of a quiz you want to play & paste it into a new tab on your browser.

Advantages of quiz2c vs internet quizzes

  1. quiz2c captures "Result files" of questions, Choices, Answers, counts of correct & wrong answers. You can review files of all Questions or only Quesitons with Wrong answers.

  2. You can hold tournaments & run Total Reports showing %percentages of correct answers by quizfile & summarized by player.

  3. You can download the results files to your own computer.

  4. This documentation is written assuming play on the UV Software website using a guest login userid & password, But on request, you could download the Vancouver Utilities software package to allow you to run quiz2c on your own Linux computer.

  5. You will learn at least some of the "CLI" (Command Line Interface) tools. Could be a great way for parents to get their children interested in learning more about computers & might lead to a career in computer programming.

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

3B1. quiz2c - Multiple-Choice Quiz game

just Play the game OR Learn how it works ?

If you just want to "Play the Game" - follow the instructions on this page '3B1'. to login & start the game, then jump to page '3C2' to see an example of 2 players playing 2 quizfiles each, then Reviewing correct & wrong answers, then running the Total Report counts of correct & wrong answers & %percentages by quizfile & by player.

If you want to Learn more about the Directories/Files setup for quiz2c and the Linux command line tools to investigate Directories & Files - then skip page '3B1' and do the investigations on pages '3B2'-3B4, Before playing the game on pages '3C2'-3C6.

just Play the Game - Login

This assumes that UV Software has provided you with a userid/password for access to 1 of several guest logins on UV Software's ISP.


 #1.  ssh uvsoftxx@uvsoftware.ca  <-- your userID (login-name)
      ==========================    - 'uvsoftxx' is your userid (uvsoft01 - uvsoft99)
 #1a. --> yes          <-- enter 'yes' to 1st time prompt at allow connection
          ===
 #1b. --> Run21K@xxx   <-- enter your password at the prompt
          ==========       (xxx is a 3 or 5 digit number)

 #2. cdm --> /home/uvsoftxx/demo (alias cdm='cd $HOME/demo)
     ===

 #3. quiz2c          <-- execute quiz2c omitting the default Results directory
     ======
     ---------------------- Main-Menu ----------------------
         S  - goto Sub-Menu (vs main-menu) after each menu command
              (for faster play when you understand the game)
         N  - prompt to enter player Name for following quiz-games
         N,name - may enter playername after 'N,...' (shortcut)
         F  - list quiz Files available for Play (in demo/quiz2f/...)
         F# - may enter specific quizFile# to be played
          # - numbered 001,002,003,etc But you can specify 1,2,3,etc
         P  - Play the game selected by F# (default 1st in $QUIZFILES)
         P# - may specify max Questions to play (default all Questions in file)
              (P# option for faster testing by game developers)
         R  - list Result filenames (Quizfile,Playername,scores) for today
         R# - may specify seq# of Result file whose contents are to be shown
          # - 1,2,3,etc from most recent game played to oldest today
              (shows Result file contents - Questions/Choices/Answers)
         W# - may also request Result contents only for Wrong Answers
         T  - create Result Totals Summarized by Player with percentage correct
         Z  - list Result filenames in prepation to clear specified Z#
         Z# - clear specified file# (sequence# from  R or Z list)
         H  - Help (Game Info & Recommendations playing quiz2c)
         Q  - Quit
     ------------------- quiz2c Version 20210402 -------------------

If you are just "Playing the game", then skip to page '3C2' to see sample game play commands to select quizfiles, play,& review results.

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

3B2. Playing quiz2c - Instructions & Demo

Learn about Linux Directories/Files Before playing

This page '3B2' - 3B4 is the Alternative to page '3B1' if you want to "Learn" more about the Directories/Files setup for quiz2c & the Linux command line tools you can use to investigate Directories & Files.


 #1.  ssh uvsoftxx@uvsoftware.ca  <-- your userID (login-name)
      ==========================    - 'uvsoftxx' is your userid (uvsoft01 - uvsoft99)
 #1a. --> yes          <-- enter 'yes' to 1st time prompt at allow connection
          ===
 #1b. --> Run21K@xxx   <-- enter your password at the prompt
          ==========       (xxx is a 3 or 5 digit number)

 #2. pwd  <-- Print current Working Directory
     ===   --> /home/uvsoftxx/

 #3. l       <-- list dirs & files in homedir (5 README files & 5 directories)
     ===       - 'l' is defined by alias l='ls -l' (shortens this often used command)
      -rw-r--r--  1 uvsoft02 uvsoft02 2743 Nov 22 20:39 1README_20210323_uvsoftxx_Username
      -rw-r--r--  1 uvsoft02 uvsoft02 3676 Mar 21 15:43 1README_env_profiles
      -rw-r--r--  1 uvsoft02 uvsoft02 3446 Mar 21 15:43 1README_uvsoftware_demos
      drwxr-xr-x 15 uvsoft02 uvsoft02 4096 Mar 21 15:43 appsadm
      drwxr-xr-x 35 uvsoft02 uvsoft02 4096 Mar 21 15:43 demo
      drwxrwxr-x  2 uvsoft02 uvsoft02  132 Mar 21 15:39 upload
      drwxr-xr-x 27 uvsoft02 uvsoft02 4096 Mar 21 15:43 uvadm

'l' (or 'ls -l') shows only the files & directories in the current directory, but not the directories & files in the sub-directories. You might use the 'tree' command to investigate the various Levels of directories & sub-directories.


 #4. tree -L 1   <-- "tree" diagram subdirs/files in current directory /home/uvsoftxx/...
     =========     - Option "-L 1" for top level only
     Note - tree /home/userxx (without option "-L 1") would be 9000 lines long
 /home/userxx/
 |-- 1README_uvsoftware_demos     <-- README files
 |-- appsadm/    <-- administration files (profiles etc)
 |   `
 |** demo/       <-- superdir for UVdemos  <-- WORKING DIRECTORY for demos ***
 |   |--         <-- see relevant subdirs in next tree diagram
 |   `--
 |-- uvadm/      <-- Vancouver Utilities
 |   |--           - uvcopy,uvsort,uvlist,uvhd,etc
 |   `--
 |-- upload/      <-- zip files uploaded from UV Software for unzip here
 |   |-- 20210303_appsadm.zip   - unzipped into |-- appsadm/... above
 |   |-- 20210303_uvadm.zip     - unzipped into |-- uvadm/... above
 |   |-- 20210303_uvdemos.zip   - unzipped into |-- demo/... above

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

3B3. Playing quiz2c - Instructions & Demo

Change to /home/uvsoftxx/demo/... to play the game


 #5. cdm --> /home/uvsoftxx/demo (alias cdm='cd $HOME/demo)
     ===

 #6. pwd  <-- Print current Working Directory
     ===   --> /home/uvsoftxx/demo

 #7. l       <-- list dirs & files in /home/uvsoftxx/demo/... directory
     ===

 #8. tree -L 1   <-- "tree" diagram subdirs/files in current dir /home/uvsoftxx/demo/...
     =========     - Option "-L 1" top level only (about 35 subdirs)
     Note - tree /home/userxx Level 2 about 300 lines, Level 3 about 500 lines

Directories & Files Relevant to quiz2c

 /home/uvsoftxx/
 demo/            <-- showing only subdirs relevant to quiz2c (about 10 of 35)
 |-- 1README_website_demos/
 |-- bin/         <-- Binary executable programs (such as quiz2c)
 |--              <-- omitting about 20 of 35 subdirs
 |--                - retaining only subdirs rlevant to quiz2c game
 |-- quiz2a/      <-- might Archive (copy) quiz2r/... Result files to quiz2a/...
 |-- quiz2d/      <-- quizfile Development (qf0,qf1,qf2,qf3 --> quiz2f/...)
 |-- quiz2f/      <-- quizfiles available (Science01,02,03,etc) $QUIZFILES
 |-- quiz2r/      <-- default Results directory (if not specified on quiz2c command)
 |-- science101/  <-- can specify alternate Results directory --> quiz2c science101 <--
 |--              <-- omitting about 6 of 35 subdirs
 |-- src/         <-- Source programs (such as quiz2c.c)
 |-- tmp/         <-- misc temp files in subdir

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

3B4. Playing quiz2c - Instructions & Demo

demo subdirs relevant to quiz2c


 #9a. tree -L 2   <-- "tree" diagram of dirs/subdirs/files (2 Levels deep)
      =========     - Option "-L 2" for 2 Levels deep
 #9b. tree -L 3   <-- "tree" diagram of dirs/subdirs/files (3 Levels deep)
      =========     - Option "-L 3" for 3 Levels deep
      Note - tree /home/userxx Level 2 about 300 lines, Level 3 about 500 lines
           - would fly by quick, could "pipe to more" if you want to see detail

 #9c. tree -L 3 | more   <-- "pipe to more" to pause on screenfull
      ================     - press space bar to continue to next screen

Here is a combination of Levels 2 & 3 to show dirs/files relevant to quiz2c

 /home/uvsoftxx/    <-- $HOME directory (uvsoftxx is uvsoft01 - uvsoft99)
 demo/                <-- demo (working) directory within $HOME (cdm takes you there)
 |-- bin/
 |   |-- quiz2c*         <-- quiz2c executable (compiled from src/quiz2c.c source)
 |   `-- ...
 |-- quiz2a/             <-- quiz2 Archive directory (optional)
 |   |-- ...               - could save quiz2r/... files here
 |   `-- ...
 |-- quiz2d/             <-- quizfile Development dircetory
 |   |-- qf1/              - quizfiles downloaded from internet
 |   |-- qf2/              - quiz2reforms1 inserts blank lines between Question/Chopices groups
 |   |-- qf2/              - Answers edited onto end of questions
 |   |-- qf3/              - quiz2reforms2 converts to format expected by quiz2c program
 |   `-- tmp
 |-- quiz2f/             <-- quizfiles copied from qf3/... here $QUIZFILES for game play
 |   |-- Science01
 |   |-- Science02       <-- quizfiles used for demo below
 |   |-- Science03         - 51 quizfiles available as of March 2021 & more to come
 |   `--  ...
 |-- quiz2r              <-- quiz Result files (samples from Owen & Bernat game play '3C1' - 3C6
 |   |-- 20210225R         - 3 subdirs for each day (R,T,W)
 |   |   |-- 20210225_072751_Science01_Owen_0011_0016    <-- quiz Results Questions/Choices/Answers
 |   |   `-- 20210225_072933_Science02_Bernat_0012_0016    - date_time_quizfilename_player_corrects_totalQs
 |   |-- 20210225T       <-- Total reports for today
 |   |   `-- 20210225_072703_Totals_Summary_Report       <-- Total reports created here
 |   |-- 20210225W       <-- Wrong Answers for today
 |   |   |-- 20210225_072751_Science01_Owen_0011_0016    <-- quiz Results for Wrong answer ONLY
 |   |   `-- 20210225_072933_Science02_Bernat_0012_0016
 |   `--
 |-- science101/         <-- Parents/Teachers can setup Alternate Result Directories
 |   `--
 |-- src/
 |   |-- quiz2c.c        <-- quiz2c source (C program)
 |   `                     - compiles to bin/quiz2c executable

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

3C1. quiz2c - Multiple-Choice Quiz game

Execute quiz2c - multi-choice quiz game


 quiz2c quiz2r   <-- execute quiz2c specifying Results directory as quiz2r/...
 =============     - quiz2r is the default & can be omitted as shown below:

 quiz2c          <-- execute quiz2c omitting the default Results directory
 ======            - same effect as above - if ./quiz2r is actually present
                   - but will get error message if not

 mkdir quiz2r    <-- could make the Results directory if you get the errmsg
 ============        & want to make the game as simple as possible for children

 mkdir Science101    <-- could make an alternate Results directory if desired
 ================      - Parents/Teachers might want to collect test results

 rmdir quiz2r        <-- could remove the default Results directory
 ============          - to force players to code desired directory
                         so their results are collected where intended

 quiz2c Science101   <-- then players must code on quiz2c execution
 =================     - else get an error-message reminding them
Note
  • at this point when you are getting familiar with quiz2c
  • we suggest you use the default ./quiz2r/ default Results directory
  • see alternate directories later on pages '3E1'-3E4
  • also see downloading more quizfiles from the internet at '3G1'-3G2
    then upload to a UV Software to reformat for quiz2c at '3H1'-3H5
  • could also create your own quizfiles & format as required for quiz2c

 quiz2c      <-- execute the quiz2c multi-choice quiz game
 ======        - displays the main-menu as follows:
     ---------------------- Main-Menu ----------------------
         S  - goto Sub-Menu (vs main-menu) after each menu command
              (for faster play when you understand the game)
         N  - prompt to enter player Name for following quiz-games
         N,name - may enter playername after 'N,...' (shortcut)
         F  - list quiz Files available for Play (in demo/quiz2f/...)
         F# - may enter specific quizFile# to be played
          # - numbered 001,002,003,etc But you can specify 1,2,3,etc
         P  - Play the game selected by F# (default 1st in $QUIZFILES)
         P# - may specify max Questions to play (default all Questions in file)
              (P# option for faster testing by game developers)
         R  - list Result filenames (Quizfile,Playername,scores) for today
         R# - may specify seq# of Result file whose contents are to be shown
          # - 1,2,3,etc from most recent game played to oldest today
              (shows Result file contents - Questions/Choices/Answers)
         W# - may also request Result contents only for Wrong Answers
         T  - create Result Totals Summarized by Player with percentage correct
         Z  - list Result filenames in prepation to clear specified Z#
         Z# - clear specified file# (sequence# from  R or Z list)
         H  - Help (Game Info & Recommendations playing quiz2c)
         Q  - Quit
     ------------------- quiz2c Version 20210402 -------------------

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

3C2. Playing quiz2c - Instructions & Demo

Sample Competition with a Friend


 quiz2c     <-- execute the quiz2c multi-choice quiz game
 ======

We will illustrate results of Owen & Bernat playing 2 games each, and then using the 'T' command to show the results with player totals & %percentages correct.


 s     <-- goto Sub-menu (shorter, faster play)
 ===
 Enter Sub-Menu option here, OR M to goto Main-Menu descriptions
       Sub-Menu options: N N,name F F# P R R# W W# T Z Z# H Q
Note
  • Sub_Menu shown after each command
  • but we will omit on commands below to save space in this documentation

1st player (Owen) playing 1st game (Science01)


 n   - enter your name: Owen
 ===                    ====

 f   - see quizfiles available
 ===
           ----- quizfilenames in $QUIZFILES (/home/uvadm/demo/quiz2f/...) -----
 001 Animals01           002 Animals02           003 Animals03           004 Canada01
 005 CapitalCities01     006 CapitalCities02     007 Cities01            008 Economics01
 009 EuropeCapitals01    010 General01           011 General02           012 General03
 013 Geography01         014 Geography02         015 Geography03         016 Harrypotter01
 017 History01           018 History02           019 History03           020 HumanBiology02
 021 HumanBiology03      022 Humanbiology01      023 Math01              024 NumberOfThings01
 025 ProvinceCapitals01  026 Science01           027 Science02           028 Science03
 029 Science04           030 Space01             031 Space02             032 Space03
 033 Space04             034 StarWars02          035 Starwars01          036 StateCapitals01
 037 Tomhanks01          038 Ushistory01         039 Uspresidents01      040 WeatherClimate01
 041 WhatColor01         042 WhichCity02         043 WhichCountry01      044 WhichCountry02
 045 WhichCountry03      046 WhichCountry04      047 WhichState01        048 Whichstate01
 049 Words01             050 WorldCapitals01     051 WorldWar201

---> Enter 'F#' of quiz file to play

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

3C3. Sample Competition with a Friend

1st player playing 1st game


 f26 - select file #26 Science01
 ===
 ---> quizfile selected: /home/uvadm/demo/quiz2f/Science01

 p   - Play the game
 ===
 ---> Owen playing quizgame Science01 with 016 Questions
 Q#01.  Which is the heaviest planet in our solar system
 --->A. Earth
 --->B. Mars
 --->C. Jupiter
 --->D. Saturn  c
        -----> Correct Answer="C", Your Answer="C" ---> Correct +1 = 0000
 Q#02.  What do herpetologists study?
 --->A. Blood
 --->B. Herpes
 --->C. Insects
 --->D. Reptiles and amphibians  b
        -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********
Q#03.
  • showing only 1st 2 Questions to save space in this documentation
 ***EOG - Results written to quiz2r/20210225R/20210225_072751_Science01_Owen_0011_0016
        - Your correct% = 066 (66-70%) - Average Score.

1st player playing 2nd game


 f27 - select Science02 (27th File)
 ===
 p   - Play the game
 ===
 ---> Owen playing quizgame Science02 with 016 Questions
 Q#01.  Which of these planets is the biggest?
 --->A. Earth
 --->B. Mars
 --->C. Mercury
 --->D. Venus  a
        -----> Correct Answer="A", Your Answer="A" --->  Correct +1 = 0000
 Q#02.  About what percent of the Earth's atmosphere is Oxygen?
 --->A. 0.4%
 --->B. 21%
 --->C. 90%  b
        -----> Correct Answer="B", Your Answer="B" --->  Correct +1 = 0001
Q#03.
  • showing only 1st 2 Questions to save space in this documentation
 ***EOG - Results written to quiz2r/20210225R/20210225_072836_Science02_Owen_0008_0016
        - Your correct% = 050 (46-50%) - You're in for credit rescue!

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

3C4. Sample Competition with a Friend

2nd player playing 1st game

2nd player to play same games & then check Totals report with %percentage correct


 n
 ===
 Enter your name: Bernat
                  ======
 Enter Sub-Menu option here, OR M to goto Main-Menu descriptions
       Sub-Menu options: N N,name F F# P R R# W W# T Z Z# H Q

f26 ---> quizfile selected: /home/uvdebug/demo/quiz2f/Science01

p ---> Bernat playing quizgame Science01 with 016 Questions

 Q#01.  Which is the heaviest planet in our solar system
 --->A. Earth
 --->B. Mars
 --->C. Jupiter
 --->D. Saturn  c
        -----> Correct Answer="C", Your Answer="C" ---> Correct +1 = 0000
Q#02.
  • showing only 1st Question to save space in this documentation
 ***EOG - Results written to quiz2r/20210225R/20210225_072911_Science01_Bernat_0016_0016
        - Your correct% = 100 (100%) Perfect Score!!!

2nd player playing 2nd game

f27 ---> quizfile selected: /home/uvdebug/demo/quiz2f/Science02

p ---> Bernat playing quizgame Science02 with 016 Questions

 Q#01.  Which of these planets is the biggest?
 --->A. Earth
 --->B. Mars
 --->C. Mercury
 --->D. Venus  a
        -----> Correct Answer="A", Your Answer="A" --->  Correct +1 = 0000
Q#02.
  • showing only 1st Question to save space in this documentation
 ***EOG - Results written to quiz2r/20210225R/20210225_072933_Science02_Bernat_0012_0016
        - Your correct% = 075 (71-75%) - Good Job!

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

3C5. Sample Competition with a Friend

Check Results of games played today


 r    <-- to list Result file contents (Questions/Choices/Answers)
 ===
 001 - quiz2r/20210225R/20210225_072751_Science01_Owen_0011_0016
 002 - quiz2r/20210225R/20210225_072836_Science02_Owen_0008_0016
 003 - quiz2r/20210225R/20210225_072911_Science01_Bernat_0016_0016
 004 - quiz2r/20210225R/20210225_072933_Science02_Bernat_0012_0016
 ---> Enter 'R#' to list the contents of all answers in a Results file
         or 'W#' to list only the Wrong answers in a Results file

 r1  <-- to list contents of Result file #1
 ===
 ##BOF: All Results quiz2r/20210225R/20210225_072751_Science01_Owen_0011_0016
 Q#01.  Which is the heaviest planet in our solar system
 --->A. Earth
 --->B. Mars
 --->C. Jupiter
 --->D. Saturn
 A#01.  -----> Correct Answer="C", Your Answer="C" --->  Correct +1 = 0000
 Q#02.  What do herpetologists study?
 --->A. Blood
 --->B. Herpes
 --->C. Insects
 --->D. Reptiles and amphibians
 A#02.  -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********
Q#03.
  • showing only 1st 2 Questions to save space in this documentation
 ##EOF: All Results quiz2r/20210225R/20210225_072751_Science01_Owen_0011_0016
        Your correct% = 066 (66-70%) - Average Score.

Check Results - ONLY for Questions with WRONG answers


 w1  <-- show results ONLY for questions with Wrong answers
 ===
 Q#02.  What do herpetologists study?
 --->A. Blood
 --->B. Herpes
 --->C. Insects
 --->D. Reptiles and amphibians
 A#02.  -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********
 ##EOF: Wrong results quiz2r/20210225W/20210225_072751_Science01_Owen_0011_0016
        Your correct% = 066 (66-70%) - Average Score.

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

3C6. Sample Competition with a Friend

Check Totals by Player with %percentage Correct


 t    <-- show Totals report
 ===
 ----- quiz2r/20210225T/20210225_072703_Totals_Summary_Report -----
 ==================================================================
 20210225_072911_Science01_Bernat_0016_0016  100%
 20210225_072933_Science02_Bernat_0012_0016  075%
                                    0028_0032  085%
 20210225_072751_Science01_Owen_0011_0016  066%
 20210225_072836_Science02_Owen_0008_0016  050%
                                  0019_0032  057%
 Totals for all players --------> 0047_0064  071%

suggestions for Tournament play

 Groups of players to play the same number of games
 - suggest the 4 science games to start, then decide on others
 - 51 games available as of April 2021 & more to come
 - then run the 'T' command to check totals & %percentages by player

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

3D1. quiz2c - Multiple-Choice Quiz game

Tournament Play - Concise Game Plan

We will illustrate results of Owen & Bernat playing 2 games each, and then using the 'T' command to show the results with player totals & %percentages correct. Assuming already logged in with ssh, password,& cdm --> /home/uvsoftxx/demo/...


 s     <-- goto Sub-menu (shorter, faster play)
 ===
 Enter Sub-Menu option here, OR M to goto Main-Menu descriptions
       Sub-Menu options: N N,name F F# P R R# W W# T Z Z# H Q

1st player (Owen)


 n   - enter your name: Owen
 ===                    ====
 f   - see quizfiles available
 ===
           ----- quizfilenames in $QUIZFILES (/home/uvadm/demo/quiz2f/...) -----
 001 Animals01           002 Animals02           003 Animals03           004 Canada01
 005 CapitalCities01     006 CapitalCities02     007 Cities01            008 Economics01
 009 EuropeCapitals01    010 General01           011 General02           012 General03
 013 Geography01         014 Geography02         015 Geography03         016 Harrypotter01
 017 History01           018 History02           019 History03           020 HumanBiology02
 021 HumanBiology03      022 Humanbiology01      023 Math01              024 NumberOfThings01
 025 ProvinceCapitals01  026 Science01           027 Science02           028 Science03
 029 Science04           030 Space01             031 Space02             032 Space03
 033 Space04             034 StarWars02          035 Starwars01          036 StateCapitals01
 037 Tomhanks01          038 Ushistory01         039 Uspresidents01      040 WeatherClimate01
 041 WhatColor01         042 WhichCity02         043 WhichCountry01      044 WhichCountry02
 045 WhichCountry03      046 WhichCountry04      047 WhichState01        048 Whichstate01
 049 Words01             050 WorldCapitals01     051 WorldWar201

 f26 - select file #26 Science01 (Owen's 1st game)
 ===
 p   - Play quizfile Science01
 === - Questions/Choices/Answers omitted for this game plam summary

 f27 - select file #27 Science02 (Owen's 2nd game)
 ===
 p   - Play quizfile Science02
 ===

2nd player (Bernat)


 n   - enter your name: Bernat
 ===                    ======
 f26 - select file #26 Science01 (Bernat's 1st game)
 ===
 p   - Play quizfile Science01
 === - Questions/Choices/Answers omitted for this game plam summary

 f27 - select file #27 Science02 (Bernat's 2nd game)
 ===
 p   - Play quizfile Science02
 ===

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

3D2. Tournament Play - Concise Game Plan - Results

show Totals Report with %percentage correct


 t    <-- show Totals report
 ===
 ----- quiz2r/20210225T/20210225_072703_Totals_Summary_Report -----
 ==================================================================
 20210225_072911_Science01_Bernat_0016_0016  100%
 20210225_072933_Science02_Bernat_0012_0016  075%
                                    0028_0032  085%
 20210225_072751_Science01_Owen_0011_0016  066%
 20210225_072836_Science02_Owen_0008_0016  050%
                                  0019_0032  057%
 Totals for all players --------> 0047_0064  071%

Check Results of games played today


 r    <-- to list Result file contents (Questions/Choices/Answers)
 ===
 001 - quiz2r/20210225R/20210225_072751_Science01_Owen_0011_0016
 002 - quiz2r/20210225R/20210225_072836_Science02_Owen_0008_0016
 003 - quiz2r/20210225R/20210225_072911_Science01_Bernat_0016_0016
 004 - quiz2r/20210225R/20210225_072933_Science02_Bernat_0012_0016
 ---> Enter 'R#' to list the contents of all answers in a Results file
         or 'W#' to list only the Wrong answers in a Results file

Example - for WRONG answers in Owen's 1st game


 w1  <-- show results only for questions with Wrong answers
 ===
 Q#02.  What do herpetologists study?
 --->A. Blood
 --->B. Herpes
 --->C. Insects
 --->D. Reptiles and amphibians
 A#02.  -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********

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

3D3. Tournament Play - Concise Game Plans

Notes to Parents

You could write up a game plan (see example on page '3D1'), modify, print, & assign to your children/students - modified with quizfiles that you want them to play. You could write the game comands concisely in horizontal format, for example:


 quiz2c s n,owen f f26 p f27 p t r w1 w2
 =======================================

 quiz2c s n,bernat f f26 p f27 p t r w3 w4
 =========================================

Notes to Teachers

Teachers could collect Result files in a specific directory (vs default quiz2r/...) named appropriately. Create it & direct students to code it on quiz2c, for example:


 mkdir science101    <-- create an alternate Results directory
 ================        vs default quiz2r/...

 quiz2c science101   <-- direct students to code alternate on quiz2c ... command
 =================

Forcing students to specify directory


 quiz2c        <-- when no argument coded, results directory defaults to ./quiz2r
 ======

 rm -rf quiz2r      <-- you can remove quiz2r so students will get an error-message
 =============        - reminding them to code the directory on the quiz2c command

 quiz2c science101  <-- specify appropriate directory to collect Result files
 =================

Creating more quizfiles for quiz2c

If you wish to Download & convert more quizfiles from the internet to the format required for quiz2c, you will need to understand more about the directories & procedures required - see following sections '3E1'-3E4 (Understanding Directories) & '3G1'-3H5 (Downloading/Reformatting new quizfiles for quiz2c).

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

3E1. quiz2c - Multiple-Choice Quiz game

quiz2 Facts you "Need to Know"

Here are things you "Need to Know" & "Must Understand", especially for group play with friends & family or if you are a parent/teacher directing your children/students. We assume you are logged in with your assigned userid & password as follows:


 ssh uvsoftxx@uvsoftware.ca  <-- login with your assigned userid & password
 ==========================
 cdm --> /home/uvsoftxx/demo/...  (alias cdm='cd $HOME/demo)
 ===

You might list the subdirs within $HOME/demo or show the directory tree diagrams, which would be 600 lines long if all Levels shown, BUT for this documentation, We will show a selection of a the relevant dirs/files from 1st 3 Levels, to help you understand how quiz2c stores the results files & how you could investigate, save, or download to your computer if desired.


 l            <-- list the directories within the $HOME/demo/... working directory
 ===            - results not shown (similar to the 'tree' results below)

 tree -L 1    <-- show directory tree diagram for 1st level (35 lines)
 =========
 tree -L 2    <-- show directory tree diagram for 2nd level (300 lines)
 =========      - stripped down version shown below
 tree -L 3    <-- show directory tree diagram for 2nd level (600 lines)
 =========      - will show selected/sample/relevant dirs/files from 3 Levels
 /home/uvsoftxx/    <-- $HOME directory (uvsoftxx is uvsoft01 - uvsoft99)
 demo/                <-- demo (working) directory within $HOME (cdm takes you there)
 |--                    - showing only Level 1 of tree diagram (all Levels = 600 lines)
 |-- 1README
 |-- bin/quiz2c      <-- quiz2c compiled executable program
 |-- ...               - 16 subdirs omitted
 |--
 |-- quiz2a/         <-- Archive directory, could save quiz2r/... files here (optional)
 |-- quiz2d/         <-- quizfile Development directory (players do not need to know)
 |-- quiz2f/         <-- quizfiles copied from quiz2d/qf3/... here for game play ($QUIZFILES)
 |--
 |** quiz2r          <-- quiz Result files collected here <-- FOCUS of this "NEED to KNOW"
 |--
 |-- ...               - 8 subdirs omitted
 |-- src/quiz2c.c    <-- quiz2c source C program (compiled into bin/quiz2c)

quiz2 Facts you Need to Know

You do not need to know anything from here on in the quiz2 documentation, If all you want to do is "Play the game" as documented on pages '3B1' - 3C4. That might apply to children, but Parents/Teachers might want to know more (so read on).

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

3E2. quiz2 Facts you Need to Know

quiz2c stores Result files in ./quiz2r/... by default


 #1. quiz2c stores Result files in date stamped subdirs within quiz2r/...
     ====================================================================
     By default, but an alternate Results directory may be specified on the command line:

      quiz2c        <-- Executing quiz2c with no Results Directory specified DEFAULTs
      ======          - to storing results in quiz2r/... within the current directory
                        which is normally /home/uvsoftxx/demo/quiz2r/...

      quiz2c quiz2r   <-- omitting the directory is the same as this
      =============     - if ./quiz2r absent, you get an ERROR message & prompt to
                        - specify an alternate or 'mkdir quiz2r' & re-ececute with no arg1

      quiz2c science101  <-- may specify an alternate directory to collect Result files
      =================    - parents/teachers might use for different groups or classes
                             & remove quiz2r/ to avoid unintended default to quiz2r/...

 #2. quiz2c sets up new date stamped subdirs for each day & stores date/time stamped files within.
     =============================================================================================

For example, if Owen & Bernat each play 2 quizfiles (Science01 & Science02) on Apr 01/2021, the Results will be:

      quiz2r              <-- quiz Result files (samples from Owen & Bernat game play '3C1' - 3C6
      |-- 20210401R         - 3 subdirs for each day (R,T,W)
      |   |-- 20210401_072751_Science01_Owen_0011_0016    <-- quiz Result files TIME stamped
      |   |-- 20210401_072836_Science02_Owen_0008_0016      - All Questions/Choices/Answers
      |   |-- 20210401_072911_Science01_Bernat_0016_0016
      |   `-- 20210401_072933_Science02_Bernat_0012_0016
      |
      |-- 20210401T       <-- Total reports for today
      |   `-- 20210401_073045_Totals_Summary_Report       <-- Total reports created here
      |
      |-- 20210401W       <-- Wrong Answers for today
      |   |-- 20210401_072751_Science01_Owen_0011_0016    <-- Questions/Choices/Answers
      |   |-- 20210401_072836_Science02_Owen_0008_0016      - ONLY for Wrong Answers
      |   |-- 20210401_072911_Science01_Bernat_0016_0016
      |   `-- 20210401_072933_Science02_Bernat_0012_0016

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

3E3. quiz2 Facts you Need to Know

Combining Results from Prior days into Today's Results


 #3. The fact that "quiz2c sets up new date stamped directories/files for each day" means:

     You will see Result files & Total reports only for the CURRENT DAY
     ==================================================================
      Assume that Anik plays the same 2 quiz games on Apr 02 & we want to combine yesterdays
      results into today's, so we can run the Totals report. Anik's results might be as follows:
      quiz2r              <-- quiz Result files (Anik playing same 2 games on Apr 02/2021)
      |-- 20210402R         - 3 subdirs for each day (R,T,W)
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- quiz Result files TIME stamped
      |   |-- 20210402_092836_Science02_Anik_0010_0016      - All Questions/Choices/Answers
      |
      |-- 20210402T       <-- Total reports for today
      |   `-- 20210402_093203_Totals_Summary_Report       <-- Total reports created here
      |
      |-- 20210402W       <-- Wrong Answers for today
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- Questions/Choices/Answers
      |   |-- 20210402_092836_Science02_Anik_0010_0016      - ONLY for Wrong Answers

 #4. quiz2combine quiz2r    <-- combine prior days results into today's results
     ===================

Results from Prior days combined into Today's Results

      quiz2r              <-- quiz Result files (samples from Owen & Bernat game play '3C1' - 3C6
      |-- 20210402R         - 3 subdirs for each day (R,T,W)
      |   |-- 20210401_072751_Science01_Owen_0010_0016    <-- Owen's Results (yesterday)
      |   |-- 20210401_072836_Science02_Owen_0008_0016
      |   |-- 20210401_072911_Science01_Bernat_0016_0016  <-- Bernat's Results (yesterday)
      |   |-- 20210401_072933_Science02_Bernat_0012_0016
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- Anik's Results (today)
      |   `-- 20210402_092836_Science02_Anik_0008_0016
      |
      |-- 20210402T       <-- Total reports for today
      |   |-- 20210401_073045_Totals_Summary_Report       <-- Total reports created here
      |   `-- 20210402_093203_Totals_Summary_Report       <-- New Total report
      |
      |-- 20210402W       <-- Wrong Answers for today
      |   |-- 20210401_072751_Science01_Owen_0011_0016    <-- Owen's Wrong Results yesterday
      |   |-- 20210401_072836_Science02_Owen_0008_0016
      |   |-- 20210401_072911_Science01_Bernat_0016_0016  <-- Bernat's Wrong Results yesterday
      |   |-- 20210401_072933_Science02_Bernat_0012_0016
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- Anik's Wrong Results today
      |   `-- 20210402_092836_Science02_Anik_0010_0016

Script 'quiz2combine' is provided to combine results for multi-day tournaments. Without quiz2combine, you would only see Results for the current day, when you use commands r,r#,w#,& t to see reports of corrects/wrongs & %percent correct.

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

3E4. quiz2 Facts you Need to Know

Total report re-run for all 3 players


 #5. quiz2c quiz2r   <-- Execute quiz2c to run the Total report
     =============

 #5a. t      <-- Re-Run Total report for all 3 players combined
     ====

      ----- quiz2r/20210403T/20210403_115744_Totals_Summary_Report -----
      ==================================================================
      20210402_115114_Science01_Anik_0012_0016  075%
      20210402_115435_Science02_Anik_0008_0016  050%
                                     0020_0032  062%
      20210401_163905_Science01_Bernat_0016_0016  100%
      20210401_163937_Science02_Bernat_0012_0016  075%
                                       0028_0032  087%
      20210401_163826_Science01_Owen_0010_0016  066%
      20210401_163846_Science02_Owen_0008_0016  050%
                                     0018_0032  056%
      Totals for all players ------> 0066_0096  068%

add players over multiple days & rerun quiz2combine

You could have several players add their results to quiz2r/... over multiple days & run 'quiz2combine' several times to see the combined results. Each days players would only see their results on the day they play, until quiz2combine is rerun to consolidate all results to the last day.

Clear quiz2r/* after player tournament ended


 #6. You will want to clear quiz2r/* after all players in a tournament have played
     & you have run the final Total reports & handed out the prize money.
     Because you would want to clear the prior tournament results before you start
     the next tournament (or student class tests). You might want to save (archive)
     the current results - before clearing & starting a new tournament.

 #6a. cp -r quiz2r/* quiz2a/  <-- copy/save quiz2r/ results to archive directory
      ======================    - could be named as desired

 #6b. rm -rf quiz2r/*    <-- remove all subdirs/files from qui2r/...
      ===============      - before beginning next tournament (or class test)

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

3E5. quiz2 Facts you Need to Know

Check Results for specified Day before combining all Days

The tournament play above used the script 'quiz2combine' (#4 on page '3E3') to combine results from all prior days into 1 set of results for today.

quiz2combine is necessary because the default is to show results only for the current day. This behaviour simplifies things for beginners who might be confused by seeing today's results mixed in with prior days play of other players.

But if desired, you can specify a prior day's results to be displayed. For example the quiz2r/... contents would be as follows prior to the quiz2combine #6 on page '3E3':

      quiz2r          <-- quiz Results from Owen & Bernat play on 20210401 (April 01/2021)
      |-- 20210401R         - 3 subdirs for each day (R,T,W)
      |   |-- 20210401_072751_Science01_Owen_0011_0016    <-- Result files date/time stamped
      |   |-- 20210401_072836_Science02_Owen_0008_0016      - All Questions/Choices/Answers
      |   |-- 20210401_072911_Science01_Bernat_0016_0016
      |   `-- 20210401_072933_Science02_Bernat_0012_0016
      |
      |-- 20210401W   <-- Wrong Answers for 20210401
      |   |-- 20210401_072751_Science01_Owen_0011_0016    <-- Questions/Choices/Answers
      |   |-- 20210401_072836_Science02_Owen_0008_0016      - ONLY for Wrong Answers
      |   |-- 20210401_072911_Science01_Bernat_0016_0016
      |   |-- 20210401_072933_Science02_Bernat_0012_0016
      |   `
      |-- 20210402R   <-- quiz Results from Anik's play on 20210402 (April 02/2021)
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- Result files date/time stamped
      |   |-- 20210402_092836_Science02_Anik_0010_0016      - All Questions/Choices/Answers
      |
      |-- 20210402W   <-- Wrong Answers for 20210402
      |   |-- 20210402_092751_Science01_Anik_0012_0016    <-- Questions/Choices/Answers
      |   |-- 20210402_092836_Science02_Anik_0010_0016      - ONLY for Wrong Answers

 #1. quiz2c quiz2r/20210401  <-- will show results only for 20210401 (Owen & Bernat)
     ======================
      - can run whatever commands desired, for example:
      --> t    <-- show Total report (only for 20210401 (Owen & Bernat)
      --> r    <-- list Result files R & W
      --> w1   <-- show Wrong results for 20210401 1st quiz (JOScience01)

 #2. quiz2c quiz2r/20210402  <-- will show results only for 20210402 (Anik)
     ======================
      - can run whatever commands desired, for example:
      --> t    <-- show Total report (only for 20210402 (Anik)
      --> r    <-- list Result files R & W
      --> w2   <-- show Wrong results for 20210402 2nd quiz (JOScience02)

 #3. quiz2combine quiz2r   <-- could then combine results
     ===================
      --> results would be as shown on under #4 on page '3E3'
      --> t    <-- show Total report (for all 3 players combined)
                 - results as shown under #5 on page '3E4'

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

3F1. quiz2c - Multiple-Choice Quiz game

Quiz File Management for Teachers

The following is intended to help you understand the directories/files used by quiz2c in case you want to save quiz results. Teachers could create their own quizzes for quiz2 & might need to save results for discussing with students, etc.


 ssh uvsoftxx@uvsoftware.ca  <-- login with your assigned userid & password
 ==========================
 cdm --> /home/uvsoftxx/demo/...  (alias cdm='cd $HOME/demo)
 ===
 tree  -L 1  --> creates directory tree diagram shown below
 ==========
 Here is the top Level of Directories in the demo/... directory
 - identifying ONLY the directories relevant to the quiz demo
 - see the following page for the files within these quiz directories
 demo
 |-- 1README
 |-- archive/
 |-- backup/
 |-- bin/quiz2c      <-- quiz2c compiled executable program
 |-- dat0/
 |-- dat1/
 |-- dat2/
 |-- dat3/
 |-- dat9/
 |-- errs/
 |-- ftps/
 |-- jcl2/
 |-- jcl3/
 |-- parms/
 |-- pf/
 |-- pfxx/
 |-- pfyy/
 |-- quiz2a/         <-- quiz2 Archive directory
 |-- quiz2d/         <-- quizfile Development dircetory
 |-- quiz2f/         <-- quizfiles copied from qf3/... here $QUIZFILES for game play
 |-- quiz2r/         <-- default directory for collection of quiz results
 |--                   - questions/choices/answers by quizfilename & playername
 |-- science101/     <-- can setup alternate directories to collect quiz results
 |--                   - & remove default quiz2r/ to prevent mistakes
 |-- sf/
 |-- sfxx/
 |-- sfyy/
 |-- sql0/
 |-- sqls/
 |-- src/quiz2c.c    <-- quiz2c source C program
 |-- tf/
 `-- tmp/

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

3F2. Quiz File Management for Teachers

Directories/Files Relevant to quiz2c demos

 /home/uvsoftxx/    <-- $HOME directory (uvsoftxx is uvsoft01 - uvsoft99)
 demo/                <-- demo (working) directory within $HOME (cdm takes you there)
 |-- bin/
 |   |-- quiz2c*         <-- quiz2c executable
 |   `-- ...
 |-- quiz2a/             <-- quiz2 Archive directory
 |--  ...                  - could copy/save quiz2r/... dirs/files here
 |--  ...                  - if you wanted to clear quiz2r/... for future play
 |--  ...
 |-- quiz2d/             <-- quizfile Development dircetory
 |   |-- qf1/              - quizfiles downloaded from internet
 |   |-- qf2/              - quiz2reforms1 inserts blank lines between Question/Chopices groups
 |   |-- qf2/              - edit Answers on end of questions
 |   |-- qf3/              - quiz2reforms2 converts to format expected by quiz2c program
 |   `-- tmp/
 |-- quiz2f/             <-- quizfiles copied from qf3/... here $QUIZFILES for game play
 |   |-- Science01
 |   |-- Science02       <-- quizfiles used for demo below
 |   |-- Science03         - 51 files available as of April 2021 & more to come
 |   `--  ...
 |-- quiz2r/          <-- quiz Result files (DEFAULT directory, remove to force ALTERNATE)
 |   |-- 20210225R/     - 3 subdirs for each day (R,T,W)
 |   |   |-- 20210225_072751_Science01_Owen_0011_0016    <-- quiz Result files TIME stamped
 |   |   |-- 20210225_072836_Science02_Owen_0008_0016      - All Questions/Choices/Answers
 |   |   |-- 20210225_072911_Science01_Bernat_0016_0016
 |   |   `-- 20210225_072933_Science02_Bernat_0012_0016
 |   |
 |   |-- 20210225T/      <-- Total reports for today
 |   |   `-- 20210225_072703_Totals_Summary_Report       <-- Total reports created here
 |   |
 |   |-- 20210225W/      <-- Wrong Answers for today
 |   |   |-- 20210225_072751_Science01_Owen_0011_0016    <-- Questions/Choices/Answers
 |   |   |-- 20210225_072836_Science02_Owen_0008_0016      - ONLY for Wrong Answers
 |   |   |-- 20210225_072911_Science01_Bernat_0016_0016
 |   |   `-- 20210225_072933_Science02_Bernat_0012_0016
 |   |
 |   |-- 20210226R/      <-- files for tomorrow would be:
 |   |   |-- 20210226_072751_Science03_Owen_0002_0003    <-- quiz Result files TIME stamped
 |   |-- 20210226T/      <-- Total reports for tomorrow
 |   |-- 20210226W/      <-- Wrong Answers for today
 |   `--
 |-- science101/     <-- can setup ALTERNATE directories to collect quiz results
 |--                   - & remove default quiz2r/ to prevent mistakes
 |-- src/
 |   |-- quiz2c.c        <-- quiz2c source (C program)
 |   `

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

3F3. Quiz File Management for Teachers

quiz2 Results Directory default ./quiz2r/...


 #1. quiz2r/... default directory where quiz2c writes its Results in quiz2r/subdirs/files.
     On startup quiz2c creates 3 subdirs:
      - yyyymmddR/ for Result files of Questions/Choices/Answers
      - yyyymmddT/ for Total Reports
      - yyyymmddW/ for Result files of Questions/Choices/Answers for Wrong Answers only

 #2. quiz2c writes its output files in these 3 subdirs with date/time stamps, for example:
      |-- quiz2r/
      |   |-- 20210221R/
      |   |   |-- 20210221_214426_Science01_Owen_0012_0016
      |   |-- 20210221T/
      |   |   `-- 20210221_214139_Totals_Summary_Report
      |   |-- 20210221W/
      |   |   |-- 20210221_214426_Science01_Owen_0012_0016
      Before teachers begin a new round of testing they could save the current results
      from quiz2r/... to an archive directory quiz2a/... & Remove files from quiz2r/...
      and run quiz2c to create new Result files in quiz2r/...

 #3. cp -r quiz2r/* quiz2a/  <-- copy prior results to quiz2a/... (archive directory)
     ======================

 #4. rm -rf quiz2r/*   <-- remove any prior results from quiz2r/...
     ===============

 #5. quiz2c           <-- students run quiz2c to create new quiz Result files
     ======

Recommend Teachers REMOVE quiz2r/ default directory

We recommend teachers to remove the quiz2r/ default directory, to force students to specify the Results directory on the command line,& prevent their answers going into quiz2r/... by mistake, for example:


 #6. rm -rf quiz2r          <-- Remove quiz2r DIRECTORY & contents
     =============            - #4 above removed only the contents (not quiz2r itself)

 #7a. mkdir science101      <-- make alternate results directory
      ================

 #7b. mkdir -rf science101  <-- OR remove all files if already present
      ====================

 #8. quiz2c science101      <-- quiz Replies collected in directory science101/...
     =================        - in subdir yyyymmddR/yyyymmdd_HHMMSS_science101_Student1
                                 & subdir yyyymmddW/yyyymmdd_HHMMSS_science101_Student2

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

3F4. Quiz File Management for Teachers

quizzes run over Multiple Days

It might take a few days until all students have responded to the quiz, which would be a problem if we did not provide script 'quizcombine2' to combine results collected over multiple days. To illustrate here is the science101 directory after Student1 did 2 quizzes on April 1 & Student2 did them on April 2:

      |-- science101
      |   |-- 20210401R/
      |   |   |-- 20210401_103100_Science01_Student1_0015_0016
      |   |   |-- 20210401_103400_Science02_Student1_0012_0016
      |   |-- 20210401W/
      |   |   |-- 20210401_103100_Science01_Student1_0015_0016
      |   |   |-- 20210401_103400_Science02_Student1_0012_0016
      |   |-- 20210402R/
      |   |   |-- 20210402_114200_Science01_Student2_0012_0016
      |   |   |-- 20210402_114600_Science02_Student2_0008_0016
      |   |-- 20210402W/
      |   |   |-- 20210402_114200_Science01_Student2_0012_0016
      |   |   |-- 20210402_114600_Science02_Student2_0008_0016

If the teacher inspected results on April 2nd, she would see only the results for Student1, since the system is designed to report results only for the current day.

And if she inspected on April 3rd, she would see no results. System designed this way for convenience of casual players who are usually interested only in the current day results & would not want to bother with clearing old results before they could run current day quizzes.

quiz2combine - script to combine multi-day results to today

Script 'quiz2combine' is provided to combine all results collected over multiple days into 1 set of results dated for the current day (to make visible). Let's assume the teacher runs the quiz2combine script on April 3 at 12:55


 #8. quiz2combine science101  <-- combine results for all quizzes, all students
     =======================      into 1 set dated for today

 #9. tree science101    <-- show directories/files tree diagram
     ===============      - after combining results of quizzes run on multiple days
      |-- science101
      |   |-- 20210403R/
      |   |   |-- 20210401_103100_Science01_Student1_0015_0016
      |   |   |-- 20210401_103400_Science02_Student1_0012_0016
      |   |   |-- 20210402_114200_Science01_Student2_0012_0016
      |   |   `-- 20210402_114600_Science02_Student2_0008_0016
      |   |-- 20210403T/
      |   |   `-- 20210403_125500_Totals_Summary_Report
      |   |-- 20210403W/
      |   |   |-- 20210401_103100_Science01_Student1_0015_0016
      |   |   |-- 20210401_103400_Science02_Student1_0012_0016
      |   |   |-- 20210402_114200_Science01_Student2_0012_0016
      |   |   `-- 20210402_114600_Science02_Student2_0008_0016

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

3F5. Quiz File Management for Teachers

Teacher investigating Results for science101 quiz


 #10.  quiz2c science101    <-- teacher runs quiz2c to see combined results
       =================

 #10a. t        <-- command 't' for Total Report
       ===
       ----- science101/20210403T/20210403_125500_Totals_Summary_Report -----
       ==================================================================
       20210401_103100_Science01_Student1_0015_0016  094%
       20210401_103400_Science02_Student1_0012_0016  075%
                                            0027_0032  085%
       20210402_114200_Science01_Student2_0012_0016  075%
       20210402_114600_Science02_Student2_0008_0016  050%
                                            0020_0032  062%
       Totals for all players -------->     0047_0064  073%

 #10b. r      <-- list All Result files for all students in science101
       ===
       001 - science101/20210401R/20210401_103100_Science01_Student1_0015_0016
       002 - science101/20210401R/20210401_103400_Science02_Student1_0012_0016
       003 - science101/20210402R/20210401_104400_Science01_Student2_0012_0016
       004 - science101/20210402R/20210401_104800_Science02_Student2_0008_0016

 #10c. w1     <-- list Wrong results for quiz Science01 by Student1
       ===
       Q#02.  What do herpetologists study?
       --->A. Blood
       --->B. Herpes
       --->C. Insects
       --->D. Reptiles and amphibians
       A#02.  -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********

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

3F6. Quiz File Management for Teachers

Download quiz Results to your computer

 Teachers/Parents could download quiz results to their own computers as follows
 - assuming that your students have completed the assigned quizzes & the results
 are in directory /home/uvsoftxx/demo/science101/..., you are still logged in
 with 'ssh',& you are still in /home/uvsoftxx/demo/...

 #1.  cd science101   <-- change into the quiz results directory
      =============

 #1a. l    <-- could list result subdirs/files
      ===    - not shown here, same as #9 above
             - could be many more files depending on no of students

 #2. zip -r ../science101_20210403.zip .  <-- zip all files in current directory '.'
     ===================================    - output up 1 level '../sci...' (in demo/)

 #3. exit   <-- exit ssh, so we can log back in with 'sftp'
     ====

 #4.  sftp uvsoftxx@uvsoftware.ca  <-- login with 'sftp' (Secure FTP)
      ===========================
 #4a. --> passwordxx <--

 #5. cd demo  --> /home/uvsoftxx/demo/...
     =======      - can not use alias cdm when logged in with 'sftp' vs 'ssh'

 #6. ls -l    <-- list subdirs within demo/...
     =====      - can not use alias l='ls -l' when logged in with 'sftp' vs 'ssh'
                - contents not shown here (see page '3F1')

 #7. get science101_20210403.zip   <-- get zip file to your computer
     ===========================

 #8. view/print/etc on your computer
     ===============================
      - using whatever tools you wish (Windows, Mac,or Linux)

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

3F7. Quiz File Management for Teachers

Running quiz2 on your computer (vs UV Software website)

Running quiz2 on the UV Software website (using your assigned userid/password) was very easy because all the software required was provided on the website,& all you needed was the 'ssh' utility on your computer (standard on Windows 10).

Running quiz2 on your own computer requires a lot more software on your computer & a lot more knowledge on your part, but we will show you what is required.


 #1. We will assume that you are running Linux on your computer, but note that you
     can run Linux under Windows using what Microsoft calls 'WSL'.

 #2. Download & install the 'Vancouver Utilities' sotware package. UV Software
     can make this package free for teachers & free2try for commercial users.
     See www.uvsoftware.ca/install.htm for download/unzip/install instructions.
     Also see install instructions starting at www.uvsoftware.ca/uvdemos2.htm#1A1
     (simpler & easier to understand)

 #3. Setup your login account/password as desired (we refer to as userxx/passxx).
     Also see user account setup starting at www.uvsoftware.ca/uvdemos2.htm#1C1
     Assuming you are logged in to your homedir on your computer:

 #4. cp -r /home/uvadm/demo .   <-- copy UV Software's demo/* to your homedir
     ========================
Note
  • ALternative - download your demo/* from your UV Software login
  • same as on page '3F6' above, but zip up all of demo/... (vs just science101)
  • do this if you have quiz results on the UV Software website you want to save

Running quiz2 on school servers

If your school has Linux servers or Linux running under WSL, your students should be able to login & complete your assigned quizzes.

And you should be able to consolidate the results & run the Total reports as described above starting at page '3F1'.

Download/Convert &/or Makeup your own quizfiles

You could download desired quizfiles from the internet as shown on page '3G1' & convert to the format required by quiz2c as shown on pages '3H1' - 3H5.

And you could make-up your own quizfiles in the easy format shown on page '3H3' & convert to the format required by quiz2c as shown on pages '3H4' - 3H5.

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

3G1. Download/Create New Quiz Files for quiz2c game

Download & Reformat quiz files for quiz2c

You can find many quiz-files on internet sites (such as jetpunk.com) that can be downloaded & reformatted for the quiz2c game program.

You cannot download directly to your UV Software userid/passord login, but you could download to your computer, upload to your UV Software login, & then run the proceddures socumented here to reformat for quiz2c.

Or if you have downloaded & installed the Vancouver Utilities on your own computer you could do everything on your computer, but installing the package on your computer (documented in uvdemos2.htm#Part_1 or install.htm) is more complex than logging into the UV Software website with your assigned userid/password.

Download to your computer & upload to UV Software guest login

Here is how you can download a new quiz file to your computer, upload it to your UV Software guest login, & reformat for quiz2c. UV Software has already done this for a few quiz files (Science01, Science02, Science03, Science04, etc)

Let's assume you have found another science quiz on the jetpunk.com website at: www.jetpunk.com/quizzes/science-multiple-choice-5 (will rename as Science05).

Use the browser on your computer to select just the text of the questions & multiple choices (highlight with shift & arrow down from question 1 to 16), control-C to capture, goto your files manager (windows or linux), create a new empty file (name it Science03),& control-V to insert the captured text. (we will assume you have created the file in tmp/Science03).

Note
  • Before you can select the text of questions & choices & highlight down,
    you probably will need to goto --> View --> Page-Style --> Nostyle

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

3G2. Download, Upload, & Reformat for quiz2c

Upload quizfile from your computer to UV Software guest login


 #1. quizfile already Downloaded to your computer (as explained above)

 #2. sftp uvsoftxx@uvsoftware.ca   <-- Secure FTP to your guest userid/password
      ==========================
      --> password

 #3. cd demo/quiz2d       <-- change into quiz2d (Development SuperDir for New quiz-files)
     ==============

 #4. ls -l                <-- list subdirs in quiz2d, note qf0/... downloads before conversion
      =====                  - see dirs/files listed on next page

 #5. cd qf0/                - change into qf0/...
     =======

 #6. put tmp/Science05  <-- upload new file into /home/uvsoftxx/demo/quiz2d/qf0/...
     ===================      to be reformatted for quiz2c

 #7. exit                  <-- exit from sftp
     ====

convert internet quizfiles to format required by quiz2c


 #1. ssh uvsoftxx@uvsoftware.ca   <-- Secure SHell on your UV Software guest login account
     ==========================
     --> password

 #2. cd demo/quiz2d/     <-- change into quiz2d (Development SuperDir for New quiz-files)
     ===============
Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3H1. quiz2c - Multiple-Choice Quiz game

Converting quizfiles to the format required by quiz2c


 tree   <-- 'tree' utility to see subdirs/files required to reformat quizfiles
 ====
 /home/uvsoftxx/demo/
 |-- ...                 <-- omitting dirs/files unrelated to quiz2
 |-- bin
 |   |-- quiz2c          <-- binary compiled from src/quiz2c.c
 |   `-- ...                 (other programs not shown)
 |-- quiz2d/             <-- SuperDir for new quiz file download & reformatting
 |   |-- pf/...            - uvcopy jobs to convert downloads
 |   |   |-- quiz2reform1  - uvcopy job inserts blank lines between Questions/Choices groups
 |   |   |-- quiz2reform2  - uvcopy job moves edited answer from Question to separate line
 |   |-- qf0/...           - quiz files downloaded from internet into qf0/...
 |   |   |-- Science01     - insert line 1 with short name & www... URL source
 |   |   |-- Science02     - previously downloaded from internet
 |   |   |-- Science03     - will demo the addition of Science03
 |   |   `
 |   |-- qf1/...           - pre-edit if required for exception websites
 |   |   |-- Science01     - previously downloaded from internet
 |   |   |-- Science03     - demo adding new file
 |   |   `
 |   |-- qf2/...           - script quiz2reforms1 converts from qf1 --> qf2
 |   |   |-- Science01     - inserts blank lines between Question/Choices groups
 |   |   |-- Science03     - edit to append Answer on the end of the Question line
 |   |   `
 |   |-- qf3/...           - script quiz2reforms2 converts from qf2 --> qf3
 |   |   |-- Science01     - moves the answer from end of question to separate record
 |   |   |-- Science03     - so player will not see
 |   |   `
 |-- quiz2f/             <-- quiz Files downloaded & reformatted for quiz2c
 |   |-- Science01         - copied from  quiz2d/qf2/... development directory
 |   |-- Science02           to demo/quiz2f/... for quiz2c game play
 |   |-- Science03         - demo adding new file
 |   `--
 |-- quiz2r/              <-- quiz2 Result files sub-directory
 |   |-- 20210107_202450_Science01_Owen   - result files date/time stamped with player name
 |   |-- 20210107_202541_Science01_Bernat - contain correct/wrong/total counts
 |   |-- 20210107_202715_Science01_Dirk
 |   `--
 |   sf/...               <-- script files directory
 |   |   |-- quiz2reforms1  - script inserts blank lines between Questions/Choices groups
 |   |   |-- quiz2reforms2  - script moves edited answer from Question to separate line
 |   `-- ...
 |-- src                  <-- C source programs
 |   |-- quiz2c.c           - source code for quiz2c
 |   `-- ...                  (other programs not shown)

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

3H2. Download/Create New Quiz Files for quiz2c game

Format Rules for Question file/record input to the 'quiz2c' game

 Question files must begin with 1 or more records with '##' in cols 1 & 2
  - to identify the file-name, source, author, when converted for the quiz2c game
  - We also use these '##' comment records to document the procedures required
  - The '##' records must be followed by a blank line prior to the 1st quiz question
  - each question line is followed by the multiple choice lines
  - groups of 1 question & multi-choice lines must be separated by 1 blank line

File conversions required for quizfiles downloaded from websites

  -------> qf0 --------> qf1 -----------> qf2 ----> qf2 -----------> qf3 ----> /demo/quiz2f/
  download    exception     quiz2reforms1     edit     quiz2reforms2     copy   (for play)
 qf0->qf1 - Download into qf0/..., copy to qf1 before making any changes that may be required
            so that Question lines are distinguishable from Choice lines
 qf1->qf1 - Edit (in place) Only when/if required so quiz2reforms1 can distinguish Question
            lines from Choice lines to insert blank lines between sets of Question/Choices
            as expected by uvcopy quiz2reforms2
          - No changes are required for jetpunk.com files which identify Question lines
            by a sequence# followed by '.' pperod (1. 10. etc)
          - May need manual changes for some other sites
Note
  • see continuation of step by step instructions on page '3H4'
  • first let's understand the directories used to convert internet formats to quiz2c formats
qf1->qf2
  • quiz2reforms1 inserts blank lines between sets of Question/Choices (required by quiz2c)
qf2->qf2
  • Edit (in place) --> Add Answers onto the end of the Question lines
 qf2->qf3 - quiz2reforms2 reformats the records for quiz2c Q#01..., A..., B..., C.etc, A#01. cc=X
          - & moves the Answer to a separate record at end Choices (so player does not see)

See record format samples on the next page of Questions/Choices in subdirs qf0/qf1, qf2,& qf3 for quizfile downloaded from https://www.jetpunk.com/quizzes/science-multiple-choice-1 which we renamed as Science01 & reformatted as required for the 'quiz2c' game

Clarify difference 'uvcopy jobs' vs 'scripts'

A 'script' calling a 'uvcopy job' simplifies the complex command format required by a uvcopy job. Later (on page '3H4') you will be given the choice of running a 'uvcopy job' or a 'script' to do the same processing. For example, here are the 2 ways to process qf1/... files to qf2/...


 #5. uvcopy quiz2reform1,fili1=qf1/quizfilexx,filo1=qf2/quizfilexx
     =============================================================
      - uvcopy job to insert blank lines between groups of Question & Choices lines

--- OR ---> #5a. Alternative to #5. uvcopy job --> script much shorter & easier to enter


 #5a. quiz2reforms1 quizfilexx   <-- only need to enter filename
      ========================     - script knows indir qf1/... & outdir qf2/...

Script 'quiz2reforms1' calls uvcopy job 'quiz2reform1' simplifying the command format (only need to specify the filename once, the script knows to copy from qf1/... to qf2/...). Similarily #7a. 'script' quiz2reforms2 is an easier way to call 'uvcopy job' quiz2reform2. The 's' in quiz2reforms1 & quiz2reforms2 is intended to indicate 'script' vs 'uvcopy job'.

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

3H3. Quizfile Format Conversion Examples

qf0 & qf1 file format - 1st 2 sets of Questions/Choices

 Science01 www.jetpunk.com/quizzes/science-multiple-choice-1 <-- filename & original URL
 1. Which is the heaviest planet in our solar system
 Earth
 Mars
 Jupiter
 Saturn
 2. What do herpetologists study?     <-- No blank lines between sets of Questions/Choices
 Blood
 Herpes
 Insects
 Reptiles and amphibians

qf2 format - after quiz2reforms1 & edit/add cc=? correct answer

 ## Science01 - quizfile from www.jetpunk.com/... renamed to Science01
 ##             - original: www.jetpunk.com/quizzes/science-multiple-choice-1
 ##             - ##comments for filename & website source
 1. Which is the heaviest planet in our solar system ? cc=C <-- append Answer with editor
 Earth
 Mars
 Jupiter
 Saturn
                                          <-- blank lines inserted between Q/C groups
 2. What do herpetologists study? cc=D    <-- Answer coded on end of Question lines
 Blood
 Herpes
 Insects
 Reptiles and amphibians

qf3 format - after quiz2reforms2 moved Answers to separate lines

 ## Science01 - quizfile from www.jetpunk.com/... renamed to Science01
 ##             - original: www.jetpunk.com/quizzes/science-multiple-choice-1
 Q#01.  Which is the heaviest planet in our solar system ? ... Answer removed
 --->A. Earth
 --->B. Mars
 --->C. Jupiter
 --->D. Saturn
 A#01.  -----> Correct Answer="C", Your Answer="?"   <--- Answer on separate record
 Q#02.  What do herpetologists study ?      <-- Answer re-moved from end of Question
 --->A. Blood
 --->B. Herpes
 --->C. Insects
 --->D. Reptiles and amphibians
 A#02.  -----> Correct Answer="B", Your Answer="?"  <-- Answer on separate record
Note
  • we show Answers as UPPER case A,B,C,etc, But easier to enter as lower case
  • quiz2reforms2 will force Answers to UPPER case consistency

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

3H4. Quizfile Conversion Operating Instructions

Convert quizfiles to format required by quiz2c

This assumes quiz files from the internet have been uploaded to your guest login account & stored in $HOME/demo/quiz2/qf0/... (as shown on page '3G2'). Or you could make-up your own quiz file with any editor into the multi-line choice format. We will use 'quizfilexx' as the filename for the instructions below.


 #0a. ssh/login uvsoftxx/userxx  --> your homedir
      =========================
 #0b. cd demo       <-- change to $HOME/demo (or use alias cdm='cd $HOME/demo')
 #0c. cd quiz2d     <-- change into the quizfile Development directory
 #0d. cdqd          <-- Alternative to #0b & #0c, using alias cdqd='cd $HOME/demo/quiz2d'
      ====

 #1. vi qf0/quizfilexx   <-- edit to insert 1st line with short filename & original URL
     =================     - line1 must contain www... or uvcopy quiz2reform1 will fail

 #2. cp qf0/quizfilexx qf1/  <-- copy to qf1/... before making any changes other changes
     ======================      that may be required for input to quiz2reforms1

 #3. vi qf1/quizfilexx   <-- ensure format as expected by quiz2reforms1
     =================
      - Ensure that Question lines are distinguishable from Choice lines
        so quiz2reform1 can insert blank lines between sets of Question/Choices
        as expected by uvcopy quiz2reform2s (no changes required for jetpunk.com files)
      - jetpunk Question lines are identified by sequence# followed by '.' (1. 10. etc)
      - May need manual changes for some sites that do not distinquish Questions/Choices

 #4. quiz2reforms1 quizfilexx  <-- script 'quiz2reforms1' calls uvcopy job 'quiz2reform1'
     ========================
      - 'quizreform1' inserts blank lines between groups of Question & Choices lines
      - also inserts ##comment lines at the begining to document conversions required
      - script 'quizreforms1' simplifies command, only need to enter the filename
        (script knows input subdir is qf1/... & output subdir is qf2/...)
      - see the script listed later on page '3I2'

 #5. vi qf2/quizfilexx  - edit to code the correct answer at the end of question lines
     =================    as cc=A/B/C/etc
      - uvcopy quiz2reform2 will move the 'cc=A/B/C/etc' to a separate record
        so the player will not see (see examples documented above or below)

 #6. quiz2reforms2 quizfilexx  <-- script 'quiz2reforms2' calls uvcopy job 'quiz2reform2'
     ========================
      - 'quiz2reform2' error checks & moves correct answers from end of question lines
        to a separate line so the user will not see
      - see the script listed later on page '3I3'

 #7. quiz2c qf3/quizfilexx  <-- run the quiz2c C program to test reformat OK
     =====================    - will NOT WORK
Note
  • #7 will NOT WORK, because quiz2c expects the quizfile to be in $QUIZFILES/...

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

3H5. Quizfile Conversion Operating Instructions

copy from Development to Deployment


 #8. cp qf3/quizfilexx $QUIZFILES  <-- copy to default directory where quiz2c
     ============================      expects the quizfiles to be
      - QUIZFILES is defined in the .bash_profile as follows:

     export QUIZFILES=$HOME/demo/quiz2f - usual definition of QUIZFILES
     ==================================   in .bash_profile

 #9. cdm  --> /home/uvsoft/demo/   <-- change to the demo directory
     ===

 #10. cp quiz2d/qf3/* quiz2f  <-- alternative to #8 (after cd up to demo/...)
      ======================    - copy ALL quiz2d/qf3/* files to $QUIZFILES
       - better because you may have created several new quizfiles
       - never edit files in quiz2f/... consider quiz2d/qf3/... is the master set

Test your new quizfiles


 #11. quiz2c quizfilexx  <-- run the quiz2c C program to test
      =================      quiz2c finds via $QUIZFILES
                             (not having to specify location)

 #11a. Enter your name ---> Owen  <---
 #11b. Enter no of questions default max in file -->  <--
      --- Welcome screen & Menus omitted (see page '3C1') ---

 #11c. P <-- to Play the game
 Q#01.  Which is the heaviest planet in our solar system
        --->A. Earth
        --->B. Mars
        --->C. Jupiter
        --->D. Saturn
        A#01.  -----> Correct Answer="C", Your Answer="C" --->  Correct +1 = 0000
        Q#02.  What do herpetologists study?
        --->A. Blood
        --->B. Herpes
        --->C. Insects
        --->D. Reptiles and amphibians
        A#02.  -----> Correct Answer="D", Your Answer="B" --->  Wrong ***********
        --- etc ---

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

3I1. Scripts supporting quiz2 play & Creation of New quizfiles

quiz2combine - combine Results subdirs to today's date

 # quiz2combine - combine Results directory to today's date
 #              - by Owen Townsend, UV Software, March 2021
 #
 qdir="$1";
 if [[ ! -d "$qdir" ]]; then
    echo "usage: quiz2combine quiz2Resultdir"
    echo "       ==========================="
    echo " - arg1 must be a quiz2c Results dir (quiz2r or alternate)"
    exit 9; fi;
 #
 test -d tmp1 || mkdir tmp1
 rm -rf tmp1/*
 #
 ymdW=$(date +%Y%m%d)
 ymd=${ymdW%W}
 mkdir tmp1/${ymd}R tmp1/${ymd}T tmp1/${ymd}W
 #
 cp $qdir/*R/* tmp1/${ymd}R
 cp $qdir/*T/* tmp1/${ymd}T
 cp $qdir/*W/* tmp1/${ymd}W
 llr tmp1
 echo " - copied all files to tmp1/${ymd}R, tmp1/${ymd}T, tmp1/${ymd}W (listed above)"
 echo " - enter to remove all from $qdir & copy files (combined to today's date) back to $qdir"
 echo "   (else enter control-C to cancel)"; read reply
 #
 rm -rf $qdir/*
 cp -r tmp1/* $qdir
 exit 0

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

3I2. Scripts to Reformat quizfiles from internet for quiz2c

'quiz2reforms1' - script calling uvcopy 'quiz2reform1'

 #!/bin/bash
 # quiz2reforms1 - insert blank lines between groups of Questions & Choices
 #                 (part of converting quizfiles to format required by 'quiz2c' game)
 #               - by Owen Townsend, UV Software, Feb 2021
 #               - script runs uvcopy quiz2reform1 copies from qf1/... --> qf2/...
 #               - Must be in your $HOME/demo/quiz2d/...  (or $UV/demo/quiz2d/...)
 #                 with subdirs qf0,qf1,qf2,& qf3
 #
 # cdqd --> alias cdqd='cd $HOME/demo/quiz2d'
 # ====         - must be in $HOME/demo/quiz2d/... with subdirs qf0,qf1,qf2,qf3
 #
 # quiz2reforms1 Science01  <-- example: convert qf1/Science01 --> qf2/Science01
 # =======================
 #
 #   -------> qf0 --------> qf1 ---***----> qf2 ----> qf2 ----------> qf3 ----> /demo/quiz2f/
 #  download     exception     quiz2reform1     edit     quiz2reform2     copy   (for play)
 #
 #   qf0->qf1 - Download into qf0/..., copy to qf1 before making any changes
 #   qf1->qf1 - Edit (in place) Only when/if required so quiz2reform1 can distinguish Question
 #              lines from Choice lines to insert blank lines between sets of Question/Choices
 #              as expected by uvcopy quiz2reform2 (see more at uvsoftware.ca/uvdemos1.htm#Part_3)
 #              No changes required for jetpunk.com files (may need manual changes for some sites)
 # * qf1->qf2 - quiz2reform1 inserts blank lines between sets of Question/Choices (required by quiz2c)
 #              Note - do NOT rerun quiz2reform1 unless you 1st save the file in qf2/...
 #                   - so that you can restore the Answers from qf2save/... to the new qf2/...
 #   qf2->qf2 - Edit (in place) --> Add Answers onto the end of the Question lines
 #   qf2->qf3 - quiz2reform2 reformats the records for quiz2c Q#01..., A..., B..., C.etc, A#01. cc=X
 #            - & moves the Answer to a separate record at end Choices (so player does not see)
 # * This script runs uvcopy 'quiz2reform1' marked with '*' above
 #   Running script 'quiz2reform1s' is easier than running 'uvcopy quiz2reform1' directly And:
 #   - PROTECTS against overwriting qf2/... files with Answers coded on end of Questions
 #   - can 1st save qf2/... file in qf2save/..., run this quiz2reforms1, then restore answers from qf2save/...
 #
 qf="$1";
 if [[ (-f "qf1/$qf") && (! -f "qf2/$qf") ]]; then : ; else
    echo "usage: quiz2reforms1 quizfilexx"
    echo "       ========================="
    echo " - you must be in $HOME/demo/quiz2d/ quizfile Development directory"
    echo " - arg1 must be a file in  quiz2d/qf1/..."
    echo "   the file must NOT be in quiz2d/qf2/..."
    echo " To rerun - move qf2/filexx to qf2save/..."
    echo "          - run this script quiz2reforms1 to create new qf2/..."
    echo "          - edit to transfer Answers from qf2save/... to new qf2/..."
    exit 99; fi
 #
 uvcopy quiz2reform1,fili1=?qf1/$qf,filo1=?qf2/$qf
 #================================================
 # - Insert blank lines between groups of Question & Choices lines
 # - also inserts ##comment lines at BOF to document conversions required
 exit 0

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

3I3. Scripts to Reformat quizfiles from internet for quiz2c

'quiz2reforms2' - script calling uvcopy 'quiz2reform2'

 #!/bin/bash
 # quiz2reforms2 - convert quizfiles to the format required by 'quiz2c' game
 #               - moves Answers from cc=A,B,C,etc at end Question to separate line
 #               - by Owen Townsend, UV Software, Feb 2021
 #               - script runs uvcopy quiz2reform2 copies from qf2/... --> qf3/...
 #               - Must be in your $HOME/demo/quiz2d/...  (or $UV/demo/quiz2d/...)
 #                 with subdirs qf0,qf1,qf2,& qf3
 #
 # cdqd --> alias cdqd='cd $HOME/demo/quiz2d'
 # ====         - must be ib $HOME/demo/quiz2d/... with subdirs qf0,qf1,qf2,qf3
 #
 # quiz2reforms2 Science01  <-- example: convert qf2/Science01 --> qf2/Science01
 # =======================
 #
 #   -------> qf0 --------> qf1 ----------> qf2 ----> qf2 ----***----> qf3 ----> /demo/quiz2f/
 #  download     exception     quiz2reform1     edit     quiz2reform2      copy   (for play)
 #
 #   qf0->qf1 - Download into qf0/..., copy to qf1 before making any changes
 #   qf1->qf1 - Edit (in place) Only when/if required so quiz2reform1 can distinguish Question
 #              lines from Choice lines to insert blank lines between sets of Question/Choices
 #              as expected by uvcopy quiz2reform2 (see more at uvsoftware.ca/uvdemos1.htm#Part_3)
 #              No changes required for jetpunk.com files (may need manual changes for some sites)
 #   qf1->qf2 - quiz2reform1 inserts blank lines between sets of Question/Choices (required by quiz2c)
 #              Note - do NOT rerun quiz2reform1 unless you 1st save the file in qf2/...
 #                   - so that you can restore the Answers from qf2save/... to the new qf2/...
 #   qf2->qf2 - Edit (in place) --> Add Answers onto the end of the Question lines
 # * qf2->qf3 - quiz2reform2 reformats the Questions, Choices,& Answer records for quiz2c game
 #            - Q#01. question... cc=? --->A. ..., --->B. ..., --->C. ..., A#01. Correct=?
 #            - moves the Answer to a separate record at end Choices (so player does not see)
 # * This script runs uvcopy 'quiz2reform2' marked with '*' above
 # - running script 'quiz2reform2s' is easier than running 'uvcopy quiz2reform2' directly
 #
 qf="$1";
 if [[ -f "qf2/$qf" ]]; then : ; else
    echo "usage: quiz2reforms2 quizfilexx"
    echo "       ========================="
    echo " - you must be in $HOME/demo/quiz2d/ quizfile Development directory"
    echo " - arg1 must be a file in  quiz2d/qf2/..."
    exit 99; fi
 #
 uvcopy quiz2reform2,fili1=?qf2/$qf,filo1=?qf3/$qf
 #================================================
 exit 0
Note
  • the uvcopy job coding is too long to be listed in this documentation
  • but you can inspect as shown below:

 vi $UV/sf/demo/quiz2reform1
 ===========================
 vi $UV/sf/demo/quiz2reform2
 ===========================

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

3J1. quiz2c - Multiple-Choice Quiz game

Interested in C programming ?

If you are interested in learning C programming, you can inspect the C code & modify if you wish, since this copy is for you & backup copies are available for recovery from any disasters.


 #1.  vi src/quiz2c.c
      ===============

 #1a. vi /home/uvsoftxx/demo/src/quiz2c.c
      ===================================
       - #1a. same as #1. since you are in /home/uvsoftxx/demo

 #2. gcc src/quiz2c.c -o bin/quiz2c
     ==============================
      - compile the source code into binary executable

 #3. quiz2c    <-- execute your modified version
     ======

 #4. cp /home/uvsoftxx/uvadm/src/games/quiz2c.c demo/src
     ===================================================
      - could recover from any disaster modifying quiz2c.c

Many more demos at www.uvsoftware.ca/uvdemos1.htm

 You can see many more demos at www.uvsoftware.ca/uvdemos1.htm#Part_2
 - more C programs helloworld1.c, lotto1.c, insult2.c, etc
 - many uvcopy jobs uvlotto1, testint1, hexcalc1, datedemo1, uvfix1, etc

3K1. Books - Linux Commands, Scripting,& C programming

Here are some books I recommend for anybody wishing to learn unix/linux command Line Tools and C programming. Anybody working with computers will benefit from learning "command line tools" & perhaps "shell scripting". Learning "C programming" could lead to a career for young people.

Learning the Bash Shell - Cameron Needham - O'Reilly Press

The Linux Command Line - William Shotts

The C Programming Language - Kernighan & Ritchie

C Reference Manual
  • Harbison & Steele

Learning the vi editor - Arnolds & Lamb - O'Reilly press

Learning the vi & vim editor - Arnolds & Lamb - O'Reilly press

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

3L1. wordle - written in bash script

wordle with some enhancements

 #!/bin/bash
 # wordle  - from: Github user "HUYTD" via www.theregister.com/2022/02/02/bash_wordle
 #         - downloaded by Owen Townsend, UV Software, April 5/2022
 #         - stored at $UV/sf/demo/... (UV=/home1/uvadm/ or /home/uvsoftxx/uvadm/ online)
 # wordle0 - original version saved before enhancements by OT
 # wordle1 - development version before changing name back to just "wordle"
 # wordle  - final version after enhancements by OT
 #         - changed max_guess from 6 to 12 & allowing "Q" or "q" quit before max
 #         - added arg1 alternate wordfile, default $UV/tf/words72K if present
 #         - may speccify words25K,words10K,etc if present in $UV/tf/...
 #         - default /usr/share/dict/words if $UV/tf/words... not preseent
 #         - any /full/path/... file accepted if present
 #         - added arg2 "show" to show the word at begining to assist learning wordle
 #         - changed ASCII color codes to more meaningful symbols $GREEN, $YELLOW, etc
 #         - documented at www.uvsoftware.ca/uvdemos1.htm#3L1
 #
 #               ** optional Expand Linux dictionary for wordle **
 #
 # The default dictionary on Linux is /usr/share/dict/american-english 102,401 words
 # and is missing many words in the British dictionary. You could combine them as
 # explained at https://uvsoftware.ca/uvdemos1.htm#3L2.
 #
 # BUT, expanding the dictionary made wordle much harder, because there were many
 # obscure words in the large version of the British dictionary, so I changed the
 # default dictionary back to original american-english.
 #
 #                ** Alternate dictionary for website Logins **
 #
 # If you are using a login/password to 1 of the guest logins on uvsoftware.ca,
 # you have no access to the Linux dictionary at /usr/share/dict/words, so the
 # wordle script detects this & uses an alternate stored at $UV/tf/words72K
 #
 # The alternate at $UV/tf/words72K has 72,166 words (vs 102,401 in Linux default),
 # because we dropped words with any non-alphanumerics & also dropped duplicates
 # caused by lower-casing all words & re-sorting with unique option.
 # Other alternates may be coded as arg1 (as explained previouysly)
 #
 #-----------------------------------------------------------------------------------
 GREEN=$(tput setab 2); YELLOW=$(tput setab 3); WHITE=$(tput setab 7);
 BLACK=$(tput setaf 0); RESET=$(tput sgr0);
 #-----------------------------------------------------------------------------------
 echo "wordle bash script - from GITHUB user HUYT, downloaded by Owen Townsend April 2022"
 echo "modified - changed max guesses from 6 to 12 (but you know it counts only if <= 6)"
 echo "         - allow entry 'q' or 'Q' to Quit early & shgow correct word"
 echo "         - allow arg1 alternate dictionary (words10K,words25K vs default words72K)"
 echo "         - allow arg2 'show' to show correct word at begining (learning assist)"
 echo "wordle          <-- default dictionary $UV/tf/words72K if present, else /usr/share/dict/words"
 echo "wordle words10K <-- alterante dictionary, fewer words, easier for beginners"
 echo "wordle words25K <-- uses words10K,words25K,words72K,etc if defined in $UV/tf/..."
 echo "wordle words75K show  <-- SHOW word at begining, learning assist, either 1st or 2nd arg"
 echo "${BLACK}${GREEN} GREEN ${RESET}  - correct letter in correct position"
 echo "${BLACK}${YELLOW} YELLOW ${RESET} - correct letter but NOT in correct position"
 echo "${BLACK}${WHITE} WHITE ${RESET}  - these letters do NOT exist anywhere in the correct word"

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

 # determine wordfile: /fullpath, arg1 if in $UV/tf/..., $UV/tfwords72K, or /usr/share/dict/words
 if [[ "$1" == /* ]]; then wordfile="$1";
    elif [[ -d $UV && -f $UV/tf/$1 ]]; then wordfile=$UV/tf/$1;
    elif [[ -d $UV && -f $UV/tf/words72K ]]; then wordfile=$UV/tf/words72K;
    else wordfile=/usr/share/dict/words; fi
 echo "         - wordfile=$wordfile (\$UV/tf/words10K,25K,72K or /usr/share/dict/words)"
 if [[ ! -s $wordfile ]]; then echo "ERROR wordfile=$wordfile not found or size zero";exit;fi
 #
 words=($(grep '^\w\w\w\w\w$' $wordfile | tr '[a-z]' '[A-Z]'))
 actual=${words[$[$RANDOM % ${#words[@]}]]} end=false guess_count=0 max_guess=12
 if [[ *"$*"* =~ "show" ]]; then echo "         - learner option: the word is: $actual"; fi
 while [[ $end != true ]]; do
     guess_count=$(( $guess_count + 1 ))
     if [[ $guess_count -le $max_guess ]]; then
         echo "Enter your guess ($guess_count / $max_guess):"
         read guess
         guess=$(echo $guess | tr '[a-z]' '[A-Z]')
         if [[ "$guess" == "Q" ]]; then
             echo "QUITTER, the word is: $actual"; exit 99; fi
         if [[ " ${words[*]} " =~ " $guess " ]]; then
             output="" remaining=""
             if [[ $actual == $guess ]]; then
                 echo "You guessed right - in $guess_count tries"
                 for ((i = 0; i < ${#actual}; i++)); do
                     output+="${BLACK}${GREEN}${guess:$i:1} ${RESET}"
                 done
                 printf "$output\n"
                 end=true
             else
                 for ((i = 0; i < ${#actual}; i++)); do
                     if [[ "${actual:$i:1}" != "${guess:$i:1}" ]]; then
                         remaining+=${actual:$i:1}
                     fi
                 done
                 for ((i = 0; i < ${#actual}; i++)); do
                     if [[ "${actual:$i:1}" != "${guess:$i:1}" ]]; then
                         if [[ "$remaining" == *"${guess:$i:1}"* ]]; then
                             output+="${BLACK}${YELLOW}${guess:$i:1} ${RESET}"
                             remaining=${remaining/"${guess:$i:1}"/}
                         else
                             output+="${BLACK}${WHITE}${guess:$i:1} ${RESET}"
                         fi
                     else
                         output+="${BLACK}${GREEN}${guess:$i:1} ${RESET}"
                     fi
                 done
                 printf "$output\n"
             fi
         else
             echo "Please enter a valid word with 5 letters!";
             guess_count=$(( $guess_count - 1 ))
         fi
     else
         echo "You lose! The word is: $actual"; end=true;
     fi
 done

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

3L2. wordle - written in bash script

Expand Linux dictionary for wordle (optional)

The default dictionary on Linux is /usr/share/dict/american-english 102,401 words and is missing many words in the British dictionary, could combine them as follows:


 1. Login as Linux system admin
    =====
 2. sudo -i    <--
    =======
    --> password <-- for Linux sysadm

 3. cd /usr/share/dict
    ==================
 4. ls -l
    =====
    -rw-rw-r--  972398 Apr  4 12:19 american-english_original
    -rw-rw-r-- 1635703 Apr 24  2018 british-english-large
    -rw-rw-r-- 1661239 Apr  4 14:37 american-english
    lrwxrwxrwx      30 Sep 12  2021 words -> /etc/dictionaries-common/words
    lrwxrwxrwx      16 Sep 12  2021 words.pre-dictionaries-common -> american-english

 5. mv american-english american-english_original
    =============================================
     - save original american-english dictionary in case you want to restore (I did)

 6. sort -u american-english_original british-english_large -o american-english
    ===========================================================================
     - combine american-english & British dictionaries, replacing american-english
     - not recommended & I restored original american-english default

The Linux dictionary actually uses the symbolic link /usr/share/dict/words which points to /etc/dictionaries-common/words, another symbolic link, which points back to american-english

BUT, expanding the dictionary as above made wordle much harder, because there were many obscure words in the large version of the British dictionary, so I changed default dictionary back to original american-english

Alternate dictionary for website Logins

If you are using a login/password to 1 of the guest logins on uvsoftware.ca, you have no access to the Linux dictionary at /usr/share/dict/words, so the wordle script detects this & uses an alternate stored at $UV/tf/words72K The alternate at $UV/tf/words has 72,166 words (vs 102,401 in Linux default), because we dropped words with any non-alphanumerics & also dropped duplicates caused by lower-casing all words & re-sorting with unique option.

And we allow alternate dictionary files to be specified as arg1 to wordle See explanation in the wordle script lised above.

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

Part_4. uvcopy Demos & Tutorials

UVdemos1 - Part 4 - Contents


4A1. uvcopy Demos & Tutorials

4A2. Provincefix1 - sample uvcopy job to convert .csv file to fixed-fields
 Input $UV/demo/dat0/Provinces.csv, Output $UV/demo/dat1/Provinces1
- sample/demo explained before we ask you to write a similar job

4A3. Execute 'uvcopy Provincefix1' & to convert .csv file to fixed fields.
- showing Input & Output files

4A4. Directories/Files relevant to uvcopy tutorials

4A5. Notes Re pf,pfxx,pfyy directories for uvcopy jobs
Create your jobs in pfxx & see UV Softwares solutions in pfyy

4B1. 'copy1' - uvcopy skeleton framework for your instructions
- Copy, Rename,& edit to Insert your instructions

4B2. pfxx/provincefix1 - copied/renamed/modified from copy1
- Notes re documenting uvcopy jobs (& scripts)

4B3. Execute your uvcopy job & check Input/Output files

4B4. Adding sequence#s & reformatting as desired

4B5. AFTER Adding seq#s, reformatting,& editing population
- accumulate Total population & print at end of report

4B6. USstatespop1 - uvcopy job used to create USstates.csv for demos in Parts 4 & 5.
Original USstates.csv had the population for the state capital, & we wanted to
add the population for the entire state from another file.

4C1. Create Table Summary of Provinces & Populations by Party

4C2. Execute job to summarize provinces & populations
Input dat9/provinces2, output tmp/provinces2.tbl

4D1. Create job to summarize US Congress members by Party
Execute job to summarize provinces & populations
Input dat1/UScongress, Output tmp/UScongress.tbl

4D2. Documenting your new job

4D3. Table Summarize US Congress Members by Party & Sex
- concatenating 2 fields for the table argument

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

4A1. uvcopy Demos & Tutorials

sample job to convert .csv file to fixed-fields

The previous pages have demonstrated several 'pre-programmed' uvcopy jobs (uvlotto1, testint1, hexcalc1, datedemo1), and now we will illustrate how you can write your own uvcopy jobs for whatever data file manipulations you might need.

'uvcopy' has over 100 instructions documented at uvsoftware.ca/uvcopy3.htm. In addition to the basic instructions (move,add,etc), there are many calls that perform hundreds of C instructions to perform commonly required data manipulations, such as delimiting/undelimiting, searching/replacing, table analysis, etc.

For our 1st example, we will illustrate the 'fix' instruction which separates '.csv' files to separate fixed-length fields depending on the longest field. Then you can reformat to a desired layout, assigning field lengths appropriate to the contents. Here are the 1st 3 records of the test data file used to illustrate the 'fix' instruction.

Input - $UV/demo/dat0/Provinces.csv

            ABR,Province,Capital,Premier,Government,Population
            AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
            BC,British Columbia,Victoria,John Horgan,NDP,5121000

Output - $UV/demo/dat1/Provinces1

         10        20        30        40        50        60        70        80        90       100       110
 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 ABR                 Province            Capital             Premier             Government          Population
 AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 BC                  British Columbia    Victoria            John Horgan         NDP                 5121000

      fix    b0(20),a0(200),6,','     <-- fix (separate fields) as shown above
   ================================     - 4 operands described below
op1
  • defines 1st output field, in area 'b' & 20 bytes long
op2
  • defines input record, in area 'a', 200 bytes allowed
op3
  • number of fields
op4
  • separator, could be multi chars (example '","')

Since uvcopy was designed to replace IBM mainframe utilities, the operand usage is similar to that of the original IBM 360 assembler language - data movement is always from the 2nd operand to the 1st operand, which makes sense because some instructions have only 1 operand & op2 could be a long constant.

See complete description of 'fix' at uvsoftware.ca/uvcopy3.htm#fix

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

4A2. uvcopy Tutorials for creating uvcopy jobs

$UV/demo/pf/Provincefix1 demonstrates that only 1 uvcopy instruction can do complex data manipulations that could take many lines of code in other languages.

Note that the uvcopy job illustrates the fix Input/Output conversions as #comments at the begining of the coding & highlights the 'fix' instruction with '==='s

Convert .csv to fixed fields for Cdn Provinces

 # Provincefix1 - convert Canadian Provinces file from comma delimited to fixed fields
 #              - uvcopy job stored in $UV/pf/demo/... & in $UV/demo/pf/...
 #              - by Owen Townsend, UV Software, July 2020
 #
 # uvcopy Provincefix1,fili1=dat0/Provinces.csv,filo1=dat1/Provinces1
 # ==================================================================
 # uvcopy Provincefix1      <-- same as above, see defaults on fili1/filo1 below
 # ===================
 #
 #                ** sample 1st 3 records Input & Output **
 #
 # ABR,Province,Capital,Premier,Government,Population
 # AB,Alberta,Edmonton,Jason Kenney,UCP,4429000                                     <-- Input area 'a'
 # BC,British Columbia,Victoria,John Horgan,NDP,5121000
 #
 #          1         2         3         4         5         6         7         8
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890 <-- Output area 'b'
 # ABR                 Province            Capital             Premier             Government          Population
 # AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 # BC                  British Columbia    Victoria            John Horgan         NDP                 5121000
 #
 opr='$jobname - convert Cdn Provinces file from comma delimited to fixed fields'
 rop=r1  # option to view output at EOF (vi,cat,more,etc)
 fili1=?dat0/Provinces.csv,typ=LST,rcs=256
 filo1=?dat1/Provinces1,typ=LST,rcs=256
 @run
         opn    all
 # begin loop to get into area 'a', fix fields 20 apart in area 'b', & output
 loop    get    fili1,a0                 get next record
         skp>   eof                      (cc set > at EOF)
 #==================================
         fix    b0(20),a0(256),6,','     separate fields 20 apart in area 'b'
 #==================================
         put    filo1,b0                 write output from area 'b'
         skp    loop                     return to get next record
 eof     cls    all                      close files
         eoj                             end job
Note
  • all the work is performed by only 1 instruction, the rest is #comments
    & uvcopy framework of file Input/Output.
  • We will provide you with a framework job $UV/pf/demo/copy1 that you
    can copy/rename/modify, so you only need to code 1 or a few instructions
    and declare your files vs demo files.

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

4A3. uvcopy tutorials for creating uvcopy jobs

Execute Provincefix1


 #0a. ssh uvsoftxx@uvsoftware.ca  <-- login if not already logged in
      ==========================      (online userids uvsoft00-uvsoft99)
      --> passxx                  <-- enter your password at the prompt

 #0b. Login userxx          <-- Alternative Login on your own machine
      ============              if you have downloaded & installed Vancouver Utilities

 #0c. cdm  ------>              /home/uvsoftxx/demo (alias cdm='cd $HOME/demo')
      ===  --OR-->              /home/userxx/demo

 #1. cat dat0/Provinces.csv  <-- show Input file (.csv)
     ======================
      ABR,Province,Capital,Premier,Government,Population
      AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
      BC,British Columbia,Victoria,John Horgan,NDP,5121000
      MB,Manitoba,Winnipeg,Brian Pallister,PC,1380000
      NB,New Brunswick,Fredericton,Blaine Higgs,PC,781000
      NL,Newfoundland,St. John's,Dwight Ball,Liberal,521000
      NS,Nova Scotia,Halifax,Stephen McNeil,Liberal,979000
      ON,Ontario,Doug Ford,Toronto,PC,14746000
      PE,PrinceEdwardIsland,Charlottetown,Dennis King,PC,159000
      QC,Quebec,Quebec City,Francois Legault,CAQ,8553000
      SK,Saskatchewan,Regina,Scott Moe,SaskParty,1182000
      NT,NW Territories,Yellowknife,Caroline Cochrane,Consensus,45000
      NU,Nunavut,Joe Savikataaq,Iqualuit,Consensus,40000
      YK,Yukon,Sandy Silver,Yellowknife,Liberal,42000

 #2. uvcopy Provincefix1  <-- execute uvcopy demo job to convert .csv to fixed fields
     ===================

 #3. cat dat1/Provinces1  <-- show Output file (Fixed-Fields)
     ===================
         10        20        30        40        50        60        70        80        90       100       110
 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 ABR                 Province            Capital             Premier             Government          Population
 AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 BC                  British Columbia    Victoria            John Horgan         NDP                 5121000
 MB                  Manitoba            Winnipeg            Brian Pallister     PC                  1380000
 NB                  New Brunswick       Fredericton         Blaine Higgs        PC                  781000
 NL                  Newfoundland        St. John's          Dwight Ball         Liberal             521000
 NS                  Nova Scotia         Halifax             Stephen McNeil      Liberal             979000
 ON                  Ontario             Toronto             Doug Ford           PC                  14746000
 PE                  PrinceEdwardIsland  Charlottetown       Dennis King         PC                  159000
 QC                  Quebec              Quebec City         Francois Legault    CAQ                 8553000
 SK                  Saskatchewan        Regina              Scott Moe           SaskParty           1182000
 NT                  NW Territories      Yellowknife         Caroline Cochrane   Consensus           45000
 NU                  Nunavut             Iqualuit            Joe Savikataaq      Consensus           40000
 YK                  Yukon               Yellowknife         Sandy Silver        Liberal             42000

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

4A4. uvcopy tutorials for creating uvcopy jobs

Directories/Files relevant to uvcopy tutorials

 /home/uvadm/demo
 |-- dat0/                 <--- .csv files to be converted to fixed layouts
 |   |-- ...                  - several files not shown (not relevant to UVdemos1)
 |   |-- Provinces.csv      <-- used to demo converting to fixed-field format
 |   |-- UScongress.csv       - used to demo table summary by party, sex, etc
 |   |-- USstates.csv         - used to demo accumulating state pop & calc % total pop
 |   `
 |-- dat1/                 <--- fixed-field layout (converted from dat0/...csv files)
 |   |-- ...                  - several files not shown (not relevant uvcopy tutorials)
 |   |-- Provinces1         <-- converted from Provinces.csv, all fields 20 bytes apart
 |   |-- Provinces2           - outputs of UVSW jobs in pf/... vs USER jobs in pfxx...
 |   |-- UScongress           - used to demo table summary by party, sex, etc
 |   |-- insults            <-- data file for insult2
 |   `--
 |-- dat9/                 <--- subdir/files created by YOUR exercises (vs our demos)
 |   |-- provinces2         <-- created by pfxx/provincefix2 (yours vs our Provinces2)
 |   |--                      - or by pfyy/provincefix2 (UV Software's solution)
 |   |-- provinces2a        <-- created by pfxx/provincefix2a (or pfyy/provincefix2a)
 |   |--                      - same as provinces2 with Total population
 |   |-- provinces2.tbl     <-- created by pfxx/provincefixtbl2 (or pfyy/provincetbl2)
 |   `--
 |-- pf/                   <--- uvcopy demo jobs (written by UV Software)
 |   |-- Provincefix1       <-- convert Provinces.csv to Provinces1 fixed 20 apart
 |   |-- Provincefix2       <-- convert Provinces.csv to Provinces2 reformatted
 |   `--
 |-- pfxx/                 <--- user written uvcopy job tutorials
 |   |-- copy1                - skeleton (framework) for creating new uvcopy jobs
 |   |-- .........          <-- user to create uvcopy jobs by copy/rename/modify copy1
 |   |-- .........              (provincefix1,provincefix2,provincefix2a,provincetbl2)
 |   |-- .........            - may compare to pfyy/uvcopy jobs (by UV Software)
 |   |--
 |-- pfyy/                 <--- answers to user tutorials
 |   |-- provincefix1         - compare your solutions to UV Software solutions
 |   |-- provincefix2         - minimal version pf/Provincefix2, created from copy1
 |   |-- provincefix2a        - same with total population line added
 |   |-- provincetbl2         - table summary of province counts & populations by Gov Party
 |   |-- UScongresstbl1       - table summary of US Congress Members by Party
 |   `-- UScongresstbl2       - table summary of US Congress Members by Party & Sex
 |-- sf/                   <--- Script Files for UVdemos2 vs this UVdemos1
 |   |-- ...                  - UV Software demo scripts
 |-- sfxx/                 <--- user written scripts
 |   |-- ...                  - see tutorials ahead (might create with uvfix1)
 |-- sfyy/                 <--- answers to user tutorials
 |   |-- rename_dat3          - create scripts with column alignment
 |   |-- rename_dat3_neat1    - enhance existing scripts with column alignment
 |   |-- rename_dat3_neat2    - scripts created by $UV/pf/util/uvfix1
 |-- tmp/                  <--- uvfix jobs preliminary output to tmp/...
 |   |--                      - for inspection before copy back to desired directory

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

4A5. uvcopy tutorials for creating uvcopy jobs

Notes Re pf,pfxx,pfyy directories for uvcopy jobs

pf
  • is the traditional directory for uvcopy jobs (in $PFPATH)
  • contains UV Software demo jobs Provincefix1, Provincefix2, etc
pfxx
  • intended for user written jobs for tutorials (not in $PFPATH)
  • user to write provincefix1,provincefix2,provincefix2a,provincetbl2,etc
  • starting from the 'copy1' skeleton framework uvcopy job (for file I/O)
  • inserting your instructions where indicated
pfyy
  • UV Software's solutions for user comparisons (not in $PFPATH)
  • for comparison to user written jobs (provincefix1,provincefix2,etc)
  • can execute these 1st & then write your own version
  • try to write your version in pfxx/... before you look at pfyy/...

pfxx & pfyy are NOT in $PFPATH, you need to specify on the uvcopy command, for example:


 uvcopy pfxx/provincefix1   <-- need to specify directory for jobs in pfxx/ & pfyy/
 ========================

As opposed to uvcopy jobs whose directories are in $PATH, foe example:


 uvcopy Provincefix1        <-- do not need to specify directory is in $PFPATH
 ===================

PFPATH is defined in $APPSADM/env/comon_profile_uv, for example:


 export PFPATH=$RUNLIBS/pf,$HOME/pf,$UV/pf/adm,$UV/pf/demo,$UV/pf/util,$UV/pf/IBM
 ================================================================================

Notes Re sf,sfxx,sfyy directories Script Files

sf
  • Script Files (demo scripts written by UV Software)
sfxx
  • user written scripts - see tutorials ahead (might create with uvfix1)
sfyy
  • answers to user tutorials, for comparison to your scripts
  • but try to write your version in sfxx/... before you look at sfyy/...

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

4B1. uvcopy tutorials for creating uvcopy jobs

'copy1' - uvcopy framework for your instructions

 # copy1 - uvcopy skeleton job - to be copied,renamed,modified as required <-*-UPDATE
 # copy1 - uvcopy utility job stored in: /home/uvadm/pf/demo/...
 #       - this job is for 'text' files (variable length records ended by 'LF's)
 #       - see 'copyf1' fixed length seqntl files, 'copyI1' for Indexed files
 #Note - Be sure to change jobname & these #comment decriptions for your new job
 #
 # 1. cp $UV/pf/demo/copy1 $HOME/pf/myfilefix - copy/rename to your homedir/pf/yourname
 # 2. vi pf/myfilefix                   - modify for your purposes
 # 3. uvcopy pf/myfilefix               - execute modified job
 #
 rop=r1    #<-- EOF option to view output file (reply vi,cat,more,etc)
 fili1=?tf/test100,typ=LST,rcs=512    # code your input filename        <-*-UPDATE
 filo1=?tmp/$fili1,typ=LSTt,rcs=512   # output same filename in tmp/... <-*-UPDATE if desired
 # '?' prompts for change, but better to code your expected filenames & null to accept
 @run
         opn     all                      open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                 get record into area 'a'
         skp>    EOF                      (cc set > at EOF)
         mvc     b0(512),a0               move input area 'a' to output area 'b'
 #---------------------------------
 #       ---     -----,-----          <-- add your instructions here     <-*- UPDATE
 #---------------------------------
 putrec  put     filo1,b0                 write to output file from area 'b'
         skp     getrec                   return to get next record
 #
 EOF     cls     all                      close files
         eoj                              end job

Copy/Rename/Insert the 'fix' instruction


 #0a. ssh userxx@uvsoftware.ca     <-- login to your account
      ========================
  --> passxx   <-- enter password

 #0b. cdm --> /home/uvsoftxx/demo/...  (alias cdm='cd $HOME/demo)
      ===

 #1. cp pf/copy1 pfxx/provincefix1
     =============================
      - copy/renaming to 'pfxx/provincefix1' or whatever makes sense to you
      - UV Software's version was called 'pf/Provincefix1'

 #2. vi pfxx/provincefix1     <-- edit your version to insert 'fix' instruction
     ====================         (replacing the existing 'mvc' instruction)

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

4B2. uvcopy Tutorials & Exercises

pfxx/provincefix1 - copied/renamed/modified from copy1

 # provincefix1 - convert Provinces.csv to fixed-field layout      <-*-UPDATE#1
 #              - created by copying/renaming/modifying copy1 to provincefix1
 #              - replacing 'mvc' with 'fix' instruction
 #              - by userxx, XX company, July 04/2020
 #
 # uvcopy provincefix1,fili1=dat0/Provinces.csv,filo1=dat9/provinces1
 # ==================================================================
 # uvcopy provincefix1  <-- same as above, I/O files default as shown
 # ===================
 #
 #                 ** Sample Record Input & Output **
 #
 # AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
 #         10        20        30        40        50        60        70        80        90       100       110
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 # AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat0/Provinces.csv,typ=LST,rcs=512   # Input filename changed            <-*-UPDATE#2a
 filo1=?dat9/provinces1,typ=LSTt,rcs=512     # Output filename changed           <-*-UPDATE#2b
 @run
        opn    all                       open files
 # begin loop to get & put records until EOF
 getrec get    fili1,a0                  get record into area 'a'
        skp>   EOF                       (cc set > at EOF)
 #----------------------------------
        fix    b0(20),a0(200),6,','  <-- fix 6 fields 20 apart in 'b' from 'a'   <-*-UPDATE#3
 #----------------------------------
 putrec put    filo1,b0                  write to output file from area 'b'
        skp    getrec                    return to get next record
 EOF    cls    all                       close files
        eoj                              end job

Mandatory UPDATEs (vs copy1 on prior page)

UPDATE1
  • change jobname & "what it does" description at begin job
UPDATE2a
  • change fili1=?... from 'tf/test100' to 'dat0/Provinces.csv'
UPDATE2b
  • change filo1=?... from 'tmp/$fili1' to 'dat9/provinces1'
UPDATE3
  • code the 'fix' instruction (replacing --- of copy1 job)

Optional Updates (Recommended at production sites)

  1. First line must specify the new jobname (not copy1) & what it does (briefly)
  2. Document author name, date written or modified, company name as applicable
  3. Show the uvcopy command to run the job, with new I/O filenames
  4. Nice to show 1 or a few sample records Input/Output
  5. Add #comments as required for other programmers to understand your job Comments on separate #lines or coded on right side of instructions, but must be separated by at least 2 spaces from the last operand.
Note
  • you can omit these Optional Updates (except #1) for these tutorials.

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

4B3. uvcopy Tutorials & Exercises

Execute your uvcopy job & check Input/Output files


 #3. uvcopy pfxx/provincefix1   <-- execute your new uvcopy job
     ========================

 #4. cat dat0/Provinces.csv
     ======================
      ABR,Province,Capital,Premier,Government,Population
      AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
      BC,British Columbia,Victoria,John Horgan,NDP,5121000
      MB,Manitoba,Winnipeg,Brian Pallister,PC,1380000
      NB,New Brunswick,Fredericton,Blaine Higgs,PC,781000
      NL,Newfoundland,St. John's,Dwight Ball,Liberal,521000
      NS,Nova Scotia,Halifax,Stephen McNeil,Liberal,979000
      ON,Ontario,Toronto,Doug Ford,PC,14746000
      PE,PrinceEdwardIsland,Charlottetown,Dennis King,PC,159000
      QC,Quebec,Quebec City,Francois Legault,CAQ,8553000
      SK,Saskatchewan,Regina,Scott Moe,SaskParty,1182000
      NT,NW Territories,Yellowknife,Caroline Cochrane,Consensus,45000
      NU,Nunavut,Iqualuit,Joe Savikataaq,Consensus,40000
      YK,Yukon,Yellowknife,Sandy Silver,Liberal,42000

 #5. cat dat9/provinces1
     ===================
         10        20        30        40        50        60        70        80        90       100       110       120
 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 ABR                 Province            Capital             Premier             Government          Population
 AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 BC                  British Columbia    Victoria            John Horgan         NDP                 5121000
 MB                  Manitoba            Winnipeg            Brian Pallister     PC                  1380000
 NB                  New Brunswick       Fredericton         Blaine Higgs        PC                  781000
 NL                  Newfoundland        St. John's          Dwight Ball         Liberal             521000
 NS                  Nova Scotia         Halifax             Stephen McNeil      Liberal             979000
 ON                  Ontario             Toronto             Doug Ford           PC                  14746000
 PE                  PrinceEdwardIsland  Charlottetown       Dennis King         PC                  159000
 QC                  Quebec              Quebec City         Francois Legault    CAQ                 8553000
 SK                  Saskatchewan        Regina              Scott Moe           SaskParty           1182000
 NT                  NW Territories      Yellowknife         Caroline Cochrane   Consensus           45000
 NU                  Nunavut             Iqualuit            Joe Savikataaq      Consensus           40000
 YK                  Yukon               Yellowknife         Sandy Silver        Liberal             42000

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

4B4. Improving provincefix1 by copy/modify to provincefix2

Adding sequence#s & reformatting as desired

Let's assume you want to add sequence#s, reformat the spacing,& edit the population field as shown below by 1st 3 records (before & after):

 ABR                 Province            Capital             Premier             Government          Population
 AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
 BC                  British Columbia    Victoria            John Horgan         NDP                 5121000
         10        20        30        40        50        60        70        80        90       100       110       120
 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 00  ABR   Province            Capital             Premier             Government
 01  AB    Alberta             Edmonton            Jason Kenney        UCP                  4,429,000
 02  BC    British Columbia    Victoria            John Horgan         NDP                  5,121,000

 #6. cp pfxx/provincefix1 pfxx/provincefix2  <-- copy/rename existing job
     ======================================

 #7. vi pfxx/provincefix2     <-- edit as shown by the 'AFTER' job shown below
     ====================         vs your 'BEFORE' job shown above.
 # provincefix2 - improved version of 'provincefix1'       <--*-- change jobname & description
 #              - created by copying/renaming/modifying provincefix1 to provincefix2
 #              - adding code to sequence number
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat0/Provinces.csv,typ=LST,rcs=512   # Input filename <--*-- SAME as provincefix1
 filo1=?dat9/provinces2,typ=LSTt,rcs=512     # Output         <--*-- Changed to provinces2 (vs 1)
 @run
        opn    all                       open files
 # begin loop to get & put records until EOF
 getrec get    fili1,a0                  get record into area 'a'
        skp>   eof                       (cc set > at EOF)
 #------------------------------------------------------------------------
 # fix fields 20 bytes apart from area 'a' to area 'b', then reformat to area 'c'
        fix    b0(20),a0(200),6,','      fix fields 20 bytes apart
 #------------------------------------------------------------------------
 #Note - 5 sequence# instructions added to provincefix2 (vs provincefix1)
        mvn    c0(2),$ca1                sequence# in cols 01-02  <--*-- Add 5 instructions
        add    $ca1,1                    increment sequence#
        mvc    c4(3),b0                  province abrev
        mvc    c10(80),b20               shift province,city,ppremier,gov left by 10
        edt    c90(10),b100(10),'zz,zzz,zzz'  edit population
 #------------------------------------------------------------------------
        put    filo1,c0                  write output from area 'c' <--*-- vs area 'b'
        skp    getrec                    return to get next record
 eof    cls    all                       close files
        eoj                              end job
Note
  • be sure you change all lines marked with '<--*--' on the right

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

4B5. Improving provincefix1 by copy/modify to provincefix2


 #8. uvcopy pfxx/provincefix2    <-- Execute new enhanced job
     ========================      - see output below:

AFTER Adding seq#s, reformatting,& editing population


 #9. cat dat9/provinces2    <-- display new output file
     ===================      - compare to previous version above
 00  ABR   Province            Capital             Premier             Government
 01  AB    Alberta             Edmonton            Jason Kenney        UCP                  4,429,000
 02  BC    British Columbia    Victoria            John Horgan         NDP                  5,121,000
 03  MB    Manitoba            Winnipeg            Brian Pallister     PC                   1,380,000
 04  NB    New Brunswick       Fredericton         Blaine Higgs        PC                     781,000
 05  NL    Newfoundland        St. John's          Dwight Ball         Liberal                521,000
 06  NS    Nova Scotia         Halifax             Stephen McNeil      Liberal                979,000
 07  ON    Ontario             Toronto             Doug Ford           PC                  14,746,000
 08  PE    PrinceEdwardIsland  Charlottetown       Dennis King         PC                     159,000
 09  QC    Quebec              Quebec City         Francois Legault    CAQ                  8,553,000
 10  SK    Saskatchewan        Regina              Scott Moe           SaskParty            1,182,000
 11  NT    NW Territories      Yellowknife         Caroline Cochrane   Consensus               45,000
 12  NU    Nunavut             Iqualuit            Joe Savikataaq      Consensus               40,000
 13  YK    Yukon               Yellowknife         Sandy Silver        Liberal                 42,000
 Total Population of Canada --->                                                           37,978,000

Adding Total population

In fact, the above (dat9/provinces2a vs dat9/provinces2) shows the extra total line.

Can you add more instructions to accumulate the total population & print at EOF ?


 #10. cp pfxx/provincefix2 pfxx/provincefix2a  <-- copy/rename for the new version
      ===================================

 #11. vi pfxx/provincefix2a      <-- modify
      =====================

 #12. uvcopy pfxx/provincefix2a  <-- execute new versions
      =========================
Note
  • you can see the solution in pfyy/provincefix2a
  • But, don't look until you have tried your own solution
  • 'pfxx/...' is for your solutions to uvcopy exercises
  • 'pfyy/...' is for UV Software's solutions for comparison to yours

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

4B6. Demo table load & lookup to combine info from 2 files

 # USstatespop1 - add state population to dat1/USstates1 creating dat0/USstates.csv
 #              - by Owen Townsend, UV Software, Sep/2020
 #
 # uvcopy USstatespop1,fili1=dat1/USstates1,fili2=dat1/USstatepops,filo1=dat0/USstates.csv
 # =======================================================================================
 # uvcopy USstatespop1  <-- same & easier to enter, filenames default as shown above
 # ===================
 #
 #          ----- dat1/USstates1 - input#1 sample 1st 3 records -----
 #         10        20        30        40        50        60        70        80
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # abr                 state               capital             population
 # AL                  Alabama             Montgomery          205764
 # AK                  Alaska              Juneau              31275
 #
 #          ----- dat1/USstatepops - input#2 sample 1st 3 records -----
 #         10        20        30        40        50        60        70        80
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # State                         Population
 # Alabama                       4908620
 # Alaska                        734002
 #
 #          ----- dat0/USstates.csv - sample output 1st 3 records -----
 # abr,state,state-pop,capital,capital-pop
 # AL,Alabama,4908620,Montgomery,205764,
 # AK,Alaska,734002,Juneau,31275,
 #
 opr='$jobname - add state pop to dat1/USstates1 creating dat0/USstates.csv'
 rop=r1   # EOF option to view output (vi,cat,more,etc)
 fili1=dat1/USstates1,rcs=100,typ=LST
 fili2=dat1/USstatepops,rcs=100,typ=LST
 filo1=dat0/USstates.csv,rcs=100,typ=LST
 @run
         opn     all                       open all files
         rtb     fili2,b0(100),b0(100)     read USstatepops into memory table
 #
 # begin loop to read dat1/USstates1 & process, until EOF
 man20   get     fili1,a0                  get next record
         skp>    man90                     (cc set > at EOF)
         mvf     c0(100),a0(40)            move abr & statename, clear remainder area c
         mvc     c60(40),a40               shift capital & pop over leave space for statepop
 #
 # lookup statepops file in memory table by statename to get statepop
 man24   lokz1   bb0(100),bb0(20),a20(20)  lookup
         skp!    1
         mvc     c40(20),bb30              insert statepop in field#3
         var     d0(100),c0(20),5,','      convert to csv
         put     filo1,d0                  write to output file
         skp     man20                     return to get next record
 #
 # EOF - close files & end job
 man90   cls     all                       close all files
         eoj                               end job

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

4C1. uvcopy Table Summary Instructions 'tbl' & 'tbp'

Create job to summarize Provinces & Populations by Party

Let's create another job to demo the uvcopy 'tbl' & 'tbp' instructions. We can copy/rename/modify the copy1 skeleton job similar to prior creation of provincefix1


 #1. cp pfxx/copy1 pfxx/provincetbl2
     ===============================
      - copy/renaming to 'provincefix1' or whatever makes sense to you
      - existing version was called 'Provincefix1'

 #2. vi pfxx/provincetbl2     <-- edit to insert 'tbl' & 'tbp' instructions
     ====================       - see results listed below:
 # provincetbl2 - table summarize province counts & populations by political party
 #              - created by copying/renaming/modifying 'copy1' to 'provincetbl2'
 #              - inserting 'tbl' & 'tbp' instructions
 #              - by userxx, XX company, July 04/2020
 #NOTE - CHANGE jobname & descriptions from 'copy1' as appropriate for "provincetbl2"
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat9/provinces2,typ=LST,rcs=512       # InFile  <-*- is OutFile of provincefix2
 filo1=?dat9/provinces2.tbl,typ=LSTt,rcs=512  # OutFile <-*- with '.tbl' extension
 @run
        opn     all                       open files
 # begin loop to get & put records until EOF
 getrec get     fili1,a0                  get record into area 'a'
        skp>    EOF                       (cc set > at EOF)
 #------------------------------------------------------------------------
        tblt1f1 a70(10),'Gov Party;population',a90(10)  <-*- 'tbl' replaces copy1
 #------------------------------------------------------------------------
        skp     getrec                    return to get next record
 EOF    tbpt1   filo1,'province counts & populations by Gov. Party'  <-*- 'tbp'
        cls     all                       close files
        eoj                               end job

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

4C2. uvcopy Table Summary Instructions tbl & tbp

Execute job to summarize provinces & populations


 #3. uvcopy pfxx/provincetbl2   <-- Execute
     ========================

 #4. cat dat9/provinces2        <-- display input file
     ===================

Input File - dat9/provinces2

         10        20        30        40        50        60        70        80        90       100       110
 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 00  ABR   Province            Capital             Premier             Government
 01  AB    Alberta             Edmonton            Jason Kenney        UCP                  4,429,000
 02  BC    British Columbia    Victoria            John Horgan         NDP                  5,121,000
 03  MB    Manitoba            Winnipeg            Brian Pallister     PC                   1,380,000
 04  NB    New Brunswick       Fredericton         Blaine Higgs        PC                     781,000
 05  NL    Newfoundland        St. John's          Dwight Ball         Liberal                521,000
 06  NS    Nova Scotia         Halifax             Stephen McNeil      Liberal                979,000
 07  ON    Ontario             Toronto             Doug Ford           PC                  14,746,000
 08  PE    PrinceEdwardIsland  Charlottetown       Dennis King         PC                     159,000
 09  QC    Quebec              Quebec City         Francois Legault    CAQ                  8,553,000
 10  SK    Saskatchewan        Regina              Scott Moe           SaskParty            1,182,000
 11  NT    NW Territories      Yellowknife         Caroline Cochrane   Consensus               45,000
 12  NU    Nunavut             Iqualuit            Joe Savikataaq      Consensus               40,000
 13  YK    Yukon               Yellowknife         Sandy Silver        Liberal                 42,000

 #5. cat dat9/provinces2.tbl   <-- display table summary report
     =======================
 provincetbl2  2020/07/05_17:41:36_086  province counts & populations by Government Party
 tbl#0001  tblt1f1 a70(10)      <----- argument ----->                -acum#1-    %
 line#   1strec#  %      count  Gov Party                           population
     1        10   7         1  CAQ                                  8,553,000   22
     2        12  14         2  Consensus                               85,000    0
     3         1   7         1  Government                                   0    0
     4         6  21         3  Liberal                              1,542,000    4
     5         3   7         1  NDP                                  5,121,000   13
     6         4  28         4  PC                                  17,066,000   44
     7        11   7         1  SaskParty                            1,182,000    3
     8         2   7         1  UCP                                  4,429,000   11
                 100        14*  *TOTAL*                            37,978,000 *100

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

4D1. uvcopy Table Summary Instructions tbl & tbp

Create job to summarize US Congress members by Party

              ----------- 1st 3 records of 539 -----------
         10        20        30        40        50        60        70        80
 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 001  Abraham             Ralph          19540916  M  LA  rep  Republican
 002  Adams               Alma           19460527  F  NC  rep  Democrat
 003  Aderholt            Robert         19650722  M  AL  rep  Republican

 #1. cp pfxx/copy1 pfxx/UScongresstbl1
     =================================
      - copy/rename template job 'copy1' to 'UScongresstbl1' (or whatever you like)
      - solution in pfyy is 'UScongresstbl1' but try making your version in pfxx/...

 #2. vi pfxx/UScongresstbl1     <-- edit to insert 'tbl' & 'tbp' instructions
     ======================       - see results listed below:
 # UScongresstbl1 - table summarize US Congress members by party         <-*-UPDATE#1
 #                - created by copy/rename/modify 'copy1' uvcopy skeleton job
 #                - by Owen Townsend, UV Software, Juky09/2020
 #NOTE - CHANGE JOBNAME & descriptions from 'copy1' as appropriate for "provincetbl2"
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat1/UScongress,typ=LST,rcs=512      # change Input Filename    <-*-UPDATE#2a
 filo1=?tmp/UScongress.tbl,typ=LSTt,rcs=512  # change Output Filename   <-*-UPDATE#2b
 @run
         opn     all                       open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                  get record into area 'a'
         skp>    eof                       (cc set > at EOF)
 #-----------------------------
         tblt1f1 a62(15),'Members by Party'   #<-- insert tbl... instrn   <-*-UPDATE#3
 #-----------------------------
 ####### put     filo1,b0  <-- ##disable detail output, dump table at EOF <-*-UPDATE#4
         skp     getrec                    return to get next record
 #
 # EOF - dump table, close files,& end job
 eof     tbpt1   filo1,'Congress Members summarized by Party'             <-*-UPDATE#5
         cls     all                       close files
         eoj                               end job

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

4D2. uvcopy job to summarize US Congress members by Party

Execute job to summarize UScongress members by Party


 #3. uvcopy pfxx/UScongresstbl1   <-- Execute
     ==========================

 #4. cat tmp/UScongress.tbl1      <-- display output file
     =======================
 UScongresstbl1  2020/07/09_15:42:12_143  US Congress Members summarized by Party
 tbl#0001  tblt1f1 a62(15)      <----- argument ----->
 line#   1strec#  %      count  Members by Party
     1         2  52       284  Democrat
     2       265   0         2  Independent
     3         1  46       253  Republican
                 100       539*  *TOTAL*

Add documentation to your new job


 #5a. vi dat1/UScongress       <-- read input file into the editor
      ==================
  --> "a3yy     <-- yank 1st 3 lines into buffer "a"

 #5b. vi tmp/UScongress.tbl1   <-- read output file into the editor
      ======================
  --> "b7yy     <-- yank all lines (7) into buffer "b"

 #5c. vi pfxx/UScongresstbl1   <-- edit your job
      ======================
  --> add front end lines with jobname,purpose,author,date (as shown below)
  --> "ap       <--Put buffer "a" in desired location & insert '#' column 1
  --> "bp       <--Put buffer "b" in desired location & insert '#' column 1

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

4D3. uvcopy job to summarize US Congress members by Party

2nd version UScongresstbl1 with added documentation #comments

 # UScongresstbl1a - table summarize US Congress members by party         <-*-UPDATE#1
 #                 - created by copy/rename/modify 'copy1' uvcopy skeleton job
 #                 - by Owen Townsend, UV Software, Juky09/2020
 #NOTE - CHANGE JOBNAME & descriptions from 'copy1' as appropriate for "provincetbl2"
 #
 #              ----------- 1st 3 records of 539 -----------
 #         10        20        30        40        50        60        70        80
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # 001  Abraham             Ralph          19540916  M  LA  rep  Republican
 # 002  Adams               Alma           19460527  F  NC  rep  Democrat
 # 003  Aderholt            Robert         19650722  M  AL  rep  Republican
 #
 #            ---------- summary table dumped at EOF ----------
 # UScongresstbl1  2020/07/09_15:42:12_143  US Congress Members summarized by Party
 # tbl#0001  tblt1f1 a62(15)      <----- argument ----->
 # line#   1strec#  %      count  Members by Party
 #     1         2  52       284  Democrat
 #     2       265   0         2  Independent
 #     3         1  46       253  Republican
 #                 100       539*  *TOTAL*
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat1/UScongress,typ=LST,rcs=512      # change Input Filename    <-*-UPDATE#2a
 filo1=?tmp/UScongress.tbl,typ=LSTt,rcs=512  # change Output Filename   <-*-UPDATE#2b
 @run
         opn     all                       open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                  get record into area 'a'
         skp>    eof                       (cc set > at EOF)
 #-----------------------------
         tblt1f1 a62(15),'Members by Party'   #<-- insert tbl... instrn   <-*-UPDATE#3
 #-----------------------------
 ####### put     filo1,b0  <-- ##disable detail output, dump table at EOF <-*-UPDATE#4
         skp     getrec                    return to get next record
 #
 # EOF - dump table, close files,& end job
 eof     tbpt1   filo1,'Congress Members summarized by Party'             <-*-UPDATE#5
         cls     all                       close files
         eoj                               end job
Note
  • For this training, we don't expect you to take the time to fully document
    with I/O samples on #comment lines as shown above, BUT at a minimum, Be sure to:
  • Change the jobname on 1st line & add short description of "what the job does"

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

4D4. Table Summaries by Multiple Arguments

Summarize US Congress Members by Party & Sex


 #1. cp pfxx/UScongresstbl1 pfxx/UScongresstbl2
     ==========================================
      - copy/rename your prior job to a new jobname

 #2. vi pfxx/UScongresstbl2   <-- add instruction to concatenate Sex onto Party
     ======================     - change argument heading & descriptions appropriately

 #3. uvcopy UScongresstbl2    <-- Execute
     =====================      - see output below (inserted into job as documentation)
 # UScongresstbl2 - table summarize US Congress members by party & sex  <-*-UPDATE#1
 #                - created by copying UScongress1, renaming to UScongresstbl2
 #                - adding 'sex' as a 2nd part of the argument for 'tblt1f1'
 #
 #              ----------- 1st 3 records of 539 -----------
 #         10        20        30        40        50        60        70        80
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # 001  Abraham             Ralph          19540916  M  LA  rep  Republican
 # 002  Adams               Alma           19460527  F  NC  rep  Democrat
 # 003  Aderholt            Robert         19650722  M  AL  rep  Republican
 #
 #            ---------- summary table dumped at EOF ----------
 # UScongresstbl2  2020/07/09_16:05:41_381  US Congress Members by Party & Sex
 # tbl#0001  tblt1f1 a62(15)      <----- argument ----->
 # line#   1strec#  %      count  Members by Party & Sex
 #     1         2  20       108  Democrat     F
 #     2         4  32       176  Democrat     M
 #     3       265   0         2  Independent  M
 #     4         9   4        23  Republican   F
 #     5         1  42       230  Republican   M
 #                 100       539*  *TOTAL*
 #
 rop=r1    #<-- option for EOF prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat1/UScongress,typ=LST,rcs=512       # change Input Filename    <-*-UPDATE#2a
 filo1=?tmp/UScongress.tbl2,typ=LSTt,rcs=512  # change Output Filename   <-*-UPDATE#2b
 @run
         opn     all                       open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                  get record into area 'a'
         skp>    eof                       (cc set > at EOF)
 #-----------------------------
         mvc     a75(1),a50                         move sex after party  <-*-UPDATE#3a
         tblt1f1 a62(15),'Members by Party & sex'   insert tbl... instrn  <-*-UPDATE#3b
 #-----------------------------
 ####### put     filo1,b0  <-- ##disable detail output, dump table at EOF <-*-UPDATE#4
         skp     getrec                    return to get next record
 #
 # EOF - dump table, close files,& end job
 eof     tbpt1   filo1,'Congress Members summarized by Party'             <-*-UPDATE#5
         cls     all                       close files
         eoj                               end job

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

Part_5. uvcopy Tutorials & Exercises

UVdemos1 Part 5 - Contents


5A1. uvfix1 - EASY way to execute uvcopy instructions
- interactive utility that solicits your instructions & inserts them
  into a complete uvcopy job including the file I/O logic
 Tips & Differences from uvcopy direct use, which requires editing or copying
 the file I/O framework,as well as your instructions).

5B1. uvfix1 first demo - convert .csv to fixed-field 20 bytes apart
- province abr, province-name, capital, premier, government-party
- same as the previous pfxx/provincefix1 job which was created by editing
  instructions into a supplied framework job ($UV/pf/demo/copy1).

5B2. uvfix1 options available (help screen)
- options b1/b2 to drop blank lines or reduce multi blank lines to 1
- option 'p1' to translate unprintable characters to '.' periods
- options m & n to sequence# Input &/or Output records
- option 'e#' to select Every nth record ('e5' select every 5th record)
- option 's#' to Stop copy after 's#' records

5C1. demo uvfix1 OPTIONS to sequence#, drop blank lines, reduce multi-blank lines to 1
5C2. option 'n4' 4 digit sequence#, 'b1' reduce multi blanks lines to 1
5C3. option 'n6' (seq# 6 digits) & 'b2' (drop All blank lines)

5D1. uvfix1 demo - convert dat0/USstates.csv to fixed-fields 20 bytes apart
- state abrev, state-name, state-population, capital, capital-population
5D2.  option 's#' Stop copy after # records
 option 'e5' select Every 5th record (or as desired)

5E1. Run uvfix1 with No Instructions to automatically:
- remove trailing blanks (mainframe files blank filled to col 80)
- remove any CR's x'0D' from mainframes or Windows files
- use 'uvhd' to show trailing spaces, CR's, LF's not shown by unix tools
 See 'uvfixA' (at '5F1') to process All files in a directory

5E2. Understanding ASCII characters coded in Hexadecimal

5E3. asciihexbinary1 - print ASCII chars in hex & binary

5F1. 'uvfixA' script to process All files in a directory copying to a 2nd directory
5F2. - also demos option 'p1' to translate unprintable characters to '.'s

5G1. uvfix1 to SELECT records
- demo selects records with 'New' from dat1/USstates1

5G2. uvfix1 to REPLACE patterns with alternates
- demo selects records with 'New' from dat1/USstates1

5G3. uvfix1 translate to lowercase, to UPPERcase, EBCDIC to ASCII, ASCII to EBCDIC

5G4. UVFIX1 left adjust & squeeze multi-spaces to 1 between words

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

UVdemos1 Part 5 - Contents (continued)


5H1. uvfixA - process All files in the parms/* directory
- clear columns 73-80 (seq#s from mainframe, N/A on unix)

5H2. Insert $date8 & $filenames in All files in parms/...
- uvcopy provides access to 85 $variables (stored at uvcopy startup)
- use option v1 on mvfv1, msgv1, lodv1, sysv1

5H3. External ${VARIABLE} values provided by uvcopy option v2.
- accessed when you execute mvfv2, msgv2, lodv2, sysv2
- access both internal & external with 'v3' (mvfv3,msgv3,lodv3, sysv3)

5I1. uvfix1 demo - create 'neat' column-aligned scripts
- testfiles provided in demo/dat3
- sf/rename_neat1 - copy/rename script 'TO BE CREATED'
- 1st Try to create column aligned script with 'vi'

5I2. Attempt to create column aligned script with 'vi'

5I3. Creating column aligned scripts with 'uvfix1'

5I4. step by step procedure using 'uvfix1'

5I5. Explanations of Instructions to create sf/rename_neat1

5J1. using 'uvfix1' to column align an EXISTING script
sf/rename_dat3 - script BEFORE column-alignment

5J2. sf/rename_dat3_neat2 - script AFTER column-alignment

5J3. Explanations of Instructions to create sf/rename_dat3_neat2

5K1. Instruction entry error messages & prompt to re-enter
- illustrate by re-running '5B1' fix dat1/Provinces.csv with errors
- Instruction Error msgs - op1 area code missing, op2 length missing, etc

5L1. Complete job (with file I/O framework) saved in tmp/filename.pf
- Can save for later re-runs without having to re-enter instructions
- Can easily modify as desired, inserting additional instructions
- Can use many uvcopy features not available in interactive modes
  (add more files, accumulate & print total lines, etc)

uvfix1 - EASY way to execute uvcopy instructions

Previously (on page '4B1'), we showed you how to create new uvcopy jobs by copying/renaming/modifing the 'copy1' skeleton job (framework to handle FILE I/O), and then you only had to write the instructions to do whatever you wanted to do. To convert a .csv file to fixed-fields we only had to write ONE 'fix' instruction.

Now, we will show you how to eliminate the need to insert your desired instructions into the 'copy1' framework job - by running interactive job 'uvfix1' that solicits your instructions & then executes the job when you enter a '.' period.

uvfix1 also saves the complete job in tmp/filename.pf, which you could save to a permanent pf directory for subsequent reruns (or edit & rerun).

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

5A1. uvfix1 - EASY way to execute uvcopy instructions

uvfix Tips & Differences from uvcopy direct use

  1. You do not need to code the uvcopy framework instructions. The 'get', test EOF, 'mvc' inarea 'a' to outarea 'b', & 'put' are automatic

  2. You would code 'skp??' to test the results of many instructions such as: cmc, cmn, scn, rep, lok, tst, tsb (& many more, see uvcopy3.htm).

  3. Condition codes on 'skp??'s can be any of '=', '!', '<', '>', '<=', '>='

  4. Normally, you would not code the 'get' instruction since it is autoamtic, but you could code 'skp?? getrec if you wanted to bypass the automatic 'put' for the current record & get the next record.

  5. You can code 'put' instructions if desired to output multiple records on 1 input record cycle. You might then use special 'skp?? getrec' to inhibit the automatic 'put' for the current record.

  6. You cannot define labels (optional in cols 1-8 of uvcopy instructions) So, you can code the instruction operations starting in column 1

  7. The only goto labels allowed are 'getrec', 'putrec',& 'EOF'. - 'skp?? getrec' would inhibit output for the current record. - 'skp?? putrec' would inhibit further instructions for current record. - 'skp?? EOF' would inhibit processing any remaining records in the file.

  8. For most jobs you will address only area 'a' for Input records & area 'b' for Output records, but areas 'c', 'd', 'e' are reserved for your use. You could manipulate data in c,d,e,& move results to the output area 'b'. You could save data in c,d,e & address later when you reach desired data.

  9. No point in coding comments since the entries are not permanent - as for complete uvcopy jobs built with the editor & saved in a pf/directory.

  10. The output file is automatically wrritten to tmp/inputfilename in your current working directory & given the same name as the input file. You could however specify your preferred name on filo1=yourdir?/yourfilename?

  11. Also note that the complete uvcopy job (framework I/O + your instructions) is saved in tmp/inputfilename.pf - so you could copy the complete job to a permanent pf/... directory & re-run it as is, or edit it & rerun it.

  12. Best to remove all files from the tmp/... subdir in your current working directory (rm -f tmp/*) before running uvfix1 jobs that are unrelated.

  13. For uvfixA (process all files in a directory vs uvfix1 for 1 file), you must specify your input directory name on the command line & may specify your output directory name (or specify outdir as 'tmp2/' in current directory) so you could check outputs before copying to your intended outdir.

  14. The created uvcopy job is always written to tmp/indirfilename.pf, in case you want to modify & rerun (without having to re-enter your instructions).

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

5B1. uvcopy Tutorials & Exercises

uvfix1 - EASY way to execute uvcopy instructions

First, we will demo uvfix1 to do the same thing as we did with the complete uvcopy job previously illustrated on pages '4B1' & '4B2' which was constructed by editing your desired instructions into a supplied job ($UV/pf/demo/copy1)

Now, we will show you how to eliminate the need to insert your desired instructions into the 'copy1' framework job - by running interactive job 'uvfix1' that solicits your instructions & then executes the job when you enter a '.' period.

uvfix1 demo#1 - convert .csv to fixed-field


 #1. head -5 dat0/Provinces.csv   <-- show 1st 5 input records
     ==========================
      ABR,Province,Capital,Premier,Government,Population
      AB,Alberta,Edmonton,Jason Kenney,UCP,4429000
      BC,British Columbia,Victoria,John Horgan,NDP,5121000
      MB,Manitoba,Winnipeg,Brian Pallister,PC,1380000
      NB,New Brunswick,Fredericton,Blaine Higgs,PC,781000

 #2. uvcopy uvfix1,fili1=dat1/Provinces.csv
     ======================================
      - execute uvfix1 to prompt for instruction keyins
Note
  • We are OMITTING the options help screen & various other file info msgs
  • Please see the complete 'uvfix1 OPTIONS' shown on the next page ------------->
  • just enter nulls to accept the defaults, until you see "enter instruction"
  • enter instruction (or period "." end entries & execute)
      ========================
 #2a. fix b0(20),a0(100),6,','   <-- enter 'fix' instrn (convert csv to fixed-field)
      ========================
 #2b. .                          <-- enter '.' period to execute
      ====
        20200707:551000:uvfix1: EOF fili01 rds=14 size=720: dat1/Provinces.csv
        20200707:551000:uvfix1: EOF filo01 wrts=14 size=1506: tmp/Provinces
        EOJ, Output File written to: tmp/Provinces

 #3.  head -5 tmp/Provices       <-- inspect output & if OK, copy to wherever you want it
     =====================         - in case of a fixup job, you may want to overwrite the original
                                   - or you may want to rename the output file
      ABR                 Province            Capital             Premier             Government          Population
      AB                  Alberta             Edmonton            Jason Kenney        UCP                 4429000
      BC                  British Columbia    Victoria            John Horgan         NDP                 5121000
      MB                  Manitoba            Winnipeg            Brian Pallister     PC                  1380000
      NB                  New Brunswick       Fredericton         Blaine Higgs        PC                  781000

 #4. cp tmp/Provinces dat1/provinces1  <-- copy/rename the tmp/output to a permanent directory
     ================================

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

5B2. uvfix1 options

Note
  • our 1st demo of 'uvfix1' above omitted several lines displayed describing
    the uvfix1 options, since you can usually enter null to take the defaults
  • here is a rerun showing the available options:

 uvcopy uvfix1,fili1=dat1/Provinces.csv,uop=n4 <-- could enter options on command line
 =============================================   - or enter options at prompt below
 uvfix1 - copy a text file & modify via uvcopy instruction keyins
        - enter your input-file on command line (else defaults to demo file)
        - output-file will be written ti tmp/... with same name as input-file
 uop=q1b0c0h0m0n0p0r4096s99 - user option defaults
       b1              - reduce multiple consecutive blank records to 1
       b2              - drop all blank records (based on 1st100 bytes)
         c1            - pass thru any "#" col1 #comment records
         c2            - drop any # col1 records
           e#          - select Every e# input record, Example: e10 Every 10th
             h1        - display uvfix help screen with more (quits for rerun)
               m#      - show INput seq# in  # bytes of output record m0 inhibits
                       - m# unusual, could use m# & n# with e# (Every e# records)
                 n#    - show OUTput sequence Number in # bytes of output record n0 inhibits
                       - output records counted in $ca12 (input records counted in $ca11)
                   p1  - translate any unprintable characters to "." periods
              r4096    - recsize: max for text-records, exact for Fixed-Length-records
                       - for Fixed-Length, reply RSF/RST at prompt (default text typ=LSTt)
                       - for Text files: accept default recsize & default typ=LSTt
           s99         - Stop count (s99 special meaning **ALL** records)
 User OPtion (uop) defaults  = q1b0c0h0m0n0p0r4096s99
 -->null to accept or enter/override -->    <-------- enter null accept default options #1 *
 LSTt = typ default filo01 - null accept or enter new typ ? <-- null accept default typ #2 *
 Enter Instructions: inarea "a" copied to outarea "b"
 Example: seq# in 1st 5 cols, shifting data 6 bytes right
   add  $ca1,10      <-- increment ctr#1 ($ca1) by 10
   clr  b0(100)      <-- clear output record area "b"
   mvn  b0(5),$ca1   <-- mvn - MoVe Numeric seq# to 1st 5 bytes
   mvc  b6(100),a0   <-- mvc - MoVe Char a to b offset 6 right
                     <-- option "uop=n5" does same as above 4 instructions
                     <-- enter instruction (or "." period to end entries & Execute)
 fix b0(20),a0(100),6,','                   <-------- enter insrtructions (only 1 here) #3 *
                     <-- enter "." period to end entries & Execute
 .                                          <----------------- "." entered to Execute   #4 *
 20200820:171400:uvfix1: EOF fili01 rds=14 size=720: dat1/Provinces.csv
 20200820:171400:uvfix1: EOF filo01 wrts=14 size=1506: tmp/Provinces.csv
 20200820:171400:uvfix1: EOF filo02 wrts=33 size=1737: tmp/Provinces.csv.pf
 EOJ, Output File written to: tmp/Provinces.csv
 ----- enter: vi,cat,more,etc (default null) --> more <--- enter "more" to show output  #5 *
 AB                  Alberta             Edmonton            Jason Kenney UCP 4429000
 BC                  British Columbia    Victoria            John Horgan NDP 5121000
       --- showing only 1st 2 records of demo file above ---
Note
  • Entry #1 null acceepts default options, #2 accepts default output file type
  • Entry #3 is our 1 instruction (fix) to convert csv delimited to fixed fields
  • Entry #4 "." to execute the instructions while copying input to output
  • Entry #5 "more" displays the output file (in tmp/... with same name as infile)

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

5C1. uvfix1 - EASY way to execute uvcopy instructions

OPTIONS - sequence#, drop blank lines, reduce multiples to 1

You can do useful work with NO options & NO instructions to copy 1 or ALL files in a directory, automatically removing trailing blanks & Carriage Returns (x'0D's) that can cause problems on unix systems (CR's can cause scripts to fail).

This is useful to clean up files FTP'd from mainframes which are usually blank filled to 80 bytes appended with a LineFeed & a Carriage-Return (to be dropped). We will demo that process on page '5E1' ahead, but 1st we will demo the options.

Please see all the options on the previous page (b1/b2,c1,d1,h1,n99,p1,r4096,s#). Here we demo options b1 (reduce multi-blank lines to 1) & n4 seq# (in 1st 4 columns).


 #1. rm -f tmp*/*           <-- clear All tmp files
     ============             - tmp*/* same as tmp/* tmp1/* tmp2/*

 #2. cat dat3/uvfix.promo    <-- inspect input file to demo uvfix1 options
     ====================
 01                    ** uvfix1 & uvfixA - Most Usefull Tools **
 02
 03 If you are an IT professional, working with programs, scripts,& documentation, etc
 04 We think you will find uvfix1 & uvfixA the most useful tools in this collection.
 05
 06 Have you had times when unix tools alone did not do the selections or changes you needed ?
 07
 08                                                      <-- will reduce multi-blank lines to 1
 09                  ** Advantages of uvfix1 & uvfixA **
 10
 11 Interactive utility to fix problems in text files with 1 or a few instructions.
 12 Over 100 powerful instructions (search,replace,concatenate,delimit,translate,etc).
 13
 14 Can apply multiple conditions for selections & mass changes.
 15
 16 Copies the file or all files to a tmp/... dir for inspection before copy back.
Note
  • The actual input file (dat3/uvfix.promo) does not have the sequence numbers
  • we show them here, so you can compare to the output file on the page below
  • we sequenced number with uvfix1 & option n4 to insert 4 digit sequence#s
  • see all options listed on the previous page
  • here are just the options used for this demo to drop blank lines & sequence#
 uop=q1b0c0h0m0n0p0r4096s99 - user option defaults
 --->  b1              - reduce multiple consecutive blank records to 1        <---
 --->  b2              - drop all blank records (based on 1st100 bytes)        <---
         c1            - pass thru any "#" col1 #comment records
         c2            - drop any # col1 records
           e#          - select Every e# input record, Example: e10 Every 10th
             h1        - display uvfix help screen with more (quits for rerun)
               m#      - show INput seq# in 1st # bytes of Input record
 --->            n#    - show OUTput seq# in 1st # bytes of Output record      <---
                   p1  - translate any unprintable characters to "." periods
              r4096    - recsize: max for text-records, exact for Fixed-Length
           s99         - Stop count (s99 special meaning **ALL** records)

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

5C2. uvfix1 - EASY way to execute uvcopy instructions

uvfix1 OPTIONS demo - sequence# & drop blank lines


 #3. uvcopy uvfix1,fili1=dat3/uvfix.promo,uop=n4b1  <-- note options 'n4' & 'b1'
     =============================================
      - option 'n4' sequence#s in 1st 4 bytes
      - option 'b1' reduces multiple blank lines to 1 blank line
      --- OR, for simpler syntax run the 'script' uvfix1 that calls 'uvcopy uvfix1'

 #3a. uvfix1 dat3/uvfix.promo n4b1  <-- run script 'uvfix1' (calls 'uvcopy uvfix1')
      ============================
      Note - We have OMITTED the options help screen & various other prompts
           - Please see the 'uvfix1 OPTIONS' listed on page '5B2'
           - just enter nulls to accept the defaults, until you see "enter instruction"
           - enter instruction (or period "." end entries & execute)

     #3b.    .                        <-- enter '.' period to execute
           ====                         - No Instructions required to use options alone

 #5. cat tmp/uvfix.promo     <-- display the output file
     ===================       - note effects of options n4 & b1
 0001                    ** uvfix1 & uvfixA - Most Usefull Tools **
 0002
 0003 If you are an IT professional, working with programs, scripts,& documentation, etc
 0004 We think you will find uvfix1 & uvfixA the most useful tools in this collection.
 0005
 0006 Remember times when unix tools alone did not do the selections or changes you needed ?
 0007
 0008                    ** Advantages of uvfix1 & uvfixA **
 0009
 0010 Interactive utility to fix problems in text files with 1 or a few instructions.
 0011 Over 100 powerful instructions (search,replace,concatenate,delimit,translate,etc).
 0012
 0013 Can apply multiple conditions for selections & mass changes.
 0014
 0015 Copies the file or all files to a tmp/... dir for inspection before copy back.
Note
  • Compare the output file (15 lines) to the input file (16 lines) on the previous page
  • 1 blank line deleted by option 'b1' which reduces multi-blank lines to 1
    (input file had 2 blank lines after line# 0006)
Note
  • We coded the options "uop=b1n4" on the command line, to make it easier to repeat
    the command by searching Linux command line history with up arrow (or alt p).
  • But we could have wait for the options prompt (see options screen on page '5B2')

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

5C3. uvfix1 OPTIONS demo - sequence# & drop blank lines

options "n6" (seq# 6 digits) & "b2" (drop All blank lines)


 #1. uvcopy uvfix1,fili1=dat3/uvfix.promo,uop=n6b2
     =============================================
      - OR, use script 'uvfix1' below (easier syntax than 'uvcopy uvfix1')

 #1a. uvfix1 dat3/uvfix1.promo n4b2  <-- option n6 seq# 6 digits, b2 drop all blank lines
      =============================
Note
  • we will omit the options screen (shown on page '5B2')
  • and just show the output file as follows:

 #2. cat tmp/uvfix.promo     <-- display the output file
     ===================       - note effects of options n6 & b2
 000001                    ** uvfix1 & uvfixA - Most Usefull Tools **
 000002 If you are an IT professional, working with programs, scripts,& documentation, etc
 000003 We think you will find uvfix1 & uvfixA the most useful tools in this collection.
 000004 Remember times when unix tools alone did not do the selections or changes you needed ?
 000005                    ** Advantages of uvfix1 & uvfixA **
 000006 Interactive utility to fix problems in text files with 1 or a few instructions.
 000007 Over 100 powerful instructions (search,replace,concatenate,delimit,translate,etc).
 000008 Can apply multiple conditions for selections & mass changes.
 000009 Copies the file or all files to a tmp/... dir for inspection before copy back.

Comoare this output file (options n6b2) to prior page options n4b1

Note
  • Above we were showing both the 'uvcopy' & 'script' versions of uvfix1
  • From now on we will show just the 'script' version (easier syntax)

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

5D1. uvfix1 - EASY way to execute uvcopy instructions

convert dat0/USstates.csv to Fixed-Fields


 #1. cdm ------->  /home/uvsoftxx/demo/...  (alias cdm='cd $HOME/demo)
     ===  --OR-->  /home/userxx/demo

 #2. rm -f tmp*/*             <-- clear All tmp files
     ============               - tmp*/* same as tmp/* tmp1/* tmp2/*

 #3. head dat0/USstates.csv   <-- show 1st 10 records of Input file
     ======================
      abr,state,state-pop,capital,capital-pop
      AL,Alabama,4908620,Montgomery,205764,
      AK,Alaska,734002,Juneau,31275,
      AZ,Arizona,7378490,Phoenix,1445632,
      AR,Arkansas,3039000,Little Rock,193524,
      CA,California,39937500,Sacramento,466488,
      CO,Colorado,5845530,Denver,600158,
      CT,Connecticut,3563080,Hartford,124775,
      DE,Delaware,982895,Dover,36047,
      FL,Florida,21993000,Tallahassee,181376,

 #4. uvfix1 dat0/USstates.csv   <-- run uvfix1 script (to solicit instructions)
     ========================     - OMITTING options screen & filename prompts
                                  - until the '.' prompt for instructions
                                  - see uvfix1 OPTIONS listed on page '5B2'
     #4a.  ========================
           fix b0(20),a0(100),5,','   <-- enter "fix" instruction
           ========================
     #4b.    .                        <-- enter '.' period to execute
           ====
      20200902:241806:uvfix1: EOF fili01 rds=51 size=1916: dat0/USstates.csv
      20200902:241806:uvfix1: EOF filo01 wrts=51 size=4423: tmp/USstates.csv
      20200902:241806:uvfix1: EOF filo02 wrts=26 size=1432: tmp/USstates.csv.pf
      uvcopy uvfix1 start 2020/09/02_16:24:01 end 16:24:18 elapsed000_16_634
      EOJ, Output File written to: tmp/USstates.csv

 #5. cp tmp/USstates.csv dat1/USstates1  <-- save tmp/output to a permanent directory
     ==================================    - renaming (replacing '.csv' with '1'
Note
  • for production jobs, you would save/copy the tmp/... output file to a
    permanent directory, since the tmp/... files are frequently removed

 #6. more dat1/USstates1     <-- show all 50 states on the next page -------->
     ===================

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

5D2. convert dat0/USstates.csv to Fixed-Fields dat1/USstates1

                 ** dat1/USstates1 - with state & capital populations *8
 abr                 state               state-pop           capital             capital-pop
 AL                  Alabama             4908620             Montgomery          205764
 AK                  Alaska              734002              Juneau              31275
 AZ                  Arizona             7378490             Phoenix             1445632
 AR                  Arkansas            3039000             Little Rock         193524
 CA                  California          39937500            Sacramento          466488
 CO                  Colorado            5845530             Denver              600158
 CT                  Connecticut         3563080             Hartford            124775
 DE                  Delaware            982895              Dover               36047
 FL                  Florida             21993000            Tallahassee         181376
 GA                  Georgia             10736100            Atlanta             420003
 HI                  Hawaii              1412690             Honolulu            337256
 ID                  Idaho               1826160             Boise               205671
 IL                  Illinois            12659700            Springfield         116250
 IN                  Indiana             6745350             Indianapolis        820445
 IA                  Iowa                3179850             Des Moines          203433
 KS                  Kansas              2910360             Topeka              127473
 KY                  Kentucky            4499690             Frankfort           25527
 LA                  Louisiana           4645180             Baton Rouge         229493
 ME                  Maine               1345790             Augusta             19136
 MD                  Maryland            6083120             Annapolis           38394
 MA                  Massachusetts       6976600             Boston              617594
 MI                  Michigan            10045000            Lansing             114297
 MN                  Minnesota           5700670             Saint Paul          285068
 MS                  Mississippi         2989260             Jackson             173514
 MO                  Missouri            6169270             Jefferson City      43079
 MT                  Montana             1086760             Helana              28190
 NE                  Nebraska            1952570             Lincoln             258379
 NV                  Nevada              3139660             Carson City         55274
 NH                  New Hampshire       1371250             Concord             42695
 NJ                  New Jersey          8936570             Trenton             84913
 NM                  New Mexico          2096640             Santa Fe            67947
 NY                  New York            19440500            Albany              97856
 NC                  North Carolina      10611900            Raleigh             403892
 ND                  North Dakota        761723              Bismarck            61272
 OH                  Ohio                11747700            Columbus            787033
 OK                  Oklahoma            3954820             Oklahoma City       579999
 OR                  Oregon              4301090             Salem               154637
 PA                  Pennsylvania        12820900            Harrisburg          49528
 RI                  Rhode Island        1056160             Providence          178042
 SC                  South Carolina      5210100             Columbia            129272
 SD                  South Dakota        903027              Pierre              13646
 TN                  Tennessee           6897580             Nashville           601222
 TX                  Texas               29472300            Austin              790390
 UT                  Utah                3282120             Salt Lake City      186440
 VT                  Vermont             628061              Montpelier          7855
 VA                  Virginia            8626210             Richmond            204214
 WA                  Washington          7797100             Olympia             46478
 WV                  West Virginia       1778070             Charleston          51400
 WI                  Wisconsin           5851750             Madison             233209
 WY                  Wyoming             567025              Cheyenne            59466

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

5D3. Demo uvfix1 OPTIONS 's' & 'n'

Stop count option 's' & sequence Number option 'n'

We will demo the "Stop count" option 's' using demo file dat1/USstates1. You can see all 50 records (+ header) in $UV/demo/dat1/USstates1, but here we will showw only the 1st 10 records using option 's10'. Easier to use 'head 10', but we wanted to demo the STOP COUNT option.


 #1. rm -f tmp*/*                 <-- clear All tmp files
     ============                   - tmp*/* same as tmp/* tmp1/* tmp2/*

 #2. uvfix1 dat1/USstates1 s10n3  <-- copy dat1/USstates1 to tmp/USstates1
     ===========================    - option s10 Stop after record #10
Note
  • we are omitting the option description lines displayed here
  • since we have already coded our options on the command line

     #2a.    .                        <-- enter '.' period to execute
           ====                         - No Instructions required to use options alone

 #3. cat tmp/USstates1_s10n3      <-- display result (1st 10 records)
     =======================
     001 abr                 state               state-pop           capital             capital-pop
     002 AL                  Alabama             4908620             Montgomery          205764
     003 AK                  Alaska              734002              Juneau              31275
     004 AZ                  Arizona             7378490             Phoenix             1445632
     005 AR                  Arkansas            3039000             Little Rock         193524
     006 CA                  California          39937500            Sacramento          466488
     007 CO                  Colorado            5845530             Denver              600158
     008 CT                  Connecticut         3563080             Hartford            124775
     009 DE                  Delaware            982895              Dover               36047
     010 FL                  Florida             21993000            Tallahassee         181376

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

5D4. Demo uvfix1 OPTION 'e'

select Every 5th record demo


 #4. uvfix1 dat1/USstates1 e5m3n3  <-- copy dat1/USstates1 to tmp/USstates1
     ============================
      - option 'e5' select every 5th record (of 50)
      - option 'm3' sequence Number Input records & 'n3' seq# Output records

     #4a.    .                        <-- enter '.' period to execute
           ====                         - No Instructions required to use options alone

 #5. cat tmp/USstates1_e5m3n3  <-- display result (Every 5th record)
     ========================
     005 001 AR                  Arkansas            3039000             Little Rock         193524
     010 002 FL                  Florida             21993000            Tallahassee         181376
     015 003 IN                  Indiana             6745350             Indianapolis        820445
     020 004 ME                  Maine               1345790             Augusta             19136
     025 005 MS                  Mississippi         2989260             Jackson             173514
     030 006 NH                  New Hampshire       1371250             Concord             42695
     035 007 ND                  North Dakota        761723              Bismarck            61272
     040 008 RI                  Rhode Island        1056160             Providence          178042
     045 009 UT                  Utah                3282120             Salt Lake City      186440
     050 010 WI                  Wisconsin           5851750             Madison             233209
Note
  • As well as option 'e5' (select Every 5th record), we coded options
    'm3' (seq# input records) & 'n3' (seq# output records).
  • 'm3' allows you to see the original seq# in the input file.
Note
  • uvfix1 automatically appends the options on the output filenames
    so we can run multiple uvfix1 jobs & not overwrite previous output files
  • Be sure to remove all tmp/* files before starting a series of related jobs

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

5E1. uvfix1 - EASY way to execute uvcopy instructions

Drop CR's & Trailing Blanks

Carriage Returns x'0D' can cause problems on unix systems (scripts can fail) & the trailing blanks are annoying. An easy way to remove the CR's & trailing blanks is to use 'uvfix1' for 1 file at a time or 'uvfixA' for all files in a directory.

Files from outside sources (Windows or mainframe systems) often have CR's & trailing spaces, which you cannot see, but are annoying when you edit the files. Files from m ainframes are usually space filled to 80 bytes +CR +LF = 82 bytes. You can't see them with vi,cat,etc so use uvhd:

For example, we will use $UV/tf/product.master1 (8 records of 82 bytes each). Here is the 1st record displayed by uvhd. Note the trailing blanks & the ending Carriage Return x'0D' + Line Feed x'0A':


 #1. uvhd dat3/product.master1 t   <-- use option 't' for Text files (end record on LF x'0A')
     ===========================
     rec#=1 rsize=82 fptr=0 fsize=656 records=8
                10        20        30        40        50        60        70        80
     r# 1 0123456789012345678901234567890123456789012345678901234567890123456789012345678901
        0 BBQ010 BAR-B-Q         0019500                                                  ..
          4453332445242522222222233333332222222222222222222222222222222222222222222222222200
          2210100212D2D1000000000001950000000000000000000000000000000000000000000000000000DA
     #1a. q        <-- 'q' to quit uvhd (only wanted to see 1st record)

 #2. rm -f tmp*/*                      <-- clear tmp files
     ============                        - clears tmp/* + tmp1/* + tmp2/*

 #3. uvfix1 dat3/product.master1       <-- run uvfix1 to remove trailing blanks & CR's
     ===========================
                 - omitting the option & filename prompts, until the prompt for instructions
      #3a.  .  <-- No instructions required, just enter the '.' period
           ===   - to signal end of instructions & proceed to processing
                 - copies the file to tmp/product.master1 (removing trailing blanks & CRs)

 #4. uvhd tmp/product.master1 t     <-- investigate the output file
     ==========================       - compare to input record uvhd #1 above
     rec#=1 rsize=31 fptr=0 fsize=248 records=8
                 10        20        30
     r# 1 0123456789012345678901234567890
        0 BBQ010 BAR-B-Q         0019500.   <-- confirming trailing blanks removed
          4453332445242522222222233333330     - and CR's x'0D' removed
          2210100212D2D10000000000019500A     - terminated by LF's only x'0A's
     #4a. q         <-- quit uvhd

 #5. cp tmp/product.master1 dat3/   <-- could copy back overwriting original file
     ============================     - do NOT do this (retain original for tutorials)

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

5E2. uvfix1 - Drop CR's & Trailing Blanks

understanding ASCII characters coded in Hexadecimal

asciihexbinary1 - display ASCII chars in Hex & Binary


 #1. uvcopy asciihexbinary1  <-- run with no options 95 printables + 8 exceptions
     ======================   - shows values in hex, binary bits,& Character
      Jobname: asciihexbinary1 - print ASCII chars in hex & binary
      Report: tmp/asciihexbinary at: UV_Software by: uvadm on: 2020/12/19_20:34:41
      Value  Hex   Binary  Char Description
        999  XX  8421 8421  C   dddddd
      ============================================================================
        000  00  0000 0000     null
        009  09  0000 1001     TAB
        010  0A  0000 1010     LF
        012  0C  0000 1100     FF
        013  0D  0000 1101     CR
        027  1B  0001 1011     ESCAPE
        032  20  0010 0000     space
        033  21  0010 0001  !
        034  22  0010 0010  "
         --omit 11 lines--
        046  2E  0010 1110  .
        047  2F  0010 1111  /
        048  30  0011 0000  0
        049  31  0011 0001  1
        050  32  0011 0010  2
        051  33  0011 0011  3
        052  34  0011 0100  4
        053  35  0011 0101  5
        054  36  0011 0110  6
        055  37  0011 0111  7
        056  38  0011 1000  8
        057  39  0011 1001  9
        058  3A  0011 1010  :
         --omit 5 lines--
        064  40  0100 0000  @
        065  41  0100 0001  A
        066  42  0100 0010  B
        067  43  0100 0011  C
         --omit 22 lines--
        090  5A  0101 1010  Z
        091  5B  0101 1011  [
         --omit 31 lines--
        126  7E  0111 1110  ~
        127  7F  0111 1111     DEL
        255  FF  1111 1111     x'FF'

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

5E3. asciihexbinary1 - print ASCII chars in hex & binary

asciihexbinary1 option p1 printables only

Previous page default option displayed printable chars + exceptions (null,tab,LF,CR,etc) If interested, you can rerun with options p1 for printables only or p2 for all ASCII chars.


 #2. uvcopy asciihexbinary1,uop=p1  <-- option 'p1' display printable characters only
     =============================
      Value  Hex   Binary  Char Description
        999  XX  8421 8421  C   dddddd
      =====================================
        032  20  0010 0000     space
        033  21  0010 0001  !
        -- 14 lines omitted --
        048  30  0011 0000  0
        --  8 lines omitted --
        057  39  0011 1001  9
        --  7 lines omitted --
        065  41  0100 0001  A
        -- 24 lines omitted --
        090  5A  0101 1010  Z
        -- 24 lines omitted --
        125  7D  0111 1101  }
        126  7E  0111 1110  ~

 #3. uvcopy asciihexbinary1,uop=p2  <-- option 'p2' to display all 256 ASCII chars
     =============================    - shows values in hex, binary bits,& Character
      Value  Hex   Binary  Char Description
        999  XX  8421 8421  C   dddddd
      =====================================
        000  00  0000 0000     null
        001  01  0000 0001
        002  02  0000 0010
         -- 252 lines omitted --
        255  FF  1111 1111     x'FF'

uvhd showing hex codes for printables & unprintables

            10        20        30        40        50        60        70        80
 r# 1 0123456789012345678901234567890123456789012345678901234567890123456789012345678901
    0 BBQ010 BAR-B-Q         0019500                                                  ..
      4453332445242522222222233333332222222222222222222222222222222222222222222222222200
      2210100212D2D1000000000001950000000000000000000000000000000000000000000000000000DA

You cannot see the trailing blanks, CR's, or LF's using unix tools, but the trailing blanks waste space & are annoying when editing, & the CR's can cause scripts to fail, so best to eliminate. 'uvfixA' makes it easy to do for all files in a directory.

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

5F1. Easy way to shorten to last non-blank & drop CR's

uvfixA - process All files in directory

Use 'uvfixA' to process ALL files in the directory while copying to a 2nd directory. uvfixA does not output to tmp like uvfix1, You must specify the I/O directories. For example, remove CR's & trailing spaces from all files in demo/dat3/* as shown below. This action is automatic with uvfixA - No need to enter any instructions.


 #1. rm -f tmp*/*             <-- clear tmp files
     ============               - clears tmp/* + tmp1/* + tmp2/*

 #2. uvfixA dat3 tmp2 LST p1  <-- process ALL files in dat3/* while copying to tmp2/...
     =====================**    - arg3 'LST' is the file type (Line Seqntl Terminated)
                                - arg4 'p1' option converts unprintable chars to "."s
     uvfixA - copy/modify all text files from 1 directory to a 2nd directory
            - modifying the files via uvcopy instruction keyins
     uop=q1c0n99r4096t0 - user option defaults
           c1           - pass thru any "#" col1 #comment records
             n99        - output record limit (n99 special meaning **ALL** records)
                p1      - translate any unprintable characters to "." periods      <--NOTE
                  r4096 - recsize ONLY for Fixed-Length OUTPUT records if desired
                        - for Text files: accept default recsize & default typ=LSTt
                     t1 - translate output file-names to lower-case, t2 for UPPER-case
     User OPtion (uop) defaults  = q1c0n99r4096t0
     -->null to accept or enter/override --------> p1 <--- convert unprintables to "."s
     did you create outdir ? (or remove files) --> y  <--- Yes, we cleared outdir tmp2/*
                  <-- enter instruction (or period "." end entries & execute)
     #2a.  .      <-- enter "." to Execute (No instrns needed to drop CRs & trailing blanks)
          ===
     20200821:374704:uvfixA: EOF filo02 wrts=12 size=805: tmp2/about.dat3.files
     20200821:374704:uvfixA: EOF filo02 wrts=20 size=1400: tmp2/gl.account.trans
     20200821:374704:uvfixA: EOF filo02 wrts=8 size=248: tmp2/product.master1
     20200821:374704:uvfixA: EOF filo02 wrts=16 size=678: tmp2/uvfix.promo
     20200821:374704:uvfixA: EOF filo02 wrts=9 size=576: tmp2/warranty.master
       ----- showing only output file stats, omitting several other lines

Notes re uvfixA

We are using the script $UV/sf/util/uvfixA vs uvcopy ($UV/pf/util/uvfixA) since the command line is shorter for uvfixA, here are both for comparison:


 uvcopy uvfixA,fild1=dat3,fild2=tmp2,arg1=LST,uop=p1  <-- uvcopy command LONGER
 ===================================================

 uvfixA dat3 tmp2 LST p1  <-- script version SHORTER & easier to enter
 =======================

We specified the 'p1' option on both the command line & the prompt (REDUNDANT). We recommend specifying all args on teh command line, so you can easly repeat the command from the Linux history (if required).

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

5F2. Easy way to shorten to last non-blank & drop CR's

Option 'p1' convert unprintables to '.'s

Option "p1" will convert any unprintable characters to '.'s. The warranty.master file has packed fields. You can use uvhd to see the difference BEFORE & AFTER:


 #3. uvhd dat3/warranty.master t2  <-- see packed field chars in dat3/ BEFORE conversion
     ============================    - option 't2' shows unprintables as ':'s
     rec#=1 rsize=64 fptr=0 fsize=576 records=9
                     10        20        30        40        50        60
     r#   1 0123456789012345678901234567890123456789012345678901234567890123
          0 12345 12345 sony television   950101 1-year :`:: 00000291q::P:::
            3333323333327667276667676662223333332327667206112333333337095110
            1234501234503FE9045C56939FE00095010101D95120900C00000029111900CA
                                                         ^ ^^         ^^^ ^^
               Note - packed/binary characters marked with '^'
     #2a.  q        - enter 'q' to quit uvhd
          ===

 #4. uvhd tmp2/warranty.master t1  <-- see packed field chars substituted in tmp2 OUTPUT
     ============================    - could use option 't1' shows unprintables as '.'s
                                     - BUT, these are now REAL '.' periods (Note below)
     rec#=1 rsize=64 fptr=0 fsize=576 records=9
                     10        20        30        40        50        60
     r#   1 0123456789012345678901234567890123456789012345678901234567890123
          0 12345 12345 sony television   950101 1-year .`.. 00000291q..P...
            3333323333327667276667676662223333332327667226222333333337225220
            1234501234503FE9045C56939FE00095010101D95120E0EE0000002911EE0EEA
                                                         ^ ^^          ^^ ^^
     #4a.  q        - enter 'q' to quit uvhd
          ===

Note - uvfixA replaced unpritnatbles with REAL '.' PERIODs

uvfixA has replaced any packed/binary unprintable characters with REAL "."s x'2E' Do not confuse with the '.' periods that uvhd default option 't' would show for unprintable characters - can use option 't2' to see a difference.

We used option 't2' above for the input file in dat3/warranty.master to show unprintables as ':'s vs option 't' (default t1 shows unprintables as '.'s) Could be confusing since uvfixA replaced unprintables with REAL '.'s x'2E's in the output file tmp2/warranty.master.

For example, byte 44 of input file is x'09' (horizontal hex vs vertical hex) is shown as a ':' by the 1st uvhd above to avoid confusion with byte 44 of the output file, shown as a '.' by the 2nd uvhd because it is a REAL '.' period x'2E'.

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

5G1. uvfix1 - demo Select records by scanning for patterns

SELECT records with 'New' from dat1/USstates1


 #1. rm -f tmp*/*            <-- clear All tmp files
     ============              - tmp*/* same as tmp/* tmp1/* tmp2/*

 #2. uvfix1 dat1/USstates2   <-- run uvfix1 script with input file dat1/USstates1
     =====================     - omitting option & filename prompts
                               - until the '.' prompt for instructions

     #2a. scn b0(100),'New'  <-- scan for 'New' anywhere in the current record
          ================

     #2b. skp! getrec        <-- skip on condition code '!' (not found)
          ===========            to 'getrec', which bypasses output of current record
                               - so output file will contain only 'New' founds

     #2c. .                  <-- enter '.' to signal end of instructions
          ===========            & Execute the get/put cycle until EOF

 #3. cat tmp/USstates2       <-- display the output file
     =================
     030 NH                  New Hampshire       1371250             Concord             42695
     031 NJ                  New Jersey          8936570             Trenton             84913
     032 NM                  New Mexico          2096640             Santa Fe            67947
     033 NY                  New York            19440500            Albany              97856

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

5G2. uvfix1 - demo REPLACE patterns with alternates

Replace 'New' with 'Old' in dat1/USstates1


 #1. rm -f tmp/*            <-- clear tmp/* files
     ===========

 #2. uvfix1 dat1/USstates2         <-- run uvfix1 script with input file dat1/USstates1
     =====================           - omitting option & filename prompts
                                     - until the '.' prompt for instructions

     #2a. rep b0(100),'New','Old'  <-- scan for 'New' anywhere in the current record
          ======================       & replace with 'Old'

     #2b. skp! getrec              <-- skip on condition code '!' (not found)
          ===========                  to 'getrec', which bypasses output of current record
                                     - so output file will contain only New/Old replacements

     #2c. .                 <-- enter '.' to signal end of instructions
          ===========           & Execute the get/put cycle until EOF

 #3. cat tmp/USstates2      <-- display the output file (with New/Old replacements)
     =================
     030 NH                  Old Hampshire       1371250             Concord             42695
     031 NJ                  Old Jersey          8936570             Trenton             84913
     032 NM                  Old Mexico          2096640             Santa Fe            67947
     033 NY                  Old York            19440500            Albany              97856
Note
  • Normally you would omit the 'skp! getrec' when searching/replacing
  • But we did not want to show all 50 output records

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

5G3. uvfix1 - demo Edit & Translate

Edit populations & Translate UPPER/lower case

We will demo both editing & translate UPPER/lower in same job. The translations are impractical but we wanted to demo them without taking up a separate page.


 #1. rm -f tmp/*              <-- clear tmp/* files
     ===========

 #2. head -5 dat1/USstates1   <-- show 1st 5 records of Input file
     ======================
 #       10        20        30        40        50        60        70        80        90       100
 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 abr                 state               state-pop           capital             capital-pop
 AL                  Alabama             4908620             Montgomery          205764
 AK                  Alaska              734002              Juneau              31275
 AZ                  Arizona             7378490             Phoenix             1445632
 AR                  Arkansas            3039000             Little Rock         193524

 #3. uvfix1 dat1/USstates1   <-- run uvfix1 script with input file dat1/USstates1
     =====================     - omitting options screen & filename prompts

     #3a. edt b40(12),a40(20),'zzz,zzz,zz9'  <-- edit state population
          =================================

     #3b. edt b80(12),a80(20),'zzz,zzz,zz9'  <-- edit capital population
          =================================

     #3c. tru b20(20)           <-- translate cols 21-40 to UPPER-case
          ===========

     #3d. trl b60(20)           <-- translate cols 61-80 to lower-case
          ===========

     #3e. .                     <-- enter '.' to signal end of instructions
          ===========              & Execute the get/put cycle until EOF

 #4. head -5 tmp/USstates1      <-- display 1st 10 records of output file
     =====================
     abr                 STATE                          0        capital                        0
     AL                  ALABAMA                4,908,620        montgomery               205,764
     AK                  ALASKA                   734,002        juneau                    31,275
     AZ                  ARIZONA                7,378,490        phoenix                1,445,632
     AR                  ARKANSAS               3,039,000        little rock              193,524

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

5G4. uvfix1 - Left adjust & squeeze multi-spaces to 1 between words

Left adjust & squeeze spaces in dat1/USstates1

In order to demo the 'sqz' squeeze instruction, we will show you the hard way to create a .csv file - by inserting ',' commas between fields & squeezing out spaces. This will be incorrect when fields have embedded spaces. The proper way to create csv files is with the 'var' instruction - see uvcopy3.htm#var.


 #1. rm -f tmp/*             <-- clear tmp/* files
     ===========

 #2. head -5 dat1/USstates1   <-- show 1st 5 records of INPUT file
     ======================
 #       10        20        30        40        50        60        70        80
 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 abr                 state               state-pop           capital             capital-pop
 AL                  Alabama             4908620             Montgomery          205764
 AK                  Alaska              734002              Juneau              31275
 AZ                  Arizona             7378490             Phoenix             1445632
 AR                  Arkansas            3039000             Little Rock         193524

 #3. uvfix1 dat1/USstates1   <-- run uvfix1 with input file dat1/USstates1
     =====================     - omitting option & filename prompts
                               - see the OPTIONS listed on page '5B2'
                               - until the '.' prompt for instructions

     #3a. mvc b19(1),','     <-- insert ',' commas between fields
          ==============
     #3b. mvc b39(1),','
          ==============
     #3c. mvc b59(1),','
          ==============
     #3d. mvc b59(1),','
          ==============
     #3e. sqz b0(100),' '   <-- squeeze out all spaces
          ===============
     #3f. .                 <-- enter '.' to signal end of instructions
          ===========           & Execute the get/put cycle until EOF

 #4. head -5 tmp/USstates1      <-- display 1st 10 records of OUTPUT file
     =====================
      abr,state,state-pop,capital,capital-pop
      AL,Alabama,4908620,Montgomery,205764
      AK,Alaska,734002,Juneau,31275
      AZ,Arizona,7378490,Phoenix,1445632
      AR,Arkansas,3039000,LittleRock,193524

     #3e. sqzc1 b0(100),' '     <-- TRY repeating with option 'c1' on 'sqz'
          ================        - to leave 1 space between fields
                                  - see doc at uvcopy3.htm#sqz

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

5H1. uvfixA - process All files in directory

uvfixA - process All files in the parms/* directory

This example is applicable to mainframe JCL conversions to unix/linux systems. The mainframe parameters (parms) for SORTs, SQL & FTP scripts are often in a separate directory & often have sequence numbers in columns 73-80 which are not required & we want to clear them to make them easier to edit. Clearing 73-80 will also clear back to the last non-blank since that is automatic when writing to text files (typ=LST).


 #1. rm -f tmp*/*      <-- clear tmp files
     ============        - clears tmp/* + tmp1/* + tmp2/*

 #2. cat parms/*       <-- inspect all 4 files in the parms/* directory
     ===========         - note sequence#s in 73-80 (to be cleared)
 # ftps/ftpdemo1
   open 192.168.0.5                                                      00000010
   user user02 user02pw                                                  00000020
   put ar.sales.items C:\AR\SALES.ITEMS                                  00000030
 * sort100
   SORT FIELDS=(78,2,CH,A,61,15,CH,A,11,25,CH,A)                         00000010
 * sort200
   SORT FIELDS=(31,6,CH,A,1,6,CH,A),                                     00000010
   OMIT COND=((11,2,CH,EQ,C'65'),OR,(COND=(11,2,CH,EQ,C'85'))            00000020

 #3. uvfixA parms tmp2 LST  <-- process ALL files in parms/* copying to tmp2/...
     ====================     - omitting options screen & filename prompts
                              - until the '.' prompt for instructions

     #3a. clr b72(8),' '    <-- clear columns 73-80
          ==============
     #3b. .                 <-- enter '.' to execute
          ==============

 #4. vi tmp2/*              <-- inspect a few of the output files
     =========                - if not OK, repeat #2 with corrections
                              - if OK, proceed to copy to new parms/... dir
Note
  • You might wonder why we edited into the 1st 12 bytes of the field (vs all 20) ?
  • Because 'edt' right adjusts into the output field (vs input left adjusted from fix)
  • edt b40(20),a40(20),'zzz,zzz,zz9' <-- would leave no space between edt result & capital
Note
  • we omit showing the output files here, same as above with sequence numbers cleared
  • and with all trailing spaces removed (IE LineFeed after last non-space)
  • you can't see the difference, but trailing spaces are annoying when editing
    and waste file space
Note
  • In real life, you would now copy tmp2/* back to parms/... as below #5a,b,c,d
  • but please omit this for these demos

 #5a. mv parms parms.old    <-- save parms as parms.old until new parms proven OK
 #5b. mkdir parms           <-- make new parms dir for uvfixA output
 #5c. cp tmp2/* parms       <-- copy uvfixA outputs back to the permanent parms/ dir
 #5d. rm -r parms.old       <-- remove the old parms when new versions proven OK

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

5H2. uvfixA - Insert $VARIABLE data into all records

Insert $date8 & $filenames in All files in parms/...


 #1. rm -f tmp*/*      <-- clear tmp files
     ============        - clears tmp/* + tmp1/* + tmp2/*

 #2. cat parms/*       <-- inspect all 4 files in the parms/* directory
     ===========         - any sequence#s will be replaced by $date8

 #3. uvfixA parms tmp2 LST     <-- process ALL files in parms/* copying to tmp2/...
     =====================       - omitting options screen & filename prompts
                                 - until the '.' prompt for instructions

     #3a. mvfv1 b72(8),'$date8'      <-- insert yyyymmdd into cols 73-80
          =====================       - option 'v1' expands $date8 variable

     #3b. mvfv1 b81(19),'$fili1+6'   <-- insert current input filename in cols 82-100
          ========================     - '+6' to drop 'parms/' of parms/current-filename

     #3b. .                 <-- enter '.' to execute
          ==============

 #4. cat tmp2/*             <-- display all output files in tmp2/...
     ==========
 # ftps/ftpdemo1                                                         20200828 ftpdemo1
   open 192.168.0.5                                                      20200828 ftpdemo1
   user user02 user02pw                                                  20200828 ftpdemo1
   put ar.sales.items C:\AR\SALES.ITEMS                                  20200828 ftpdemo1
 * sort100                                                               20200828 pap100s1
   SORT FIELDS=(78,2,CH,A,61,15,CH,A,11,25,CH,A)                         20200828 pap100s1
 * sort200                                                               20200828 parm200s
   SORT FIELDS=(31,6,CH,A,1,6,CH,A),                                     20200828 parm200s
   OMIT COND=((11,2,CH,EQ,C'65'),OR,(COND=(11,2,CH,EQ,C'85'))            20200828 parm200s
 /* select_customers.sql */                                              20200828 selectcustomers
    SELECT * FROM CUSTOMERS;                                             20200828 selectcustomers
Note
  • uvcopy provides access to the values of many $variables
  • lower case variables are stored by uvcopy startup
  • UPPER case variables are usual for external environmental variables
  • see details on the next page

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

5H3. $VARIABLE values provided by uvcopy

  1. See uvcopy2.htm#B7 for the many $variable values provided by uvcopy. Here are 20 more useful ones (of 85 available) & values on Aug28/2020

      uvcopyvars2 - show values of uvcopy $symbols  uvsoft5 uvadm 2020/08/28_11:41:55
      $symbol             definition          character value OR binary below
                                      binary* hexadecimal value   numeric value
      $date8              =y000(08)           20200828
      $datetime           =y020(019)          2020/08/28_11:41:55
      $date               =y020(10)           2020/08/28
      $time               =y031(8)            11:41:55
      $version            =y100(8)            20200825
      $license            =y110(19)           20200825_99V_930630
      $sitename           =y130(030)          UV_Software
      $regname            =y160(030)          Owen_Townsend
      $jobname            =y220(030)          uvcopyvars2
      $hostname           =y280(020)          uvsoft5
      $cwd                =y500(050)          /home/uvadm
      $logname            =y550(050)          uvadm
      $home               =y600(050)          /home/uvadm
      $hscale             =y2300(100)         1.......10........20........30 etc to 100
      $uscale             =y2600(200)         123456789012345678901234567890 etc to 200
      $fili1              =z00000(180)        /home/uvadm/src/uvcopy.c
      $filo1              =z24000(180)        tmp/uvcopy_symbols_values
  1. You can access the values using 'mvfv1' (mvf instruction with option 'v1') Here is an example from the demo above


      mvfv1 b72(8),'$date8'      <-- insert yyyymmdd into cols 73-80
      =====================        - option 'v1' expands $date8 variable
  1. You can access values of external environmental variables using option 'v3'. For example to get your login-name (& store it in cols 100+ of current record)


      mvfv3 b100(20),'${LOGNAME}'   <-- insert login-name in cols 101+ (120 max)
      ===========================     - option 'v3' expands external ${VARIABLE}s
Note
  • You need to surround EXTERNAL VARIABLEs with braces '{' & '}'
  • External (unix) variables UPPER case, Internal (uvcopy) variables lower case

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

5I1. uvfix1 - EASY way to execute uvcopy instructions

uvfix1 demo - create 'neat' column-aligned scripts

'uvfix1' can help you to create good-looking scripts with columns aligned. uvfix1 can do things that are hard to do with 'vi' (or 'vim'), such as copying data from 1 position in a line to a 2nd position at a fixed column.

Example
  • create a script to copy all files from 1 directory to a 2nd directory
  • BUT, we might need to do this for directories with HUNDREDs of files

testfiles provided in demo/dat3

      about.dat3.files
      gl.account.trans
      product.master1
      uvfix.promo
      warranty_master

script created by unix tools - messy, NOT "column-aligned"

cp dat3/about.dat3.files tmp2/about_dat3_files cp dat3/gl.account.trans tmp2/gl_account_trans cp dat3/product.master1 tmp2/product_master1 cp dat3/uvfix.promo tmp2/uvfix_promo cp dat3/warranty_master tmp2/warranty_master

desired script created by uvfix1 - Column-Aligned

 cp dat3/about.dat3.files                tmp2/about_dat3_files
 cp dat3/gl.account.trans                tmp2/gl_account_trans
 cp dat3/product.master1                 tmp2/product_master1
 cp dat3/uvfix.promo                     tmp2/uvfix_promo
 cp dat3/warranty_master                 tmp2/warranty_master

Notes Re sf,sfxx,sfyy directories Script Files

sf
  • Script Files (demo scripts written by UV Software)
sfxx
  • user written scripts - see tutorials ahead (might create with uvfix1)
sfyy
  • answers to user tutorials, for comparison to your scripts
  • but try to write your version in sfxx/... before you look at sfyy/...

FIRST "TRY" to create column aligned script with 'vi'


 #1. rm -f tmp/* tmp2/*          <-- clear tmp* subdirs in the demo/ directory
     ==================

 #2. ls dat3 >sfxx/rename_dat3   <-- capture filenames into the 'sfxx' Script Files subdir
     =========================      assigning an appropriate name

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

5I2. uvfix1 demo - create 'neat' Column-Aligned scripts


 #3. vi sfxx/rename_dat3              <-- edit file list & try to convert into script
     ===================
      about.dat3.files                <-- filenames of testfiles provided
      gl.account.trans
      product.master1
      uvfix.promo
      warranty_master

 #3a. --> :%s/^/cp dat3\//              <-- vi Substitute command to insert 'cp/dat3/'
          =================                - '^' means at begining of line
                                           - '\' to  insert actual '/' (vs end pattern '/')
      cp dat3/about.dat3.files          <-- 'cp dat3/' inserted in front of filenames
      cp dat3/gl.account.trans
      cp dat3/product.master1
      cp dat3/uvfix.promo
      cp dat3/warranty_master

 #3b. --> :%s/$/               tmp2\//  <-- Substitute at '$' (End of Line)
          =============================   - 15 spaces preceding 'tmp2/'
                                          - attempt to separate 2nd column of filenames
      cp dat3/about.dat3.files                tmp2/... vi cannot copy within line ...
      cp dat3/gl.account.trans                tmp2/
      cp dat3/product.master1                tmp2/
      cp dat3/uvfix.promo                tmp2/
      cp dat3/warranty_master                tmp2/
Problem#1
  • inserting 15 spaces (attempt to space 2nd column away from filenames)
    might be nicer than inserting just 1 space, but not aligned as desired.
Problem#2
  • 'vi' has no way to copy the filename to a 2nd position in the line
problem#3
  • you can NOT substitute '.'s with '_'s for only PART of a line

DESIRED script - CAN be created with 'uvfix1' (see below)

      cp dat3/about.dat3.files                tmp2/about_dat3_files
      cp dat3/gl.account.trans                tmp2/gl_account_trans
      cp dat3/product.master1                 tmp2/product_master1
      cp dat3/uvfix.promo                     tmp2/uvfix_promo
      cp dat3/warranty_master                 tmp2/warranty_master

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

5I3. uvfix1 demo - create 'neat' Column-Aligned scripts

create "Column-Aligned" script with 'uvfix1'


 #1. rm -f tmp/* tmp2/*          <-- clear tmp* subdirs in the demo/ directory
     ==================
 #1a. rm -f tmp*/*               <-- same as above, but fewer keystrokes
      ============

 #2. ls dat3 >sfxx/rename_dat3_neat1  <-- capture filenames into the Script Files subdir
     ===============================      assigning an appropriate name

 #3. cat sfxx/rename_dat3_neat1       <-- inspect filenames to be converted into a script
     ==========================
      about.dat3.files             `    <-- filenames of testfiles provided
      gl.account.trans
      product.master1
      uvfix.promo
      warranty_master

 #4. uvcopy uvfix1,fili1=sfxx/rename_dat3_neat1
     ==========================================
        - copy a text file & modify via uvcopy instruction keyins
        - input rec in area a has already been copied to output rec in b
      Note - We have OMITTED several prompts here to change options & show an example
           - enter null to accept the defaults, until you see "enter instruction"
                               <-- enter instruction (or period "." end entries & execute)

 #4a. mvf b0(100),'cp dat3/'   <-- MoVe cp cmd & 1st dir to output area 'b'
      ======================       & Fill remainder of output area with spaces

 #4b. cat b0(100),a0(50)       <-- concatenate the filename onto cp cmd & dir1
      ==================

 #4c. mvc b40(6),','tmp2/'     <-- store 2nd dir at dsplcmnt 40 (column 41)
      ====================

 #4d. cat b40(50),a0(50)       <-- concatenate filename onto destination directory
      ==================

 #4e. rep b40(50),'.','_'      <-- REPlace all '.' periods in 2nd filename with '_' underscores
      ===================

 #4f.  .                       <-- enter '.' to End Instrutions & Execute job
      ===
      20200707:414201:uvfix1: EOF fili01 rds=5 size=132: tf/rename_dat3_neat1
      20200707:414201:uvfix1: EOF filo01 wrts=5 size=317: tmp/rename_dat3_neat1
      EOJ, Output File written to: tmp/rename_dat3_neat1

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

5I4. uvfix1 demo - create 'neat' column-aligned scripts


 #5. cat tmp/rename_dat3_neat1           <-- inspect script created in the tmp/... dir
     =========================             - if problems, repeat #2 thru #2f
      cp dat3/about.dat3.files                tmp2/about_dat3_files
      cp dat3/gl.account.trans                tmp2/gl_account_trans
      cp dat3/product.master1                 tmp2/product_master1
      cp dat3/uvfix.promo                     tmp2/uvfix_promo
      cp dat3/warranty_master                 tmp2/warranty_master

 #6. cp tmp/rename_dat3_neat1 sfxx/      <-- save script in user tutorial scripts directory
     ==============================

 #7. chmod 775 sfxx/rename_dat3_neat1    <-- add execute permissions
     ================================

 #8. sfxx/rename_dat3_neat1              <-- execute the script
     ======================

 #9. sfyy/rename_dat3_neat1   <-- could execute the UV Software answer version
     ======================     - but we hope you will create your own version in sfxx/...

Many rename... scripts provided in $UV/sf/util/...

UV Software already proviides script 'renameP2U' - just ONE of over 40, Here are a few examples, see iall in $UV/sf/util/...

renameL
  • translate All filenames in directory to lower case
renameU
  • translate All filenames in directory to UPPER case
renameX
  • replace eXtension with alternate, renameP Prefix to alternate
renameAA
  • replace Any pattern with any Alternate anywhere in filename
renameB2U
  • change blanks to underscores, renameD2_ '$' signs to '_'s
renameD2U
  • change '$' signs to '_' Underscores
renameP2U
  • change '.' Periods to '_' Underscores
  • many more, all scripts display old/new filenames with seq#

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

5I5. uvfix1 creating scripts with filenames in fixed columns

Explanations of Instructions to create sfxx/rename_dat3_neat1

 We will explain the intructions entered to uvfix1 on lines #4a to #4f above
 - illustrating with the 1st record & showing results of each instruction in area 'b'
 about.dat3.files
 about.dat3.files         <-- area 'a' with 1st record
 ================================================================================
         10        20        30        40        50        60        70        80
 12345678901234567890123456789012345678901234567890123456789012345678901234567890

 about.dat3.files         <-- area 'b' 1st record copied before user instructions
 ================================================================================
                                                      #4a. mvf b0(100),'cp dat3/'
 cp dat3/                                                      <-- results
 ================================================================================
                                                      #4b. cat b0(100),a0
 cp dat3/about.dat3.files
 ================================================================================
                                                      #4c. mvc b40(6),','tmp2/'

 cp dat3/about.dat3.files                tmp2/
 ================================================================================
                                                      #4d. cat b0(100),ax1(50)

 cp dat3/about.dat3.files                tmp2/about.dat3.files
 ================================================================================
                                                      #4e. rep b40(30),'.','_'

 cp dat3/about.dat3.files                tmp2/about_dat3_files
 ================================================================================
                                                      #4f.  .
 ================================================================================
                                                      #5. cat tmp/rename_dat3_neat1
 cp dat3/about.dat3.files                tmp2/about_dat3_files
 cp dat3/gl.account.trans                tmp2/gl_account_trans
 cp dat3/product.master1                 tmp2/product_master1
 cp dat3/uvfix.promo                     tmp2/uvfix_promo
 cp dat3/warranty_master                 tmp2/warranty_master

Notes

  1. Could do some of these steps using an editor (such as 'vi')
  2. But hard to copy data to desired output columns for neat appearance
  3. And hard to restrict operations to desired column ranges

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

5J1. uvfix1 demo - column-aligned EXISTING scripts

Suppose we just want to make an existing script neater by aligning output files at as specified column. As an example we will use the script created in demo but with only 1 space between input tmp1/filenames & output tmp2/filenames:

sf/rename_dat3 - script BEFORE column-alignment

      # rename_dat3 - script to copy/rename files - BEFORE column align outfile names
      #             - see uvfix1 demo#3 in uvsoftware.ca/uvdemos1.htm#5B1 - 5C3
      #             - by Owen Townsend, UV Siftware, August 2020
      cp dat3/about.dat3.files tmp2/about_dat3_files
      cp dat3/gl.account.trans tmp2/gl_account_trans
      cp dat3/product.master1 tmp2/product_master1
      cp dat3/uvfix.promo tmp2/uvfix_promo
      cp dat3/warranty_master tmp2/warranty_master

sfxx/rename_dat3_neat2 - script AFTER column-alignment

      # rename_dat3 - script to copy/rename files - BEFORE column align outfile names
      #             - see uvfix1 demo#3 in uvsoftware.ca/uvdemos1.htm#5B1 - 5C3
      #             - by Owen Townsend, UV Siftware, August 2020
      cp dat3/about.dat3.files                tmp2/about_dat3_files
      cp dat3/gl.account.trans                tmp2/gl_account_trans
      cp dat3/product.master1                 tmp2/product_master1
      cp dat3/uvfix.promo                     tmp2/uvfix_promo
      cp dat3/warranty_master                 tmp2/warranty_master

 #1. rm -f tmp/* tmp2/*   <-- clear tmp* subdirs in the demo/ directory
     ==================

 #2. uvcopy uvfix1,fili1=sf/rename_dat3,uop=c1
     =========================================
        - copy a text file & modify via uvcopy instruction keyins
        - use ',uop=c1' option to pass thru '#' Comment records unchanged
        - use ',uop=d1' option to Delete '#' comment records
        - input rec in area a has already been copied to output rec in b
        - We have OMITTED several prompts here to change options & show an example
        - enter null to accept the defaults, until you see "enter instruction"
                              <-- enter instruction (or period "." end entries & execute)

      #2a. scnn2p a0(100),' !'     <-- scan to 2nd occurrence of space + non-space
           ===================       - option 'n2' for 2nd occurrence
                                     - option 'p' for pattern scan ('!' any non-space)
                                     - scan sets register 'x' to dsplcmnt of found pattern
      #2b. clr bx0(100),' '        <-- clear output dir/file from area 'b'
           ================
      #2c. mvc b40(50),ax1         <-- move ouput dir/file from area 'a' to area 'b' column 40+
           ===============
      #2d. .                       <-- enter '.' period to end entries & execute
           ===
           20200708:153902:uvfix1: EOF fili01 rds=8 size=473: sfxx/rename_dat3
           20200708:153902:uvfix1: EOF filo01 wrts=5 size=381: tmp/rename_dat3

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

5J2. uvfix1 demo - create 'neat' column-aligned scripts


 #3. cat tmp/rename_dat3                   <-- inspect script created in the tmp/... dir
     ===================                     - if problems, repeat #2 thru #2d
      # rename_dat3 - script to copy/rename files - BEFORE column align outfile names
      #             - see uvfix1 demo#3 in uvsoftware.ca/uvdemos1.htm#5B1 - 5C3
      #             - by Owen Townsend, UV Siftware, August 2020
      cp dat3/about.dat3.files                tmp2/about_dat3_files
      cp dat3/gl.account.trans                tmp2/gl_account_trans
      cp dat3/product.master1                 tmp2/product_master1
      cp dat3/uvfix.promo                     tmp2/uvfix_promo
      cp dat3/warranty_master                 tmp2/warranty_master

 #4. copy the new version from tmp/rename_dat3 to permanent Scripts directory
     - renaming to avoid overwriting the original
     - in case you want to rerun this exercise

 #4a. cp tmp/rename_dat3 sfxx/rename_dat3_neat2  <-- copy/renaming to avoid overwrite
      =========================================

 #5. chmod 775 sfxx/rename_dat3_neat2             <-- add execute permissions
     ================================

 #6. sfxx/rename_dat3_neat2                       <-- execute the script
     ======================

 #7. rename_dat3_neat2        <-- will not work because sfxx is not in $PATH
     =================

 #8. sfyy/rename_dat3_neat2   <-- could execute the UV Software answer version
     ======================     - but we hope you will create your own version in sfxx/...

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

5J3. uvfix1 creating scripts with filenames in fixed columns

Explanations of Instructions to create sf/rename_dat3_neat2

 We will explain the intructions entered to uvfix1 on lines #2a to #2d above
 - illustrating with the 1st record & showing results of each instruction in area 'b'

 # rename_dat3 - script to copy a script column aligning output filenames
 ================================================================================
                              #2a. scnn2p a0(100),' !'   <-- scan to 2nd dir/file
         10        20        30        40        50        60        70        80
 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 cp tmp1/about.dat3.files     tmp2/about.dat3.files     <-- area 'a' 1st non-cmt record
 ================================================================================
                             ^---- register 'x' set to 2nd occurrence of space+non-space
                             #2b. clr bx0(100),' '  <-- clear area 'b' from $rx col 29 on

 cp tmp1/about.dat3.files                               <-- area 'b' cleared from col 29+
 ================================================================================
                             #2c. mvc b40(50),ax1   <-- move out dir/file to b+$rx(28)+1

 cp tmp1/about.dat3.files                tmp2/about.dat3.files
 ================================================================================
                             #2d. .                 <-- enter '.' end entries & execute

 #2. cat tmp/rename_dat3_neat2         <-- inspect script created in the tmp/... dir
     ====================
      cp dat3/about.dat3.files                tmp2/about_dat3_files
      cp dat3/gl.account.trans                tmp2/gl_account_trans
      cp dat3/product.master1                 tmp2/product_master1
      cp dat3/uvfix.promo                     tmp2/uvfix_promo
      cp dat3/warranty_master                 tmp2/warranty_master

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

5K1. uvfix1 Tutorials & Exercises

Instruction ERROR msgs & prompt to re-enter

When uvcopy is executed in batch mode (with a pre-edited parameter file of instructions), any error aborts the job & you would correct the parameter file & re-execute.

Since uvfix1 operates in interactive mode, we would not want to abort, so we have an option (rop=e2) to cause prompts for instruction re-entry.

Here is a demo with intentional errors to show you some of the diagnostic error msgs:


 #1. rm -f tmp/*            <-- clear tmp/* files
     ===========

 #2. uvfix1 dat1/Provinces.csv    <-- run uvfix1 script with input file dat1/USstates1
     =========================      - omitting option & filename prompts
                                    - enter nulls until the '.' prompt for instructions

      #2a. fix 0(20),a0(100),',',6
           =======================
           uvcopy uvfix1 ERR - area code a-z missing for op# 1
                                      <-- Re-enter instruction (or "." to Execute)
      #2b. fix b0(20),a0(000),',',6
           =======================
           uvcopy uvfix1 ERR - 0 lth, missing op# 2, invalid tag(3 alpha b4 numeric)
                                      <-- Re-enter instruction (or "." to Execute)
      #2c. fix b0(20),a0(100),',',6
           =======================
           uvcopy uvfix1 ERR - invalid format for operand # 3
                                      <-- Re-enter instruction (or "." to Execute)
      #2d. fix b0(20),a0(100),6,','
           =======================
                                      <-- enter instruction (or "." Execute)
 .
 20200829:513208:uvfix1: EOF fili01 rds=14 size=720: dat1/Provinces.csv
 20200829:513208:uvfix1: EOF filo01 wrts=14 size=1506: tmp/Provinces.csv
 20200829:513208:uvfix1: EOF filo02 wrts=33 size=1737: tmp/Provinces.csv.pf

Notes re Instruction Error msgs

  1. We are not showing the output file since the point of this demo was to show error-messages & prompts to re-enter.

  2. There are many more errmsgs that would terminate the job without offering a re-enter option, but we think we have allowed for all the errors that you might make during interactive instruction entry.

  3. You might experiment with intentional errors & let us know if you find an error which does not allow a re-entry.

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

5L1. uvfix1 Tutorials & Exercises

complete uvcopy job saved in tmp/filename.pf

'uvfix1' is quick & easy, when all you need to do is copy 1 input file to 1 output file & apply a few instructions. This page shows you what you can do when you need more files or need to print total lines, etc.

Actually, uvfix1 saves the created job, as well as executing immediately. The complete job (including file definitions & I/O commands to get & put records) is saved in tmp/... with the same filename as the output file + extension '.pf'.

For example, suppose you want to read dat1/USstates1, accumulating the state populations & printing the total at EOF. You can run uvfix1 with no instructions, save the framework job to a permanent pf/... directory, modify to print totals,& execute the modified job.


 #1. rm -f tmp/*                <-- clear tmp/* files
     ===========

 #2. uvfix1 dat1/USstates1      <-- run uvfix1 script with input file dat1/USstates1
     =====================        - omitting option & filename prompts
                                  - enter nulls until the '.' prompt for instructions
      #2a. .                    <-- enter '.' to end job & write tmp/USstates1.pf
      ========                    - no instructions entered (will modify saved job)

 #3. l tmp/                     <-- list outputs in tmp
     =======
     --> tmp/USstates1          <-- output file (will not be used)
     --> tmp/USstates1.pf       <-- complete uvcopy job with file I/O

 #4. cp tmp/USstates1.pf pfxx   <-- save RE-RUN job in a permanent pf directory
     ========================

 #5. cat pfxx/USstates.pf        <-- display re-run job BEFORE copy/modify
     ====================
 # USstates1.pf - uvcopy job created by --> uvcopy uvfix1,fili1=dat1/USstates1
 #             - stored in tmp/USstates1.pf in case required for modify/rerun
 #             - named same as uvfix1 data output in tmp/... but with '.pf' appended
 rop=r1                #<-- EOF option to view output file (reply vi,cat,more,etc)
 fili1=?dat1/USstates1,typ=LST,rcs=4096       # '?' prompts for change, code your input file
 filo1=?tmp/USstates1,typ=LSTt,rcs=4096   # this would write same filename in tmp/..
 @run
         opn     all                     open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                get record into area 'a'
         skp>    EOF                     (cc set > at EOF)
         mvc     b0(4096),a0             move input area 'a' to output area 'b'
 #-------------------------------------
 #-------------------------------------
 putrec  put     filo1,b0                write to output file from area 'b'
         skp     getrec                  return to get next record
 EOF     cls     all                     close files
         eoj                             end job

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

5L2. modifying uvcopy job saved in tmp/filename.pf

Accumulate total state population to print at EOF


 #6. vi pfxx/USstates1.pf       <-- edit adding instructions to accumulate
     ====================           populations & print totals at End Of Job
 # USstates1.pf - uvcopy job created by --> uvcopy uvfix1,fili1=dat1/USstates1
 #             - saved in tmp/USstates1.pf in case required for modify/rerun
 #             - named same as uvfix1 data output in tmp/... but with '.pf' appended
 #
 # 1. cp tmp/USstates1.pf pfxx    <-- copy to a permanent pf directory
 # 2. vi pfxx/USstates1.pf        <-- edit to modify/add desired instructions
 # 3. uvcopy pfxx/USstates1.pf    <-- rerun modified job
 #
 #Note - This is the modified result of tutorial at www.uvsoftware.ca/uvdemos1.htm#5L1 & 5L2
 #     - marking Additions/Modifications marked on right with <--A--
 #
 uop=q0c0n99r4096      # user option defaults ('n99' means **ALL** records)
 rop=r1                #<-- EOF option to view output file (reply vi,cat,more,etc)
 fili1=?dat1/USstates1,typ=LST,rcs=4096    # '?' prompts for change, code your input file
 filo1=?tmp/USstates1A,typ=LSTt,rcs=4096   # modified outfilename (+A)    <--A#1
 @run
         opn     all                     open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                get record into area 'a'
         skp>    EOF                     (cc set > at EOF)
         mvc     b0(4096),a0             move in-area 'a' to out-area 'b'
 #-------------------------------------
         add     $ca1,a40(20)            Accumulate state-population      <--A#2
         edt     b40(12),a40(20),'zzz,zzz,zz9'   edit state-pop           <--A#3
         edt     b80(12),a80(20),'zzz,zzz,zz9'   edit capital-pop         <--A#4
 #-------------------------------------
 putrec  put     filo1,b0                write to out-file from area 'b'
         skp     getrec                  return to get next record
 #
 EOF     mvf     c0(100),'** Total US states Population'                  <--A#5
         edt     c40(12),$ca1,'zzz,zzz,zz9'                               <--A#6
         put     filo1,c0(100)                                            <--A#7
         cls     all                     close files                      <--A#8
         eoj                             end job

Notes re Added/modified Instructions


 #7. uvcopy pfxx/USstates1.pf      <-- execute the saved & Modified re-run job
     ========================        - see report on the page below:

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

5L3. Accumulate total state population to print at EOF


 #8. more tmp/USstates1    <-- display report from modified re-run job
     ==================
 abr                 state                          0        capital                        0
 AL                  Alabama                4,908,620        Montgomery               205,764
 AK                  Alaska                   734,002        Juneau                    31,275
 AZ                  Arizona                7,378,490        Phoenix                1,445,632
 AR                  Arkansas               3,039,000        Little Rock              193,524
 CA                  California            39,937,500        Sacramento               466,488
 CO                  Colorado               5,845,530        Denver                   600,158
 CT                  Connecticut            3,563,080        Hartford                 124,775
 DE                  Delaware                 982,895        Dover                     36,047
 FL                  Florida               21,993,000        Tallahassee              181,376
 GA                  Georgia               10,736,100        Atlanta                  420,003
 HI                  Hawaii                 1,412,690        Honolulu                 337,256
 ID                  Idaho                  1,826,160        Boise                    205,671
 IL                  Illinois              12,659,700        Springfield              116,250
 IN                  Indiana                6,745,350        Indianapolis             820,445
 IA                  Iowa                   3,179,850        Des Moines               203,433
 KS                  Kansas                 2,910,360        Topeka                   127,473
 KY                  Kentucky               4,499,690        Frankfort                 25,527
 LA                  Louisiana              4,645,180        Baton Rouge              229,493
 ME                  Maine                  1,345,790        Augusta                   19,136
 MD                  Maryland               6,083,120        Annapolis                 38,394
 MA                  Massachusetts          6,976,600        Boston                   617,594
 MI                  Michigan              10,045,000        Lansing                  114,297
 MN                  Minnesota              5,700,670        Saint Paul               285,068
 MS                  Mississippi            2,989,260        Jackson                  173,514
 MO                  Missouri               6,169,270        Jefferson City            43,079
 MT                  Montana                1,086,760        Helana                    28,190
 NE                  Nebraska               1,952,570        Lincoln                  258,379
 NV                  Nevada                 3,139,660        Carson City               55,274
 NH                  New Hampshire          1,371,250        Concord                   42,695
 NJ                  New Jersey             8,936,570        Trenton                   84,913
 NM                  New Mexico             2,096,640        Santa Fe                  67,947
 NY                  New York              19,440,500        Albany                    97,856
 NC                  North Carolina        10,611,900        Raleigh                  403,892
 ND                  North Dakota             761,723        Bismarck                  61,272
 OH                  Ohio                  11,747,700        Columbus                 787,033
 OK                  Oklahoma               3,954,820        Oklahoma City            579,999
 OR                  Oregon                 4,301,090        Salem                    154,637
 PA                  Pennsylvania          12,820,900        Harrisburg                49,528
 RI                  Rhode Island           1,056,160        Providence               178,042
 SC                  South Carolina         5,210,100        Columbia                 129,272
 SD                  South Dakota             903,027        Pierre                    13,646
 TN                  Tennessee              6,897,580        Nashville                601,222
 TX                  Texas                 29,472,300        Austin                   790,390
 UT                  Utah                   3,282,120        Salt Lake City           186,440
 VT                  Vermont                  628,061        Montpelier                 7,855
 VA                  Virginia               8,626,210        Richmond                 204,214
 WA                  Washington             7,797,100        Olympia                   46,478
 WV                  West Virginia          1,778,070        Charleston                51,400
 WI                  Wisconsin              5,851,750        Madison                  233,209
 WY                  Wyoming                  567,025        Cheyenne                  59,466
 ** Total US states Population            330,598,493

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

5L4. Further Enhance to calc state pop % of total USA pop

Further Enhancements

  1. Add page headings with jobname, filname,& $date

  2. Calculate state pop as percentage of total pop - add user option 't' for total pop accumulated by 1st modified report above - declare at begin job on uop=t330698493 to be addressed as $uopbt - insert edited percentage between state-pop & capital city name


 #1. cp pf/USstates1.pf pf/USstates1.pf2  <-- copy 1st job above (USstates1.pf)
     ===================================    - renaming as USstates1.pf2

 #2. vi pf/USstates1.pf2   <-- further enhance as described above
     ===================     - changes marked below with <--EA#_ on right
 # USstates1.pf2 - Further Enhanced version of USstates.pf
 # USstates1.pf  - original uvcopy job created by --> uvcopy uvfix1,fili1=dat1/USstates1
 #               - original saved/rerun job was modified to accumulate state-pop & print total
 # USstates1.pf2 - Further Enhanced to print page headings with jobname,filename,date
 #               - And calculate percentage state-pop of total pop
 #
 #Note - This is the ENHANCED result of tutorial at www.uvsoftware.ca/uvdemos1.htm#5Lr13 - 5L5
 #     - ORIGINAL Additions/Modifications were marked on right with <--A--
 #     - Further ENHANCED additions/modifications marked with <--EA--
 #
 uop=q0c0n99r4096t330598493  # option defaults + Total pop option t=330,598,493 <--EA#1
 #Note - uop t330698493 added from original USstates.pf accumulation total pop
 rop=r1                      # EOF option to view output (reply vi,cat,more,etc)
 fili1=?dat1/USstates1,typ=LST,rcs=4096    # '?' prompts for change, code your input file
 filo1=?tmp/USstates1E,typ=LSTt,rcs=4096   # modiifed outfilename (+E)    <--EA#2
 @run
         opn     all                     open files
         mvfv1   c0(100),'$jobname - US state populations & percentage of total - $date'
         put     filo1,c0(100)            print page heading              <--EA#3
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                get record into area 'a'
         skp>    EOF                     (cc set > at EOF)
         mvc     b0(4096),a0             move in-area 'a' to out-area 'b'
 #-------------------------------------
         add     $ca1,a40(20)            Accumulate state-population      <--A#1
         edt     b40(12),a40(20),'zzz,zzz,zz9'   edit state-pop           <--A#2
         edt     b80(12),a80(20),'zzz,zzz,zz9'   edit capital-pop         <--A#3
         mvn     $ca2,a40(20)            move current state pop to ctr#2  <--EA#4
         mpy     $ca2,1000               multiply 1000 percent 1 decimal  <--EA#5
         div     $ca2,$uopbt             divide by US total pop           <--EA#6
         edt     b53(5),$ca2,'zz9.9'     edit state pop percentage        <--EA#7
 #-------------------------------------
 putrec  put     filo1,b0                write to out-file from area 'b'
         skp     getrec                  return to get next record
 #
 EOF     mvf     c0(100),'** Total US states Population'                  <--A#4
         edt     c40(12),$ca1,'zzz,zzz,zz9'                               <--A#5
         put     filo1,c0(100)                                            <--A#6
         cls     all                     close files                      <--A#7
         eoj                             end job

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

5L5. MODIFY USstates1.pf to calc state pop % of total USA pop

Notes re Calculating state pop % of USA Total pop

Problem
  • We need to have the total USA population to calc state pop,
    But how can we know total pop BEFORE we get total accumulation at EOF ???
Solution
  • Get the total pop from the previous report shown on page '5L3'
    And add it as option 't' on the end of the uop=... options line
 uop=q0c0n99r4096      # options line from pfxx/USstates1.pf job on page '5L2'
                       # - append option 't' with USA total pop in modified job page '5L4'

 uop=q0c0n99r4096t330598493  # option with Total pop option t=330,598,493 <--EA#1
                 ==========  # options line with total pop appended
Note
  • see the modifed report on the page below, with state pop as % of total USA pop
    on all 50 state lines & total pop at end of report

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

5L6. MODIFY USstates1.pf to calc state pop % of total USA pop


 #3. uvcopy pf/USstates1.pf2  <-- Execute further enhanced job
     =======================    - see report below
 USstates1E - US state populations & percentage of total - 2020/09/03
 abr                 state                          0   0.0  capital                        0
 AL                  Alabama                4,908,620   1.4  Montgomery               205,764
 AK                  Alaska                   734,002   0.2  Juneau                    31,275
 AZ                  Arizona                7,378,490   2.2  Phoenix                1,445,632
 AR                  Arkansas               3,039,000   0.9  Little Rock              193,524
 CA                  California            39,937,500  12.0  Sacramento               466,488
 CO                  Colorado               5,845,530   1.7  Denver                   600,158
 CT                  Connecticut            3,563,080   1.0  Hartford                 124,775
 DE                  Delaware                 982,895   0.2  Dover                     36,047
 FL                  Florida               21,993,000   6.6  Tallahassee              181,376
 GA                  Georgia               10,736,100   3.2  Atlanta                  420,003
 HI                  Hawaii                 1,412,690   0.4  Honolulu                 337,256
 ID                  Idaho                  1,826,160   0.5  Boise                    205,671
 IL                  Illinois              12,659,700   3.8  Springfield              116,250
 IN                  Indiana                6,745,350   2.0  Indianapolis             820,445
 IA                  Iowa                   3,179,850   0.9  Des Moines               203,433
 KS                  Kansas                 2,910,360   0.8  Topeka                   127,473
 KY                  Kentucky               4,499,690   1.3  Frankfort                 25,527
 LA                  Louisiana              4,645,180   1.4  Baton Rouge              229,493
 ME                  Maine                  1,345,790   0.4  Augusta                   19,136
 MD                  Maryland               6,083,120   1.8  Annapolis                 38,394
 MA                  Massachusetts          6,976,600   2.1  Boston                   617,594
 MI                  Michigan              10,045,000   3.0  Lansing                  114,297
 MN                  Minnesota              5,700,670   1.7  Saint Paul               285,068
 MS                  Mississippi            2,989,260   0.9  Jackson                  173,514
 MO                  Missouri               6,169,270   1.8  Jefferson City            43,079
 MT                  Montana                1,086,760   0.3  Helana                    28,190
 NE                  Nebraska               1,952,570   0.5  Lincoln                  258,379
 NV                  Nevada                 3,139,660   0.9  Carson City               55,274
 NH                  New Hampshire          1,371,250   0.4  Concord                   42,695
 NJ                  New Jersey             8,936,570   2.7  Trenton                   84,913
 NM                  New Mexico             2,096,640   0.6  Santa Fe                  67,947
 NY                  New York              19,440,500   5.8  Albany                    97,856
 NC                  North Carolina        10,611,900   3.2  Raleigh                  403,892
 ND                  North Dakota             761,723   0.2  Bismarck                  61,272
 OH                  Ohio                  11,747,700   3.5  Columbus                 787,033
 OK                  Oklahoma               3,954,820   1.1  Oklahoma City            579,999
 OR                  Oregon                 4,301,090   1.3  Salem                    154,637
 PA                  Pennsylvania          12,820,900   3.8  Harrisburg                49,528
 RI                  Rhode Island           1,056,160   0.3  Providence               178,042
 SC                  South Carolina         5,210,100   1.5  Columbia                 129,272
 SD                  South Dakota             903,027   0.2  Pierre                    13,646
 TN                  Tennessee              6,897,580   2.0  Nashville                601,222
 TX                  Texas                 29,472,300   8.9  Austin                   790,390
 UT                  Utah                   3,282,120   0.9  Salt Lake City           186,440
 VT                  Vermont                  628,061   0.1  Montpelier                 7,855
 VA                  Virginia               8,626,210   2.6  Richmond                 204,214
 WA                  Washington             7,797,100   2.3  Olympia                   46,478
 WV                  West Virginia          1,778,070   0.5  Charleston                51,400
 WI                  Wisconsin              5,851,750   1.7  Madison                  233,209
 WY                  Wyoming                  567,025   0.1  Cheyenne                  59,466
 ** Total US states Population            330,598,493

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

Part_6. Mass Change Search/Replace Beyond Unix Tools

UVdemos1 - Part 6 - Contents


6A1. Overview of Vancouver Utility Mass Change Utilities
- search/replace depending on multiple patterns present &/or not present
- table summaries based on keywords & offsets to target words
- these tools can save days of manual editing when you need to make mass
  changes to large directories of programs & documentation
- parameter driven tools can do in minutes what otherwise would require
  hours of manual editing or writing a complex C program to accomplish

6B1. scan1d - scan a directory for 1 pattern qualified by 1 or 2 other patterns
that must be or must not be present

6C1. scan2d - scan a directory for matches to multiple patterns in a tablefile
- each entry qualified by 1 or 2 patterns present or not present

6D1. rep1d - scan a directory replacing 1 pattern with an alternate
- qualified by 1 or 2 other patterns present or not present

6E1. rep2d - search/replace by table for all files in a directory
- each entry qualified by 1 or 2 patterns present or not present

6F0. TableJobs - Powerful tool for programmers to analyze problems & plan changes
- build tables of counts & values to be dumped to a report file at EOF.
- specify Key-Words preceding the Target-Words to be table summarized.

6F1. table3d Example - For FTP scripts, table the IP#s following the KeyWord "OPEN",
or table the userids & passwords following the KeyWord "USER".

6G1. Mass Change Project - change all occurences of UVdemos.htm to UVdemos2.htm
- required when we added UVdemos1.htm (preliminary to existing UVdemos.doc).
- Vancouver Utility documentation is 325,518 lines in 152 text files
- UVdemos.doc was just 1 of the 152 files, but there were hundreds of references
  to various pages from many other documents.

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

6A1. Search/Replace Beyond Unix System Tools

Overview of Vancouver Utility Mass Change Utilities

The Vancouver Utilities are invaluable to IT professionals at Unix/Linux sites.

  1. They are much more powerful than grep because they can search for multiple patterns with 1 pass, using AND & OR relationships.

  2. You can specify that the multiple patterns must be found or not found on the same line or on any line in the file, or on 1 or any line between a begining & ending line, that are themselves identified by 1 or multiple patterns.

  3. You can use these tools to investigate problems in text files of any kind: data files, scripts (SQLs, JCLs, FTPs, etc),& any programming language.

  4. You can use these tools to research the impacts of planned changes to your scripts, programs, documentation, etc.

  5. These tools create reports in subdirs (rpts,stats,selects) of the current working directory, automatically named from the file or directories being searched & the report names are concatenated with the patterns used. This allows you to review past searches & easily modify & repeat the search.

  6. The search reports include all relevant info (files,dirs,search patterns,date/time, user,host,etc) to help you document problems & plan proposed changes.

  7. uvcopy makes it easy to do mass changes that would otherwise require many hours of editing or writing specific programs in other languages.

  8. uvcopy has all the power required to deliver solutions much faster than other languages. uvcopy is parameter driven & requires no compiles - the power of assembly without the complexity.

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

6B1. Search/Replace Beyond Unix System Tools

scan1d - scan directory for 1 pattern qualified by other patterns

'scan1d' is a uvcopy job to scan all files in a directory searching for any 1 pattern, qualified by 1 or 2 other patterns (present or not present), creating a report with matching lines, line#s,& total matches by file.


 uvcopy scan1d   - would prompt for directory,arguments,& options
 =============   - better to code directory & arguments on command line
                 - to show on audit report for easier re-runs

command format & arguments


 uvcopy scan1d,fild1=dir,arg1=search-pat,arg2=qual-present,arg3=qual-absent
 ==========================================================================
  ,arg6=searchbgn,arg7=searchend,arg8=match-optns,arg9=viewer,uop=user-optns
  ==========================================================================
   - command format above, see example/demo on page below
 arg1 - search pattern (prefix 0x indicates hex, 0x2C for a comma)
 arg2 - qualifier present (optional)
 arg3 - qualifier absent, or 2nd present if option p2
 arg6 - pattern to begin scanning for search pattern (optional)
      - also see alternative uop=a1 to begin scan by data file line
 arg7 - pattern to end scanning for search pattern (optional)
      - also see alternative uop=b99999 to end scan by data file line
 arg8 (match options): q3 inhibits scanning within quotes
        i = case insensitive (patterns must be entered in lower case)
        p = pattern match chars (@=any alpha,=any numeric,etc)
 uop (user options): q1 causes prompt for change, q0 inhibits prompt
        a1=line(within file) to begin scan,b99999=line# to end scan
        c0=column(within lines, zero rel) begin scan, d256=length of scan
        p1 - qualifier1 Present & qualifier2 Absent'
        p2 - qualifier1 Present & qualifier2 Present'
        p4 - qualifier1 Absent  & qualifier2 Absent'

July 2020 updates

 scan1d,scan2d,rep1d,rep2d updated to create audit reports in rpts/...
 - named as jobname_indir_oudir_searchpattern_replace_pattern_options
 - showing command used to create report, making it easy to rerun
 New doc at uvdemos1.htmPart_6 (vs old doc at scanjobs.htm)
 - using new demo files in $UV/demo/dat1/... (vs $UV/tf/...)

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

6B2. scan1d - scan directory for 1 pattern qualified by other patterns

scan1d demo - scan all files in dat1/* for matches to "Idaho"


 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for online to UVsoftware website
             - /home/userxx/demo/..... for offline on user machines

 #2. uvcopy scan1d,fild1=demo/dat1,arg1=Idaho
     ========================================
      - scan all files in demo/dat1/... searching for "Idaho"
      - output report will default to rpts/demo_dat1_Idaho
      - First --> mkdir rpts <-- if not already present
      - See demo output Report listed below

 #3. cat rpts/scan1d_dat1_Idaho
     ==========================
 Report: rpts/scan1d_dat1_Idaho
 -----> uvcopy scan1d,fild1=dat1,arg1=Idaho
        ============================================================================
 Format: uvcopy scan1d,fild1=indir,arg1=search,arg2=qual1,arg3=qual2,uop=UserOptions
                     ,arg6=searchbgn,arg7=searchend,arg8=MatchOptions
 MatchOptnsArg8: i=Insensetive, q3=notinquotes, p=patternchars(@=alpha,=num,etc)
 UserOptions: a0=BgnScan at bgnfile or arg6 if spcfd, a=BgnScanLine
             b0=EndScan at endfile or arg7 if spcfd, b=EndSscanLine
             c0=BgnScan at dsplcmnt 0 or cdsp, d0=EndScan at 256 or dsplcmnt
             p1=qual1Present & qual2Absent, p2=bothPresent, p4=bothAbsent
 Date=2020/07/20_12:58:00, Host=uvsoft5, User=uvadm, Option-Overrides=
 ====================================================================================
 00101 097  ID  Idaho                Boise City city                            205,671
 00291 287  ID  Idaho                Meridian city                               75,092
 00305rt: rpts/scan1d    2 hits @EOF: dat1/UScities
 00013 ID                  Idaho               Boise               205671
 00051                   1 hits @EOF: dat1/USstates1
 00013 12  ID    Idaho               Boise                  205,671
 00051                   1 hits @EOF: dat1/USstates2
 =======================================================2020/07/20_12:58:03======
 EOD: 4 hits in 3 files of 16 total (1460 lines)
 Note - Audit report saved in rpts/... for later reviews, reruns, changes & reruns
     - includes all info you might need directory & arguments
     - Audit report-name changes to reflect changes you make to indir & arguments

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

6B3. scan1d - scan directory for 1 pattern qualified by other patterns

Alternate Demos Suggested

 Here are some more suggested demos you can run. We will not show the reports
 - but will tell you how many hits to expect (see if your results agree ?).

 #0. rm -f rpts/*   <-- remove any previous audit reports
     ============

 #1. uvcopy scan1d,fild1=dat1,arg1=Vancouver,arg2=BC  <-- search 'Vancouver' And 'BC'
     ===============================================      (arg2 Qualifier-Present)
      - expect 10 hits in 2 files of 13 total

 #2. uvcopy scan1d,fild1=dat1,arg1=Vancouver,arg3=BC  <-- search 'Vancouver' and NOT 'BC'
     ===============================================      (arg3 Qualifier-Absent)
      - expect 1 hit in 1 file of 13 total

 #3. uvcopy scan1d,fild1=dat1,arg1=Richmond,arg2=VA,arg3=BC  <-- 'Richmond' & 'VA', NOT 'BC'
     ======================================================      (arg2 Present, arg3 Absent)
      - expect 3 hits in 3 files of 13 total

 #4. l rpts    <-- list Audit files from alternate demos
     ======
      -rw-rw-r-- 1 uvadm apps 1405 Jul 22 12:45 scan1d_dat1_Richmond_VA_not_BC
      -rw-rw-r-- 1 uvadm apps 2082 Jul 22 12:22 scan1d_dat1_Vancouver_BC
      -rw-rw-r-- 1 uvadm apps 1150 Jul 22 12:23 scan1d_dat1_Vancouver_not_BC
Note
  • Appending search args on audit filenames avoids overwriting previous reports

Run your own scan1d's


 #1. ls dat1      <-- list test file-names available
     =======
      CanadaMPs CanadaProvinces Provinces1 Provinces2
      UScandidates UScandidateups UScities UScongress USstates1 USstates2
      insults nameadrs1 payroll1.dlm

 #2. more dat1    <-- list test-file contents
     =========      - not shown here

 #3. uvcopy scan1d,fild1=dat1,arg1=SearchPattern,arg2=QualifierPresent
                             ,arg3=QualifierAbsent,uop=options
     =================================================================
      - make up your own scan1d's

 #4. l rpts/      <-- list Audit reports, see most recent
     =======        - ReportName includes your filename & arguments

 #5. more rpts/*  <-- inspect your audit reports
     ===========

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

6C1. Search/Replace Beyond Unix System Tools

scan2d - scan directory for matches to patterns in a tablefile

'scan2d' is a uvcopy job to scan all files in a directory searching for any match to a table file of search patterns & optional qualifying patterns, matching lines are written to rpts/... with a filename that identifies the jobname (scan2d), the directory, the table-filename, & any options.


 uvcopy scan2d   <-- would solicit files & arguments
 =============     - better to code directory & arguments on command line
                   - to show on audit report for easier re-runs
 uvcopy scan2d,fild1=indir,fili2=tablefile,arg6=SearchBegin,arg7=SearchEnd
                          ,arg8=MatchOptions,uop=UserOptions
 ==========================================================================
  - command format above, see example/demo on page below
arg6
  • pattern to begin scanning for search pattern
  • also see alternative uop=a1 to begin scan by data file line
arg7
  • pattern to end scanning for search pattern
  • also see alternative uop=b99999 to end scan by data file line
arg8
  • match options:
    i = case insensitive (table & data translated to lower)
    p = pattern match chars (@=any alpha,=any numeric,etc)
    q3 = inhibit scanning within quotes
uop
  • user options:
    a1 = line(within file) to begin scan,b99999=lineto end scan
    c0 = column(within lines, zero rel) begin scan, d256=length of scan
    p1 = qual1 present & qual2 absent, p2 = both qualifiers present
    t1 = qualifiers current table-line, t2 = qualifiers apply to any line

scan2d demo - scan all dat1/* for all matches in a table


 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for online to UVsoftware website
             - /home/userxx/demo/..... for offline on user machines

 #2. cat tf/scan2d.tbl   <-- inspect table file to be used for scan2d demo
     =================     - you could prepare alternates with 'vi'
 # scan2d.tbl - table file to demo --> uvcopy scan2d,fild1=directory,fili2=patterntable
 # scan2d - scan all files in directory for any match in a table of patterns
 # 01-30 - search pattern (ended by 1st tilde)
 # 31-60 - qualifier1, must ALSO be present, if coded (disabled by tildes)
 # 61-80 - qualifier2, must  NOT be present, if coded (disabled by tildes)
 #       - option p1 (default above), option p2 both present
 North Vancouver~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Vancouver~~~~~~~~~~~~~~~~~~~~~WA~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~
 Olympia~~~~~~~~~~~~~~~~~~~~~~~WA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~(table end marker)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

6C2. scan2d - scan directory for matches to patterns in a tablefile

scan2d demo - scan all dat1/* for all matches in a table


 #3. uvcopy scan2d,fild1=dat1,fili2=tf/scan2d.tbl  <-- execute scan2d on demo dir
    =============================================      with demo table-file patterns
      - best to specify indir, tablefile,& any arguments on command line
        (will show on audit report, making it easier for any later reruns)
      - could specify audit report via filo1=..., but it defaults as shown below

 #4. cat rpts/scan2d_dat1_scan2d.tbl   <-- inspect output report
    ===============================
 Report: rpts/scan2d_dat1_scan2d.tbl
 -----> uvcopy scan2d,fild1=dat1,fili2=tf/scan2d.tbl
        ============================================================================
 Format: uvcopy scan2d,fild1=indir,fili2=pattern-table,uop=UserOptions
                     ,arg6=searchbgn,arg7=searchend,arg8=MatchOptions
 MatchOptnsArg8: i=Insensetive, q3=notinquotes, p=patternchars(@=alpha,=num,etc)
 UserOptions: a0=BgnScan at bgnfile or arg6 if spcfd, a=BgnScanLine
             b0=EndScan at endfile or arg7 if spcfd, b=EndSscanLine
             c0=BgnScan at dsplcmnt 0 or cdsp, d0=EndScan at 256 or dsplcmnt
             p1=qualifier1 Present & qualifier2 Absent, p2=both Present
             t1=type 1 table - qualifiers apply only to current line (default)
             t2=type 2 table - qualifiers independent of search patterns
 Date=2020/07/20_12:27:43, Host=uvsoft5, User=uvadm, OptionOverrides=
 ====================================================================================
                     ** Table-File = tf/scan2d.tbl **
 North Vancouver~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Vancouver~~~~~~~~~~~~~~~~~~~~~WA~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~
 Olympia~~~~~~~~~~~~~~~~~~~~~~~WA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ================================================================================
 00048 WA                  Washington          Olympia             46478
 00051                   1 hits @EOF: dat1/USstates1
 00048 47  WA    Washington          Olympia                 46,478
 00051                   1 hits @EOF: dat1/USstates2
 00001 Owen Townsend       4667 Hoskins Rd     North Vancouver, BC Canada V7K2R3
 00008                   1 hits @EOF: dat1/nameadrs1
 00327 327  Wilkinson          Jonathan        North Vancouver               BC Liberal          2015
 00335                   1 hits @EOF: dat1/CanadaMPs
 00142 138  WA  Washington           Vancouver city                             161,791
 00305                   1 hits @EOF: dat1/UScities
 =======================================================2020/07/20_12:27:44======
 EOD: 00005 hits in 0005 files of 0016 total (01460 lines)
 Note - Audit report saved in rpts/... for later reviews, reruns, changes & reruns
     - includes all info you might need directory, table-file, arguments
     - Audit report-name includes any changes you make indir,tablefile,arguments

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

6D1. Search/Replace Beyond Unix System Tools

rep1d - scan a directory replacing 1 pattern with an alternate

'rep1d' is a uvcopy job to scan all files in a directory searching for any 1 pattern & replacing with an alternate pattern. Replacement may be qualified by 1 or 2 other patterns that must be or must not be present.

Note
  • you must create the output directory or remove all files if already existing
  • the output directory defaults to tmp2/ (no need to specify on command line)
  • or you may specify on the command line via ',fild2=...'

 uvcopy rep1d   - directories & arguments will be solicited if omitted
 ============   - could specify on command line as follows:
 uvcopy rep1d,fild1=indir,fild2=outdir,arg1=search,arg2=replace
             ,arg3=qual-present,arg4=qual-absent,arg6=repbgn,arg7=repend
             ,arg8=match-optns,uop=user-optns
 arg1 - search pattern
 arg2 - replacement
 arg3 - qualifier present (optional)
 arg4 - qualifier absent or 2nd qual present if option p2
 arg6 - pattern to begin scanning for search pattern (optional)
      - also see alternative uop=a1 to begin scan by data file line
 arg7 - pattern to end scanning for search pattern (optional)
      - also see alternative uop=b99999 to end scan by data file line
 arg8 (match options): q3 inhibits scanning within quotes
        p - pattern match chars (@=any alpha,=any numeric,etc)
        s - allows match chars in replacement patterns
 uop  - user options (see options on the next page)

rep1d OLD demo


 uvcopy rep1d,fild1=tf,fild2=tmp2,arg1=Canada,arg2=Iceland,arg3=~,arg4=BC,arg8=n
 ==============================================================================
  - output directory will default to tmp2/ if unspecified
  - output audit report will default to 'tmp/indir_searchpattern' if unspcfd
  - demo1 at 'uvsoftware.ca/repjobs.htmE1', listing I/O demo files
  - original demo from around Year 2000

July 2020 updates

 scan1d,scan2d,rep1d,rep2d updated to create audit reports in rpts/...
 - named as jobname_indir_oudir_searchpattern_replace_pattern_options
 - showing command used to create report, making it easy to rerun
 New documentation at 'uvdemos1.htmPart_6'
 - vs old doc at scanjobs.htm & repjobs.htm
 - see July2020 new rep1d demo below

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

6D2. rep1d - scan a directory replacing 1 pattern with an alternate

search all dat1/* replacing 1 pattern with an alternate

Note
  • may qualify replacement with 1 or 2 other patterns that must be present
    on the same line (or 1 patern present & 1 pattern absent)

 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for online to UVsoftware website
             - /home/userxx/demo/..... for offline on user machines

 #2. uvcopy rep1d,fild1=dat1,arg1=Vancouver,arg2=CoastCity,arg4=Liberal
     ==================================================================
      - search/replace 'Vancouver' with 'CoastCity' qualified by 'Liberal'
        in all files of $UV/demo/dat1/...  while copying to $UV/demo/tmp2/...

audit report created in rpts/rep1d_indir_arg1_arg2

 Report: rpts/rep1d_dat1_Vancouver_CoastCity
 -----> uvcopy rep1d,fild1=dat1,arg1=Vancouver,arg2=CoastCity,arg4=Liberal
        ============================================================================
 Format: uvcopy rep1d,fild1=indir,fild2=outdir,arg1=search,arg2=replace
              ,arg3=qual-present,arg3=qual-absent,arg6=repbgn,arg7=repend
              ,arg8=Match-Options,uop=User-Options
 MatchOptions: i=caseInsensetive, q3=NoMatchInQuotes, p=patternchars(@=alpha,=num,etc)
 UserOptions:  a0=BgnScan at bgnfile or arg6 if spcfd, a=BgnScanLine
              b0=EndScan at endfile or arg7 if spcfd, b=EndSscanLine
              c0=BgnScan at dsplcmnt 0 or cdsp, d0=EndScan at 256 or dsplcmnt
              p1=qual1Present & qual2Absent, p2=bothPresent, p4=bothAbsent
 Date=$datetime, Host=$hostname, User=$logname, Option-Overrides=UOPS2
 ====================================================================================
 00075 075  Davies             Don             CoastCity Kingsway            BC NDP              2015
 00165 165  Kwan               Jenny           CoastCity East                BC NDP              2015
 00328 328  Wilson-Raybould    Jody            CoastCity Granville           BC Independent      2015
 00335                   3 reps @EOF: tmp2/CanadaMPs
 00142 138  WA  Washington           CoastCity city                             161,791
 00305                   1 reps @EOF: tmp2/UScities
 00001 Owen Townsend       4667 Hoskins Rd     North CoastCity, BC Canada V7K2R3
 00002 Jenny Townsend      21 Canada Place     CoastCity, BC       Canada V5P3V8
 00008                   2 reps @EOF: tmp2/nameadrs1
 ====================================================== 2020/07/21_10:05:00
 EOD: 6 reps in 3 files of 16 total (1460 lines)
 Audit filename: rpts/rep1d_dat1_Vancouver

'alldiff2' to verify search/replacements


 #3. alldiff2 dat1 tmp2   <-- verify changes as intended & nothing unintended
     ==================     - will match the audit file shown above

 #4. cp tmp2/* dat1       <-- copy back overwriting original files
     ==============

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

6E1. rep2d - search/replace by table for all files in a directory

search/replace all dat1/* using table of patterns/replacements

'rep2d' is a uvcopy job to search all files in a directory, using a search/replace table file of search-patterns & replacement-patterns & optionally qualified by a pattern that must be present & a 2nd pattern that must not be present.

sample search/replace table

 # rep2d.tbl - table file to demo uvcopy rep2d mass change via search/replace table
 # uvcopy rep2d,fild1=indir,fild2=outdir,fili2=patterntable
 # 001-030 - search pattern (ended by 1st tilde)
 # 031-060 - replace pattern (ended by 1st tilde)
 # 061-080 - qualifier#1, must ALSO be present, if coded (disabled by tildes)
 # 081-100 - qualifier#2, must  NOT be present, if coded (disabled by tildes)
 #         - option p1 (default above), option p2 both present
 North Vancouver~~~~~~~~~~~~~~~South Vancouver~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~Liberal~~~~~~~~~~~~~
 New Mexico~~~~~~~~~~~~~~~~~~~~OLD Mexico~~~~~~~~~~~~~~~~~~~~NM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Richmond~~~~~~~~~~~~~~~~~~~~~~Poormond~~~~~~~~~~~~~~~~~~~~~~VA~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(table end marker)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uvcopy rep2d   - directories & arguments will be solicited
 ============   - But, better to code on command line
                - to appear on the audit report, to make reruns easier
 uvcopy rep2d,fild1=indir,fild2=outdir,fili3=table,filo4=auditreport
             ,arg6=RepBgn,arg7=RepEnd,arg8=match-optns,uop=user-optns
 ====================================================================
 arg6 - pattern to begin scanning for search pattern (optional)
      - also see alternative uop=a1 to begin scan by data file line
 arg7 - pattern to end scanning for search pattern (optional)
      - also see alternative uop=b99999 to end scan by data file line
 arg8 (match options): q3 inhibits scanning within quotes
        p - pattern match chars (@=any alpha,=any numeric,etc)
        s - allows match chars in replacement patterns
 uop  - user options (see listed in the audit report below)

July 2020 updates

 scan1d,scan2d,rep1d,rep2d updated to create audit reports in rpts/...
 - named as jobname_indir_oudir_searchpattern_replace_pattern_options
 - showing command used to create report, making it easy to rerun
 New documentation at 'uvdemos1.htmPart_6'
 - vs old doc at scanjobs.htm & repjobs.htm
 - see July2020 new rep2d demo below

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

6E2. rep2d - search/replace by table for all files in a directory

search/replace all dat1/* using table of patterns/replacements


 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for online to UVsoftware website
             - /home/userxx/demo/..... for offline on user machines

 #2. uvcopy rep2d,fild1=dat1,fild2=tmp2,fili3=tf/rep2d.tbl [,filo4=audit-file]
     ============================================================================
     - copy files from dat1/* to tmp2/... using search/replace table tf/rep2d.tbl
     - audit file defaults to rpts/rep2d_dat1_tmp2_rep2d.tbl

audit report created in rpts/rep2d_indir_outdir_tablefile

 Report: rpts/rep2d_dat1_rep2d.tbl
 -----> uvcopy rep2d,fild1=dat1,fild2=tmp2,fili3=tf/rep2d.tbl
        ============================================================================
 Format: uvcopy rep2d,fild1=indir,fild2=outdir,fili3=SearchReplaceTableFile
              ,arg6=searchbgn,arg7=searchend,arg8=MatchOptions,uop=UserOptions
 MatchOptions: i=Insensetive, q3=notinquotes, p=patternchars(@=alpha,=num,etc)
 UserOptions:  a0=BgnScan at bgnfile or arg6 if spcfd, a=BgnScanLine
              b0=EndScan at endfile or arg7 if spcfd, b=EndSscanLine
              c0=BgnScan at dsplcmnt 0 or cdsp, d0=EndScan at 256 or dsplcmnt
              p1=qualifier1 Present & qualifier2 Absent
 Date=2020/07/21_18:16:10, Host=uvsoft5, User=uvadm, OptionOverrides=
 ====================================================================================
                     ** Table-File = tf/rep2d.tbl **
 North Vancouver~~~~~~~~~~~~~~~South Vancouver~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~Liberal~~~~~~~~~~~~~
 New Mexico~~~~~~~~~~~~~~~~~~~~OLD Mexico~~~~~~~~~~~~~~~~~~~~NM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Richmond~~~~~~~~~~~~~~~~~~~~~~Poormond~~~~~~~~~~~~~~~~~~~~~~VA~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~
 ====================================================================================================
 00036=032  NM  OLD Mexico           Albuquerque city                           545,852
 00102 098  VA  Virginia             Poormond city                              204,214
 00305                   2 reps @EOF: tmp2/UScities
 00032 NM                  OLD Mexico          Santa Fe            67947
 00047 VA                  Virginia            Poormond            204214
 00051                   2 reps @EOF: tmp2/USstates1
 00001 Owen Townsend       4667 Hoskins Rd     South Vancouver, BC Canada V7K2R3
 00008                   1 reps @EOF: tmp2/nameadrs1
 ========================================================== 2020/07/21_18:16:14
  EOD: 00007 reps in 0004 files of 0016 total (01460 lines)
 Audit filename: rpts/rep2d_dat1_rep2d

'alldiff2' to verify search/replacements


 #3. alldiff2 dat1 tmp2   <-- verify changes as intended & nothing unintended
     ==================     - will match the audit file shown above

 #4. cp tmp2/* dat1       <-- copy back overwriting original files
     ==============

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

6F0. Vancouver Utility Programming Aids - TableJobs

TableJobs Benefits to Programmers & Analysts

  1. TableJobs build summary tables of counts & values to be dumped to a report file at EOF. There are various TableJobs for various file-types (text,fixed,variable), but we think you will find 'table3d' for text files most useful to supply you with statistics from directories of programs, scripts, parameter files, etc.

  2. You specify a Key-Word preceding the Target-Word to be table summarized. For example, given a directory of JCLs, you could specify KeyWord "PGM" preceding the program name in statements such as "// EXEC PGM=programxx".

  3. For FTP scripts, you could table the IP#s following the KeyWord "OPEN", or table the userids & passwords following the KeyWord "USER". For SQL scripts you could table the table-name following the KeyWord "FROM".

  4. You can also create table summary reports from fixed or variable length data-files which may have packed/binary fields.

  5. You can use Tablejobs to research the impacts of planned changes to your scripts & programs.

  6. TableJobs create reports in subdir stats/... of the current working directory, automatically named from the file or directory concatenated with Keywords used. This allows you to review table history & easily modify & repeat.

  7. The table reports include all relevant info (files,dirs,Keywords,date/time, user,host,etc) to help you document problems & plan proposed changes.

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

6F1. TableJobs - create Table Summaries via Keywords/Targetwords

Example#1 - table summarize all IP#s in FTP scripts

For example, 'table3d' can read all files in the ftps/ directory, searching for KeyWord "open" & count occurrences of the following TargetWord (the IP#).


 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for online to UVsoftware website
             - /home/userxx/demo/..... for offline on user machines

 #2. mkdir stats  <-- make subdir for table3d output reports
     ===========      OR --> rm stats/*  <-- clear reports from old projects

 #3. uvcopy table3d,fild1=ftps,arg1=open
     ===================================
      - read ftps/* search for "open" & count occurrences of following IP#
      - output report created in subdir stats/... & automatically named by concatenating
        directory + keywords separated by underscores
      #Report: /home/uvadm/demo/stats/table3d_ftps_open
      #------> uvcopy table3d,fild1=ftps,arg1=open
      # ==============================================================================
      # - scan all files in directory for a keyword & table counts of following word
      # InDir=ftps  Keyword=open  Qual1=   Qual2=
      # WordSepsBlank=  Options=q1a0b3c0d0f0j0l0m0p1s0t0x0w1
      # - default selects following word, use option w2 to table 2nd word, etc
      # - specify arg1=Keyword,arg2=Qualifier-present,arg2=Qualifier-absent
      # &\,$=/>-<:(.');_*[|]"<--- arg4=punctuation to blank for word separation
      # abcdefghjklpqrsuALPRQ<--- equivalents, easier to enter, may enter "all"
      # Date=2020/07/24_15:43:23, Site=UV_Software, Host=uvsoft5, User=uvadm
      #===============================================================================
      #---> uvcopy table3d,fild1=ftps,arg1=open
      table3d  2020/07/24_15:43:27_209  Counts by Targetword following specified Keyword
      tbl#0001  tblt1f7 e0(48)       <----- argument ----->
      line#   1strec#  %      count  target-word
          1         2  25         1   192.168.0.4
          2         2  25         1   192.168.0.5
          3         2  50         2   192.168.0.6
                      100         4*  *TOTAL*

Notes, Benefits of table3d reports

  1. Output reports are automatically created in subdir stats/... named by concatenating the input directory & keywords separated by '_' underscores. The Report filename is coded on the 1st line of the report.

  2. The uvcopy command used to create the report is coded on the 2nd line, so you can look back at previous runs & repeat them (with modifications as desired).

  3. The reports are date/time stamped with all relevent info (site,host,user,options).

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

6G1. Search/Replace Beyond Unix System Tools

Mass Change Project - all "UVdemos.doc" to "UVdemos2.doc"

Here is a real 'Mass Change Project' that was required at UV Software, when we added this document UVdemos1.htm as a preliminary to the existing UVdemos.htm. It then made sense to change the existing document name to UVdemos2.htm.

The Vancouver Utilities documentation is 325,518 lines in 152 text files. UVdemos.htm was just 1 of the 152 files, but there were hundreds of references to various pages from many other documents.

Note that the .htm files are just text files created with the 'vi' editor and converted to HTML .htm files for the UV Software website (automatically by the 'uvcopy' utility).

Also note that the change was somewhat complicated by the convention of allowing the .htm text files to contain some UPPER case letters (UV), but the HTML files are always all lower case. So the filename changes desired were:

Most of the references would contain a page code, for example:

Such references need to be changed to:

Before attempting mass changes, we should determine the number of changes required, and we can do this with the table analysis & scan tools.

Do not Execute - but Do understand this Example

This documents how I made a mass change to my Vancouver Utilities, but do not attempt to re-execute. The documentation has already been updated & the $UV directory may not be available to the online demos.

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

6G2. Mass Change all UVdemos.xxx to UVdemos2.xxx

Table Analysis to count changes rquired

'uvcopy table3d' can search a directory & count all occurrences of specified patterns.


 #1. cd $UV       <-- change to Vancouver Utilities homedir with subdir doc/...
     ======         - /home/uvadm/ offline OR /home/uvsoft__/uvadm/ online

 #2. mkdir stats  <-- make subdir for table3d output reports
     ===========      OR --> rm stats/*  <-- clear reports from old projects

 #3. uvcopy table3d,fild1=doc,arg1=UVdemos:uvdemos,arg4=all,uop=b1w0
     ===============================================================
      - search all files in doc/* & count occurrences of 'UVdemos' & 'uvdemos'
      - creates report in subdir stats/... as shown below:
 #Report: /home/uvadm/stats/table3d_doc1_UVdemos:uvdemos_all_b1w0
 #------> uvcopy table3d,fild1=doc1,arg1=UVdemos:uvdemos,arg4=all,uop=b1w0
 # ==============================================================================
 # - scan all files in directory for a keyword & table counts of following word
 # InDir=doc1  Keyword=UVdemos:uvdemos  Qual1=   Qual2=
 # WordSepsBlank=&\,$=/>-<:(.');_*[|]"  Options=q1a0b3c0d0f0j0l0m0p1s0t0x0w1b1w0
 # - default selects following word, use option w2 to table 2nd word, etc
 # - specify arg1=Keyword,arg2=Qualifier-present,arg2=Qualifier-absent
 # &\,$=/>-<:(.');_*[|]"<--- arg4=punctuation to blank for word separation
 # abcdefghjklpqrsuALPRQ<--- equivalents, easier to enter, may enter "all"
 # Date=2020/07/24_09:58:50, Site=UV_Software, Host=uvsoft5, User=uvadm
 #===============================================================================
 #---> uvcopy table3d,fild1=doc1,arg1=UVdemos:uvdemos,arg4=all,uop=b1w0
 table3d  2020/07/24_09:58:58_503  Counts by Targetword following specified Keyword
 tbl#0001  tblt1f7 e0(48)       <----- argument ----->
 line#   1strec#  %      count  target-word
     1       133  41       174   UVdemos      <-- to be changed to --> UVdemos2
     2       164  18        77   UVdemos1
     3         2  17        73   UVdemos2
     4       738  19        81   uvdemos      <-- to be changed to --> uvdemos2
     5       166   1         8   uvdemos1
     6       193   2        10   uvdemos2
                 100       423*  *TOTAL*

Note the '#Report: ...' name on the 1st line includes the search args & options, And the 2nd line '#----> ...' shows the uvcopy command used, making it easy to later repeat the command (same or modified) if required.

'arg4=all' causes all(most) punctuation to be blanked, important because words are separated bases on spaces between, so we want to blank any preceding quote, and the '.' period following - uvdemos.htm#1A1 for example.

Options 'uop=b1w0' are critical, default b3 assumes blank Before & After words, 'b1' assumes Blank Before only, lack of 'b2' means do not assume Blank After so search for 'uvdemos' picks up 'uvdemos1' & 'uvdemos2' as well.

option 'w0' tables the search word itself (vs default 'w1' tables following word).

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

6G3. Mass Change all UVdemos.xxx to UVdemos2.xxx

Find all occurrences of patterns to be changed

'uvcopy scan1d' will find all occurrences of the patterns to be changed:


 #1. cd $UV       <-- change to Vancouver Utilities homedir with subdir doc/...
     ======         - /home/uvadm/ offline OR /home/uvsoftxx/uvadm/ online

 #2. mkdir rpts  <-- make subdir for scan1d output reports
     ==========      OR --> rm rpts/*  <-- clear reports from old projects

 #3. uvcopy scan1d,fild1=doc,arg1=uvdemos,arg8=i
     ===========================================
      - search all files in doc/*, selecting lines with 'uvdemos' OR 'UVdemos'
        ('arg8=i' is the case-insensitive option)
      - creates report in subdir rpts/... as shown below:
 #Report: rpts/scan1d_doc_uvdemos_i
 # -----> uvcopy scan1d,fild1=doc,arg1=uvdemos,arg8=i
 #        ============================================================================
 #Format: uvcopy scan1d,fild1=indir,arg1=search,arg2=qual1,arg3=qual2,uop=UserOptions
 #                     ,arg6=searchbgn,arg7=searchend,arg8=MatchOptions
 #MatchOptnsArg8: i=Insensetive, q3=notinquotes, p=patternchars(@=alpha,#=num,etc)
 #UserOptions: a0=BgnScan at bgnfile or arg6 if spcfd, a#=BgnScanLine#
 #             b0=EndScan at endfile or arg7 if spcfd, b#=EndSscanLine#
 #             c0=BgnScan at dsplcmnt 0 or c# dsp#, d0=EndScan at 256 or d# dsplcmnt
 #             p1=qual1Present & qual2Absent, p2=bothPresent, p4=bothAbsent
 # Date=2020/07/23_08:45:58, Host=uvsoft5, User=uvadm, Option-Overrides=
 #====================================================================================
 00671 # - see uvsoftware.ca/uvdemos.htm#1B5 more about RUNLIBS/RUNDATA stub/common profiles
 00673 # 4. Programmer testing/development projects, Example uvsoftware.ca/uvdemos.htm#Part_9
 11398rt: rpts/scan1d    2 hits @EOF: doc/ADMjobs.doc
 00091 #04. https://uvsoftware.ca/uvdemos.htm
 00099      - 'UVdemos' is a great place to start exploring Vancouver Utilities
 01186                   2 hits @EOF: doc/JCLcnv0brief.doc
              ----------- 450 lines omitted --------------
 00302 https://uvsoftware.ca/uvdemos.htm
 00310  - 'UVdemos' is a great place to start exploring Vancouver Utilities
 02295                   2 hits @EOF: doc/jclcnv_uvdemo.doc
 00345 See https://uvsoftware.ca#uvdemos.htm for many powerful uvcopy utilities to select
 04086                   1 hits @EOF: doc/uvhelp.doc
 =======================================================2020/07/23_08:46:04======
 EOD: 424 hits in 19 files of 152 total (325518 lines)

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

6G4. Mass Change all UVdemos.xxx to UVdemos2.xxx

use 'rep2d' to make the mass changes

'uvcopy rep2d' applies a table-file with multiple search/replace patterns while copying all files from 1 directory to a 2nd directory.


 #1. cd $UV       <-- change to Vancouver Utilities homedir with subdir doc/...
     ======         - /home/uvadm/ offline OR /home/uvsoftxx/uvadm/ online

 #2. mkdir rpts  <-- make subdir for scan1d output reports
     ==========      OR --> rm rpts/*  <-- clear reports from old projects

 #3. vi tf/rep2d.tbl_UVdemos2   <-- create table of search/replace patterns
     ========================     - as shown below:
      # rep2d.tbl_UVdemos - table file for uvcopy rep2d mass change to VU documentation
      # 001-030 - search pattern (ended by 1st tilde)
      # 031-060 - replacement pattern (ended by 1st tilde)
      # 061-080 - optional PRESENT qualifier
      # 081-100 - optional NOT-PRESENT qualifier
      UVdemos.~~~~~~~~~~~~~~~~~~~~~~UVdemos2.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      uvdemos.~~~~~~~~~~~~~~~~~~~~~~uvdemos2.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~~~~~~~~ (end of table marker) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 #4. mkdir doc2      <-- make output directory
     ==========

 #5. uvcopy rep2d,fild1=doc,fild2=doc2,fili3=tf/rep2d.tbl_UVdemos2
     =============================================================
      - copy all files from doc/* to doc2/... while searching/replacing
        with table-file tf/rep2d.tbl_UVdemos2
      - creates report in subdir rpts/... as shown below:

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

6G5. Mass Change all UVdemos.xxx to UVdemos2.xxx

use 'rep2d' to make the mass changes


 #6. vi rpts/rep2d_doc_rep2d.tbl_UVdemos2
     ====================================
      - check the search/replace audit report
 #Report: rpts/rep2d_doc_rep2d.tbl_UVdemos2
 # -----> uvcopy rep2d,fild1=doc,fild2=doc2,fili3=tf/rep2d.tbl_UVdemos2
 #===================================================================================================
 #Format: uvcopy rep2d,fild1=indir,fild2=outdir,fili3=SearchReplaceTableFile
 #              ,arg6=searchbgn,arg7=searchend,arg8=MatchOptions,uop=UserOptions
 #MatchOptions: i=Insensetive, q3=notinquotes, p=patternchars(@=alpha,#=num,etc)
 #UserOptions:  a0=BgnScan at bgnfile or arg6 if spcfd, a#=BgnScanLine#
 #              b0=EndScan at endfile or arg7 if spcfd, b#=EndSscanLine#
 #              c0=BgnScan at dsplcmnt 0 or c# dsp#, d0=EndScan at 256 or d# dsplcmnt
 #              p1=qualifier1 Present & qualifier2 Absent
 # Date=2020/07/23_09:02:49, Host=uvsoft5, User=uvadm, OptionOverrides=
 #===================================================================================================
                     ** Table-File = tf/rep2d.tbl_UVdemos2 **
 UVdemos.~~~~~~~~~~~~~~~~~~~~~~UVdemos2.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 uvdemos.~~~~~~~~~~~~~~~~~~~~~~uvdemos2.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ====================================================================================================
 00671=# - see uvsoftware.ca/uvdemos2.htm#1B5 more about RUNLIBS/RUNDATA stub/common profiles
 00673 # 4. Programmer testing/development projects, Example uvsoftware.ca/uvdemos2.htm#Part_9
 11398                   2 reps @EOF: doc2/ADMjobs.doc
 00091 #04. https://uvsoftware.ca/uvdemos2.htm
 01186                   1 reps @EOF: doc2/JCLcnv0brief.doc
                 ------------- 175 lines omitted ---------------
 01180 For example see uvsoftware.ca/uvdemos2.htm#1A1. You could also use for
 02386 UVdemos2.doc - Brief descriptions of uvhd,uvsort,uvcp,uvlist,& uvcopy + tutorials
 02399              - addition to UVdemos2.doc
 03174                   3 reps @EOF: doc2/install.doc
 00345 See https://uvsoftware.ca#uvdemos2.htm for many powerful uvcopy utilities to select
 04086                   1 reps @EOF: doc2/uvhelp.doc
 ============================================================ 2020/07/23_09:03:01
  EOD: 157 reps in 18 files of 152 total (325518 lines)
 Audit filename: rpts/rep2d_doc_rep2d

Notes

You might ask why the 'total hits' from previous 'scan1d' audit report do not match the 'total reps' shown here for 'rep2d' ?

      EOD: 424 hits in 19 files of 152 total (325518 lines)  <-- previous 'scan1d'
      EOD: 157 reps in 18 files of 152 total (325518 lines)  <-- above 'rep2d'

Because we intentionally only inserted the '2' in 'UVdemos.xxx' or 'uvdemos.xxx' on the HTML hyperlink references, but not on general references to just 'UVdemos' which is OK. Main intention was to avoid any hyperlink "file not found"s.

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

Part_7. uvcopy solutions to problems at Unix/Linux sites

Part 7 will demonstrate some of the many powerful features of uvcopy that might provide solutions to the various problems that come up at any computer site. Our intention is to illustrate uvcopy capabilities that go beyond Unix/Linux utilities.

Please study & run the demos provided. You might see similarities to problems you have experienced in the past & we hope uvcopy can help you with solutions in future.

UVdemos1 - Part 7 - Contents


7A1. expandvars1 - copy text files expanding unix ENVIRONMENTAL $VARIABLEs
- used to expand $Variables in DB2 SQL scripts
- you might find useful to front-end some of your scripts

7A2. testevs1 - uvcopy job that to test the 'evs' instruction
- displays common variables $HOME, $LOGNAME, etc & their values
- then prompts you to enter any other $Variables you can think of

7B1. UScongresstbl3 - uvcopy job with 2 tables (could have max 255 in 1 job).
- Congress members by Party & by Party & Sex

7C1. Translate tables - powerful tool that can be used for a lot more than
translating code sets (Ascii to Ebcdic, Ebcdic to Ascii, etc).
We will illustrate how you can use them to solve problems in your data files.

7C2. Translate tables to print files with binary characters
- illustrated with uvcopy job 'printable1' & testdatafile dat3/warranty_master

7C3. Listing of the uvcopy job to translate unprintables to '.' periods
- $HOME/demo/pf/printable1

7C4. Listing of the translate table to translate unprintables to '.' periods
- $UV/srcf/trtprint.c

7C5. Fix problems such as bad data in incoming files to your applications
For example, datafiles with "`" back-quotes instead of "'" single-quotes
Modify a neutral translate table, replacing bad data bytes with desired data bytes

7C6. Listing of uvcopy copy job to translate back-quotes to single-quotes
- $HOME/demo/pf/fixquote1

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

UVdemos1 Part 7 - Contents (continued)


7D1. Indexed Files - typical example is a product master file where the indexed
key-field is the product# - used to lookup the product description & price
 using product# from a sales_item file.

7D2. extendsales2 - uvcopy job to copy the sales_item file, extending with the
product price & description from the product master INDEXED file

7D3. Execute extendsales2 (Indexed file method) showing the input & output files.

7E1. extendsales3 - Table LOAD & Table LOOKUP - alternate method of extending
the sales_item file with product description & price.

7E2. Execute extendsales3 (Table Load/Lookup method) showing the I/O files.

7E3. uvcopy debugger - sample session stepping thru execution of extendsales3,
displaying data areas & registers. This was a short example of uvcopy debugging
And now (as of Nov2020), see Part_8 complete documentation for uvcopy debugging.

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

7A1. uvcopy solutions to problems at Unix/Linux sites

expandvars1 - copy files expanding $VARIABLEs

 # expandvars1 - copy a text file expanding unix ENVIRONMENTAL $VARIABLEs
 #             - copy any file expanding $SYMBOLs (in unix scripts, etc)
 #             - by Owen Townsend, UV Software, March 2018
 #
 # uvcopy expandvars1,fili1=$UV/tf/testexpandvars1,filo1=tmp/testexpandvars1x
 # ==========================================================================
 #  - demo with test file provided, INPUT/OUTPUT shown below:
 #
 # HOME=$HOME HOSTNAME=${HOSTNAME} LOGNAME=$LOGNAME SHELL=${SHELL}  <-- INPUT
 # HOME=/home/uvadm HOSTNAME=uvsoft5 LOGNAME=uvadm SHELL=/bin/bash  <-- OUTPUT
 #
 rop=r1    # option prompt to view output file at EOF
 fili1=?${UV}/tf/testexpandvars1,rcs=256,typ=LST
 filo1=?tmp/testexpandvars1x,rcs=256,typ=LSTt
 @run
         opn    all
 # begin loop to copy expanding $variables
 man20   get    fili1,a0                 get next line
         skp>   man90                    (cc set > at EOF)
         mvc    c0(200),a0               copy in case expand inhibited by '#'
         cmc    a0(1),'#'                #cmts pass thru w/o expanding $VARs ?
         skp=   man40
         evs    b0(200),a0(200)      <-- copy expanding EXTERNAl $VARIABLEs ($HOME,$PWD,etc)
         mvfv1  c0(200),b0(200)        - also expand uvcopy INTERNAL $variables ($date,$time,etc)
 man40   put    filo1,c0                 write to output file
         skp    man20                    repeat loop until EOF
 # EOF - close files & end job
 man90   cls    all
         eoj

Execute expandvars1 with demo file default


 #1. cdm   <-- alias to change to the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for ssh to UVsoftware website
             - /home/userxx/demo/..... for logins on user machines

 #2. uvcopy expandvars1  <-- easy demo, files default as shown above on fili1/filo1
     ==================

 #3. cat tmp/testexpandvars1x  <-- display output, just 1 line I/O shown below
     ========================    - may also be some other #comment lines
     # HOME=$HOME HOSTNAME=${HOSTNAME} LOGNAME=$LOGNAME SHELL=${SHELL}  <-- INPUT
       HOME=/home/uvadm HOSTNAME=uvsoft5 LOGNAME=uvadm SHELL=/bin/bash  <-- OUTPUT

expandvars1 used in DB2 SQL files

See uvdemos2.htm#7F4 - expandvars1 was used to expand $Variables in SQL file input for table unloads in JCL conversions. We needed to redefine the $SYSREC00 output file defined in the JCL/script & the 'db2' utility does not do that.

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

7A2. uvcopy solutions to problems at Unix/Linux sites

testevs1 - uvcopy job to test 'evs' instruction

Note that 'evs' is the critical instruction in the expandvars1 job listed above. 'evs' is just 1 of the 100+ instructions in uvcopy - see uvcopy3.htm#evs.

'$UV/pf/adm/testevs1' is a uvcopy job that was written to test the 'evs' instruction when it was added to the uvcopy utility. Here is the listing with run instructions:

 # testevs1 - test uvcopy instruction 'evs' (test job in $UV/pf/adm/testevs1)
 #          - copy a string expanding environmental-variables
 #          - also see $UV/pf/util/expandvars1 expand $VARIABLEs in any file
 #
 # uvcopy testevs1    <-- execute this job to test the "evs" instruction
 # ===============      - shows a BEFORE & AFTER expansion demo
 #                      - then prompts you to enter your own $Variables
 @run
         msg     '  --- test uvcopy instruction "evs" copy text expanding $VARIABLES ---'
         mvf     a0(200),'homedir=$HOME, user=$LOGNAME, shell=$SHELL, date=$date       <-- demo INPUT'
         msg     a0(200)                show string BEFORE expanding variables
         evs     b0(200),a0(200)    <-- copy from 'a' to 'b' expanding external $VARIABLEs
         mvfv1   c0(200),b0(200)      - also expand uvcopy internal $variables ($date,$time,etc)
         rep     c0(200),'      <-- demo INPUT','<-- demo OUTPUT'  # correct for OUTPUT
         msg     c0(200)                show string AFTER expanding variables
 # Now prompt user to enter any text with $Variables to be expanded
 loop    msga1l1w  ' --- Enter your text containing $VARIABLEs (ex: $HOME, $PWD, $date, etc)'
         skp<    EOF                    goto end job if null entry
         mvf     a0(200),$arg1
 #       ===
         evs     b0(200),a0(200)    <-- copy from 'a' to 'b' expanding $variables
 #       ===
         mvfv1   c0(200),b0(200)      - also expand uvcopy internal $variables ($date,$time,etc)
         msg     c0(200)                show string AFTER expanding variables
         msg     '     Enter another string OR null entry to end job'
         skp     loop
 EOF     eoj

 uvcopy testevs1   <-- Execute 'testevs1'
 ===============     - sample output shown below
   --- test uvcopy instruction "evs" copy text expanding $VARIABLES ---
 homedir=$HOME, user=$LOGNAME, shell=$SHELL           <-- demo INPUT
 homedir=/home/uvtest, user=uvtest, shell=/bin/bash   <-- demo OUTPUT
  --- Enter your text containing $VARIABLEs (ex: $HOME, $PWD,$PS1, etc)
 \$PWD=$PWD  $\HOSTNAME=$HOSTNAME  \$EDITOR=$EDITOR   <-- YOUR INPUT
 \$PWD=/home/uvtest  $\HOSTNAME=uvsoft5  \$EDITOR=vi  <-- YOUR OUTPUT
      Enter another string OR null entry to end job
  --- Enter your text containing $VARIABLEs (ex: $HOME, $PWD,$PS1, etc)

The test run above demonstrates that you can inhibit the $EXPANSION by \escaping the $VARIABLE with the '\' escape character (same as unix).

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

7B1. Table Summary Instructions tbl & tbp

We have already given examples of 'tbl' & 'tbp' on pages '4D1' - '4D3', but we thought it might be useful to give an example of multiple tables in 1 uvcopy job.

demo/pfyy/UScongresstbl3 - sample job with 2 'tbl's

 # UScongresstbl3 - table summarize US Congress members by party & party + sex
 #                - by Owen Townsend, UV Software, July 2020
 rop=r1    #<-- EOF option prompt to view output file (reply vi,cat,more,etc)
 fili1=?dat1/UScongress,typ=LST,rcs=512    # '?' prompts for change, code your input file
 filo1=?tmp/$jobname,typ=LSTt,rcs=512      # write to tmp/$jobname = tmp/UScongresstbl3
 @run
         opn     all                       open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                  get record into area 'a'
         skp>    eof                       (cc set > at EOF)
 #-----------------------------
         tblt1f1 a62(15),'Members by Party'
         mvc     a75(1),a50                move F/M to end of party field
         tblt2f1 a62(15),'Members by Party & Sex'  table by Party & Sex
 #-----------------------------
         skp     getrec                    return to get next record
 # EOF - dump table, close files,& end job
 eof     tbpt1   filo1,'US Congress Members summarized by Party'
         tbpt2   filo1,'US Congress Members summarized by Party & Sex'
         cls     all                       close files
         eoj                               end job

Execute job to summarize provinces & populations


 #1. uvcopy pfyy/UScongresstbl3   <-- Execute
     ==========================

 #2. cat tmp/UScongress.tbl3      <-- display output file
     =======================
 UScongresstbl3  2020/07/31_10:23:23_065  US Congress Members summarized by Party
 tbl#0001  tblt1f1 a62(15)      <----- argument ----->
 line#   1strec#  %      count  Members by Party
     1         2  52       284  Democrat
     2       265   0         2  Independent
     3         1  46       253  Republican
                 100       539*  *TOTAL*
 UScongresstbl3  2020/07/31_10:23:23_065  US Congress Members summarized by Party & Sex
 tbl#0002  tblt2f1 a62(15)      <----- argument ----->
 line#   1strec#  %      count  Members by Party & Sex
     1         2  20       108  Democrat     F
     2         4  32       176  Democrat     M
     3       265   0         2  Independent  M
     4         9   4        23  Republican   F
     5         1  42       230  Republican   M
                 100       539*  *TOTAL*

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

7B2. Table Summary Instructions tbl & tbp

Input file for UScongresstbl3 table job


 #3. more dat1/UScongress   <-- display input data file for UScongresstbl3
     ====================
              ----------- 1st 3 records of 539 -----------
         10        20        30        40        50        60        70        80
 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 001  Abraham             Ralph          19540916  M  LA  rep  Republican
 002  Adams               Alma           19460527  F  NC  rep  Democrat
 003  Aderholt            Robert         19650722  M  AL  rep  Republican

Notes Re: tbl & tbp

  1. The example above shows a uvcopy job with 2 tables, but you could have up to 255 tables in 1 job. Default allows 10 tables, increase via rop=u99. Default allows 4000 table entries for all tables, increase via rop=v9999.

  2. This 'tbl' example is for a custom written uvcopy job, but you do not have to write any uvcopy code to use this powerful feature. 'You can use 'table3d', a pre-programmed utility to search for a keyword & table the following word. Here is the example from page '6F1' which searches FTP scripts for 'open' & tables the IP# following, But adding option 'f1' to prepend the target-word with the current filename. (could use 'uop=f2' to APPEND vs PREPEND.


 #2a. uvcopy table3d,fild1=ftps,arg1=open,uop=f1
      ==========================================
     #Report: /home/uvadm/demo/stats/table3d_ftps_open_f1
     #------> uvcopy table3d,fild1=ftps,arg1=open,uop=f1
     table3d  2020/07/31_14:43:56_434  Counts by Targetword following specified Keyword
     tbl#0001  tblt1f7 e0(48)       <----- argument ----->
     line#   1strec#  %      count  target-word
         1         2  25         1  ftpdemo1a 192.168.0.4
         2         2  25         1  ftpdemo1b 192.168.0.5
         3         2  25         1  ftpget1 192.168.0.6
         4         2  25         1  ftpput1 192.168.0.6
                     100         4*  *TOTAL*
  1. See many more examples of table3d in uvsoftware.ca/uvdemos2.htm#Part_4

  2. See detailed documentation for 'tbp' & 'tbp' at uvsoftware.ca/uvcopy3.htm#tbl

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

7C1. uvcopy solutions to problems at Unix/Linux sites

translate tables

Translate tables are a very powerful tool that can be used for a lot more than translating code sets (Ascii to Ebcdic, Ebcdic to Ascii, etc). We will illustrate how you can use them to solve problems in your data files.

The Vancouver Utilities include several translate tables in $UV/srcf/... such as:


 source     uvcopy-symbol   Description
 =============================================
 asc2ebc.c    $trta2e       ASCII to EBCDIC
 ebc2asc.c    $trte2a       EBCDIC to ASCII
 trtprint.c   $trtper       translate all unprintable characters to '.' periods
 trtunder.c   $trtunder     translate all unprintable characters to '_' underscores
 trtneut.c    $trtneut      Neutral translate table

These tranlate tables are compiled into uvcopy for use by several instructions

tra
tre
trl
tru
trt
  • translate op1 area using translate table specified by op2 uvcopy3.htm#trt
  • op2 translate table could be $trta2e,$trte2a,$trtper,$rtrunder,$trtneut(modified)
  • can copy $trtneut & modify for customized translations to scrub your data

 l $UV/srcf   <-- list translate table names in $UV/srcf/...
 ==========

 vi $UV/srcf/trtprint.c      <-- investigate translate table source code
 ======================        - trtprint.c $trtrper in uvcopy job below

    trt  b0(4096),$trtper    <-- translate instruction from uvcopy job
 =========================     - see uvcopy job 'printable1' on page '7C3'

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

7C2. uvcopy solutions to problems at Unix/Linux sites

translate tables to print files with binary characters

Here is an example of trying to print a file with packed/binary characters:


 #1. cat dat3/warranty_master   <-- try 'cat' or other unix system utilities
     ========================       to print/display files with binary/packed fields
 12345 12345 sony television   950101 1-year 	` 00000291q™P
 22222 11111 refrigerator      960101 2-year 	€ 000004922™`
 33333 22222 dish washer       961231 3-year 	‘# 00000673s™a#
 33333 11111 refrigerator      970101 3-year  000006744™p
 44444 33333 freezer           970101 4-year  00000995u™p
 55555 55555 clothes dryer     991231 5-year !# 000055566™‘#
 66666 66666 blank dates              6-year
                                             000066600œ <-- x'0C' Breaks Line
 77777 77777 zero/blank dates  000000 7-year
                                             00007770p
 99999 99999 nines dates       999999 7-year	™™œ 00009999y™™™œ
Note
  • packed field signs x'0C' are the worst problem, since that is a FormFeed
  • causes line break on screen & worse if sent to printer
  • causes skip to next page, often causing 1 line per page

 #2. uvcopy printable1,fili1=dat3/warranty_master  <-- print with uvcopy job
     ============================================
Note
  • $UV/pf/util/printable1 is a uvcopy job using a translate table to translate
    packed/binary characters to '.' PERIODs, output file in tmp/...

 #3. cat tmp/warranty_master   <-- display 'cleaned-up' copy of dat3/warranty_master
     =======================     - with any unprintable chars converted to '.' periods
 12345 12345 sony television   950101 1-year .`.. 00000291q..P..
 22222 11111 refrigerator      960101 2-year .... 000004922..`..
 33333 22222 dish washer       961231 3-year ..#. 00000673s..a#.
 33333 11111 refrigerator      970101 3-year .... 000006744..p..
 44444 33333 freezer           970101 4-year .... 00000995u..p..
 55555 55555 clothes dryer     991231 5-year .!#. 000055566...#.
 66666 66666 blank dates              6-year .... 000066600.....
 77777 77777 zero/blank dates  000000 7-year .... 00007770p.....
 99999 99999 nines dates       999999 7-year .... 00009999y.....

 #4. uvhd /home/uvadm/demo/tmp1/wm t   <-- uvhd to show rec#7 with 1st Line Break
     ===============================
      rec#=7 rsize=64 fptr=384 fsize=576 records=9
                        10        20        30        40        50        60
      r#     7 0123456789012345678901234567890123456789012345678901234567890123
           384 66666 66666 blank dates              6-year .... 000066600......
               3333323333326666626676722222222222222327667200002333333333000090
               6666606666602C1EB041453000000000000006D95120000C00000666000001CA
Note
  • byte# 47 x'0C' packed zero + sign same as FormFeed causes line/page breaks

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

7C3. translate tables to print files with binary characters

printable1 - uvcopy job to print files with binary chars


 #5. cat $UV/pf/util/printable1   <-- inspect uvcopy job to copy files translating
     ==========================       any unprintable chars to '.' periods
 # printable1 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/util/...
 # printable1 - copy a file, translating any packed/binary chars to '.' periods
 #            - by Owen Townsend, UV Software, Jan2014, update Jul2020
 #
 # pf/util/printable1 - for text files with LineFeeds (see printable2 if no LineFeeds)
 # pf/util/listrec1   - alternate job for text files that lists in 100 byte segments
 # sf/util/printable1 - script using 'tr', vs uvcopy job, same name in sf/util vs pf/util
 #
 opr='$jobname - copy a file, translating any unprintable characters to periods'
 opr='         - default output file to tmp/... with same name as input file'
 rop=r1   # EOJ prompt to view output file (vi,cat,more,lp,uvlp13,etc)
 fili1=?input,typ=LST,rcs=4096
 filo1=?tmp/$fili1,typ=LSTt,rcs=4096
 @run
        opn    all                      open files
 # begin loop to get & put records until EOF
 getrec get    fili1,a0                 get record into area 'a'
        skp>   eof                      (condition code set > at EOF)
        mvc    b0(4096),a0              move input record to output area 'b'
 #-------------------------------
        trt    b0(4096),$trtper         translate any unprintables to '.' periods
 #-------------------------------
        put    filo1,b0                 write record to output file
        skp    getrec                   return to get next record
 eof    cls    all                      close files
        eoj                             end job

Notes re the 'trt' instruction

  1. See the translate table listed on the next page. Source code ($UV/srcf/trtprint.c) is compiled into uvcopy & can be addressed as '$trtper' (shown above on trt instruction).

  2. 'trt' replaces each byte of op1 with the contents of a byte in the translate table whose address is calculated by adding the binary value of the contents to the base address of op2 which must be a 256 byte area (translate table).

  3. In the ASCII character set, the 1st 32 bytes with values x'00' - x'1F' are unprintable control codes & $trtper will replace them with '.' periods

  4. The next 96 bytes with values x'20' - x'7F' are the printable ASCII characters & $trtper will replace them with contents from corresponding locations, BUT, these have the same values as the printable chars (so they will be unchanged).

  5. The Last 128 bytes are extended Ascii (foreign languages & grpahic characters). Op1 bytes with values x'80' - x'FF' will be replaced with the '.' periods stored at these locations.

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

7C4. uvcopy solutions to problems at Unix/Linux sites

$UV/srcf/trtprint.c - translate unprintables to periods

 /* trtprint.c - translate table - convert unprintable chars to periods */
 unsigned char trtprint[256] = {
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 /*NUL SOH  STX  ETX  EOT  ENQ  ACK  BEL   BS   HT   LF   VT   FF   CR   SO   SI */
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 /*DLE DCL  DC2  DC3  DC4  NAK  SYN  ETB  CAN   EM  SUB  ESC   FS   GS   RS   US */
 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
 /*     !    "    #    $    %    &    '    (    )    *    +    ,    -    .    / */
 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
 /*0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ? */
 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
 /*@    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O */
 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
 /*P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _ */
 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
 /*`    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o */
 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x2E,
 /*p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~      */
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E
 };

How Translate Tables work

Input data bytes are replaced with the contents of a byte in the translate table whose address is calculated by adding the binary value of the input data byte to the base address of the translate table which is a 256 bytes (all possible values of an 8 bit byte - x'00' - x'FF', decimal 0 - 255).

So, for the trtprint.c translate table shown above:

  1. The ASCII control characters in the 1st 32 of the 256 byte translate table will be translated to PERIODs (coded as x'2E' to keep the table neat).

  2. The printable ASCII characters x'20' to x'7F' will be unchanged, since the table replacement is the same as the input data bytes.

  3. The extended ASCII characters x'80' to x'FF' will be translated to PERIODs

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

7C5. uvcopy solutions to problems at Unix/Linux sites

fix problems by modifying a neutral translate table

You can use the neutral translate table to fix unique problems in the data inputs to your applications. For example, some incoming data might use "`" back-quotes instead of "'" single-quotes.

You can fix this problem with the uvcopy job listed on teh next page, but 1st we will show the neutral translate table & explain how you can modify it for the fix.

$UV/srcf/trtneut.c - Neutral Translate Table

 /* trtneut.c - translate table - neutral, use as basis to create others */
 unsigned char trtneut[256] = {
 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
 /*NUL SOH  STX  ETX  EOT  ENQ  ACK  BEL   BS   HT   LF   VT   FF   CR   SO   SI */
 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
 /*DLE DCL  DC2  DC3  DC4  NAK  SYN  ETB  CAN   EM  SUB  ESC   FS   GS   RS   US */
 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
 /*     !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /  */
 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
 /*0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?  */
 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
 /*@    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O  */
 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
 /*P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _  */
 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
 /*`    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o  */
 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
 /*p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~       */
 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
 };

Note that the "`" backquote Ascii value is x'60' & we can simply replace the character at this location with a single-quote - using the following instruction (extracted from the job listed on the next page).

 #-------------------------------
        mvc    c96(1),x'27'             replace back-quote with single-quote
 #-------------------------------

We use decimal displacement 96 since hex x'60' is (6*16) = 96. So the 0x60 line is modified as shown below:

0x60,0x61,0x62,0x63 ... <-- original /*' a b c ... <-- single-quote "'" replaces back-quote "`" 0x27,0x61,0x62,0x63 ... <-- single quote hex value 0x27

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

7C6. uvcopy solutions to problems at Unix/Linux sites

fixquote1 - copy translating back-quotes to single-quotes

 # fixquote1 - uvcopy Parameter File stored in: /home/uvadm/pf/demo/...
 # fixquote1 - copy a file translating any "`" back-quotes to "'" single-quotes
 #           - by Owen Townsend, UV Software, July 2020
 # demo/example - for users to copy/rename/modify to fix similar problems
 #
 opr='$jobname - copy a file translating any back-quotes to single-quotes'
 rop=r1   # EOJ prompt to view output file (vi,cat,more,lp,uvlp13,etc)
 fili1=?input,typ=LST,rcs=4096
 filo1=?tmp/$fili1,typ=LSTt,rcs=4096
 @run
        opn    all                      open files
        mvc    c0(256),$trt             copy neutral translate table to area 'c'
 #-------------------------------
        mvc    c96(1),x'27'             replace back-quote with single-quote
 #-------------------------------
 # begin loop to get & put records until EOF
 getrec get    fili1,a0                 get record into area 'a'
        skp>   eof                      (condition code set > at EOF)
        mvc    b0(4096),a0              move input record to output area 'b'
 #-------------------------------
        trt    b0(4096),c0(4096)        translate changing any back-quotes to single-quotes
 #-------------------------------
        put    filo1,b0                 write record to output file
        skp    getrec                   return to get next record
 eof    cls    all                      close files
        eoj                             end job

test trtfixquote1


 #1. cat testfixquote1    <-- investigate INPUT test-data-file (listed below)
     =================      - Note '`' back-quotes
      # testfixquote1 - test data file for uvcopy job `$UV/pf/demo/fixquote1'
      #    `fixquote1` copies a file translating any `back-quotes` to "single-quotes"
      # - demos modifying a `neutral` translate table to clean-up inputs to your applications

 #2. uvcopy fixquote1,fili1=tf/testfixquote1  <-- execute fixquote1 with testfile
     =======================================
      - output file will be in tmp/... with same filename as input by default
      - could append ",filo1=..." to specify outdir/outfile as desired

 #3. cat tmp/testfixquote1    <-- investigate OUTPUT test-data-file (listed below)
     =====================      - Note '`' back-quotes REPLACED by single-quotes
      # testfixquote1 - test data file for uvcopy job '$UV/pf/demo/fixquote1'
      #    'fixquote1' copies a file translating any 'back-quotes' to "single-quotes"
      # - demos modifying a 'neutral' translate table to clean-up inputs to your applications

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

7D1. Indexed Files

A typical example of an Indexed file is a product master file where the indexed key-field is the product#. It can be used to lookup the product description & price using the product# from a sales_item file. Here are our demo files:

dat2/product_master - Indexed by product#

 # product_master - Indexed on product# looked-up for description & price
 #        1         2         3         4         5
 #2345678901234567890123456789012345678901234567890
 #prod#====Description===========price=============
 BBQ010    BAR-B-Q             0019500
 CHR015    LAWN CHAIR          0004500
 HAM010    CLAW HAMMER         0000950
 HAM035    JACK HAMMER         0029500
 SAW011    HAND SAW            0001975
 SAW012    RIP SAW             0002500
 SAW051    POWER SAW           0008500
 TAB012    LAWN TABLE          0008500

dat2/sales_items - sequential file

 # sales_items - to demo extendsales2 table load & table lookup
 #        1         2         3         4         5         6         7         8
 #2345678901234567890123456789012345678901234567890123456789012345678901234567890
 #cust#=slm===date====invoice==product====qty===price==amount===description======
 130140  44 20200801 INV11001  HAM010  000010
 130140  44 20200801 INV11001  CHR015  000020
 139923  21 20200802 INV11002  BBQ010  000010
 139923  21 20200802 CR5421    SAW051  000005
 250825  44 20200803 INV11003  HAM099  000004
 401210  21 20200804 INV11004  SAW011  000025

tmp/sales_itemsx1 - Extended with product price & description

 # sales_itemsx1 - to demo extendsales2 table load & table lookup
 #        1         2         3         4         5         6         7         8
 #2345678901234567890123456789012345678901234567890123456789012345678901234567890
 #cust#=slm===date====invoice==product===qty===price==ExtAmount=description======
 130140  44 20200801 INV11001  HAM010  000010 0000950 000009500 CLAW HAMMER
 130140  44 20200801 INV11001  CHR015  000020 0004500 000090000 LAWN CHAIR
 139923  21 20200802 INV11002  BBQ010  000010 0019500 000195000 BAR-B-Q
 139923  21 20200802 CR5421    SAW051  000005 0008500 000042500 POWER SAW
 250825  44 20200803 INV11003  HAM099  000004                    ** ERR product# INVALID **
 401210  21 20200804 INV11004  SAW011  000025 0001975 000049375 HAND SAW

We will use uvcopy job demo/pf/extendsales2 as follows:


 uvcopy extendsales2,fili1=dat2/sales_items,filr2=dat2/product_master,filo1=tmp/sales_itemsx1
 ============================================================================================
 - fili1=dat2/sales_items    - read sequentially
 - filr2=dat2/product_master - read Randomly using product# from sales_items records
 - filo1=tmp/sales_itemsx1   - written sequentially with price,amount,description added

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

7D2. Indexed Files

extendsales2 - uvcopy using Indexed file

 # extendsales2 - copy sales items adding prices & descriptions from Indexed product master
 #              - to demo Indexed files
 #              - must 1st load product_master into an Indexed file as follows:
 #
 # uvcp "fili1=dat2/product_master,typ=LST,rcs=100,filo1=dat2/product_masterI,typ=ISF,rcs=99,isk1=0(6)"
 # ====================================================================================================
 #
 # uvcopy extendsales2,fili1=dat2/sales_items,filr2=dat2/product_masterI,filo1=tmp/sales_itemsx1
 # =============================================================================================
 # uvcopy extendsales2   <-*- same as above, but easier, files default as shown above
 # ===================
 #
 rop=r1     # EOF option prompt to viiew output file (vi,cat,lp,etc)
 fili1=?dat2/sales_items,rcs=100,typ=LST                # sales item file
 filr2=?dat2/product_masterI,rcs=99,typ=ISF,isk1=0(6)   # product master Indexed file *Note1*
 filo1=?tmp/sales_itemsx1,rcs=100,typ=LST               # output items extended w price/dscrptn
 @run
        opn    all                      open all files
 # begin loop: read sales items, extending with price & dscrptn from Indexed file
 man20  get    fili1,a0                 read next sales item record
        skp>   man90                    (cc set > at EOF)
        cmc    a0(1),'#'                #comment to bypass ?
        skp=   man20
        mvc    b0(100),a0               copy input to output area
        mvf    c0(100),a30(6)           store product# in key position & clear remainder
        redm5  filr2,c0(100)            read key equal (option m5) *Note2*
        skp=   man30                    (cc equal if match)
 man28  mvf    b63(30),' ** ERR product# INVALID **'
        skp    man40
 man30  mvn    b45(7),c30(7)            price from product_master Indexed file
        mvn    b53(9),c30(7)            price to amount for extension
        mpy    b53(9),b38(6)            master price * item qty = extended amount
        mvc    b63(20),c10              product dscrptn from Indexed file
 man40  put    filo1,b0                 write output
        skp    man20                    return to get next record
 #
 # EOF - close files & end job (rop=r1 prompts to show output file)
 man90  cls    all
        eoj
 #
 #                         ** Notes Re: Indexed file **
 #
 #Note1 - Indexed files have 2 partitions: product_masterI.dat & product_masterI.idx (in this case)
 #      - the ".idx" is binary, but the ".dat" data partition can be viewed & printed with unix tools
 #        because Indexed file records have a status byte appended which is normally x'0A' (a LineFeed)
 #      - we specified "rcs=99" on filr2=... because we wanted the result to be 100 bytes
 #        (we could have specified 38 bytes for this demo, but we might later add more product info)
 #Note2 - 'redm5' random read option 'm5' means key= to value stored in key position (1st 6 bytes)
 #      - see uvcopy3.htm#red for documentation on reading Indexed files
 #      - see uvcp.htm#D2 or uvsort.htm#A2 for more examples of loading Indexed files

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

7D3. Indexed Files

Execute uvcopy extendsales2 Indexed file method


 #1. cdm   <-- ensure you are in the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for ssh to UVsoftware website
             - /home/userxx/demo/..... for logins on user machines

Before we can run our demo, we must 1st load the Indexed file with uvcp or uvsort:


 #2. uvcp "fili1=dat2/product_master,typ=LST,rcs=100,filo1=dat2/product_masterI,typ=ISF,rcs=99,isk1=0(6)"
     ===================================================================================================

 #2a. uvsort "fili1=dat2/product_master,typ=LST,rcs=100,filo1=dat2/product_masterI,typ=ISF,rcs=99,key1=0(6)"
      =====================================================================================================
       - see uvcp.htm#D2 or uvsort.htm#A2 for more examples of loading Indexed files

 #3. cat dat2/product_masterI.dat  <-- display the Product Master INDEXED file
     ============================    - only 1st 3 records, see all 8 on page '7D1' above
      # product_master - Indexed on product# looked-up for description & price
      #        1         2         3         4         5
      #2345678901234567890123456789012345678901234567890
      #prod#====Description===========price=============
      BBQ010    BAR-B-Q             0019500
      CHR015    LAWN CHAIR          0004500
      HAM010    CLAW HAMMER         0000950

 #4. cat dat2/sales_items     <-- display the sales_items SEQUENTIAL INPUT file
     ====================       - only 1st 3 records, see all 6 on page '7D1' above
      # sales_items - to demo extendsales2 table load & table lookup
      #        1         2         3         4         5         6         7         8
      #2345678901234567890123456789012345678901234567890123456789012345678901234567890
      #cust#=slm===date====invoice==product====qty===price==amount===description======
      130140  44 20200801 INV11001  HAM010  000010
      130140  44 20200801 INV11001  CHR015  000020
      139923  21 20200802 INV11002  BBQ010  000010

 #5. uvcopy extendsales2,fili1=dat2/sales_items,filr2=dat2/product_masterI,filo1=tmp/sales_itemsx1
     =============================================================================================
      - copy sales_items, looking-up product_master Indexed file, to get price & description

 #5a. uvcopy extendsales2   <-*- same as above but easier, filenames default as shown above
      ===================      - see filenames coded within the job listed on page above

 #6. cat tmp/sales_itemsx1  <-- investigate the OUTPUT file
     =====================    - Note addition of--> price  ExTAmount Description
      130140  44 20200801 INV11001  HAM010  000010 0000950 000009500 CLAW HAMMER
      130140  44 20200801 INV11001  CHR015  000020 0004500 000090000 LAWN CHAIR
      139923  21 20200802 INV11002  BBQ010  000010 0019500 000195000 BAR-B-Q
      139923  21 20200802 CR5421    SAW051  000005 0008500 000042500 POWER SAW
      250825  44 20200803 INV11003  HAM099  000004                    ** ERR product# INVALID **
      401210  21 20200804 INV11004  SAW011  000025 0001975 000049375 HAND SAW

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

7E1. Table Load & Table Lookup

extendsales3 - table load/lookup (vs Indexed file)

 # extendsales3 - copy sales items adding prices & descriptions from product master
 #              - demo Table Load & Table Lookup Aug2020
 # - using uvcopy instructions 'rtb' Read TaBle & 'lok' Look up table
 # - load product master file into memory table at begin job
 # - extend sales items by looking up product master for price & description
 #
 # uvcopy extendsales3,fili1=dat2/sales_items,fili2=dat2/product_master,filo1=tmp/sales_itemsx2
 # ============================================================================================
 # uvcopy extendsales3   <-*- same as above, but easier, filenames default as shown above
 # ===================
 #
 rop=r1     # EOF option prompt to viiew output file (vi,cat,lp,etc)
 fili1=?dat2/sales_items,rcs=100,typ=LST      # sales item file
 fili2=?dat2/product_master,rcs=100,typ=LST   # product master file
 filo1=?tmp/sales_itemsx2,rcs=100,typ=LST     # output items extended w price/dscrptn
 @run
        opn    all                      open all files
        rtbc1  fili2,c0(100),c0(100)    read product master into memory area 'c'
 #                                      option 'c1' bypasses #comment lines
 # begin loop: read sales items, extending with price & dscrptn from table lookup
 man20  get    fili1,a0                 read next sales item record
        skp>   man90                    (cc set > at EOF)
        cmc    a0(1),'#'                #comment to bypass ?
        skp=   man20
        mvc    b0(100),a0               copy input to output area
        lokz1  cc0(100),cc0(6),a30(6)   lookup table by product code
        skp=   man30                    (skp cc equal if match)
 man28  mvf    b63(30),' ** ERR product# INVALID **'
        skp    man40
 man30  mvn    b45(7),cc30(7)           price from table
        mvn    b53(9),cc30(7)           price to amount for extension
        mpy    b53(9),b38(6)            master price * item qty = amount
        mvc    b63(20),cc10             product dscrptn from table
 man40  put    filo1,b0                 write output
        skp    man20                    return to get next record
 # EOF - close files & end job (rop=r1 prompts to show output file)
 man90  cls    all
        eoj
 #
 #    ** Re: 'lokz1 cc0(100),cc0(6),a30(6)' Area 'c' Register 'c' **
 #
 # - 1st 'c' of cc0 is area 'c', 2nd 'c' of cc0 is Index Register 'c'
 # - option 'z1' ensures Register 'c' reset to 0
 # - lok instruction searches the 100 byte table entries loaded by 'rtb'
 #   for a match on 1st 6 bytes to product# from columns 31-36 of sales_items
 # if Match - cc = (if Nomatch cc unequal causing ERR msg & skp man40 output)
 # if Match - table lookup register 'c' will hold displacement to the matching entry
 # if match on 3rd table entry Register 'c' will be 200 & cc30 will be 230 in area c
 # - see more about Index Registers at uvcopy2.htm#H0 - H7.
 # - see more about 'rtb' Read files & TaBle in memory at uvcopy3.htm#rtb
 # - see more about 'lok' LOoK up tables in memory at uvcopy3.htm#lok

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

7E2. Table Load & Table Lookup

Execute uvcopy extendsales3 - Table Load/Lookup method


 #1. cdm   <-- ensure you are in the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for ssh to UVsoftware website
             - /home/userxx/demo/..... for logins on user machines

 #2. cat dat2/sales_items     <-- display the sales_items INPUT file
     ====================       - only 1st 3 records, see all 6 on page '7D1' above
      # sales_items - to demo extendsales2 table load & table lookup
      #        1         2         3         4         5         6         7         8
      #2345678901234567890123456789012345678901234567890123456789012345678901234567890
      #cust#=slm===date====invoice==product====qty===price==amount===description======
      130140  44 20200801 INV11001  HAM010  000010
      130140  44 20200801 INV11001  CHR015  000020
      139923  21 20200802 INV11002  BBQ010  000010

 #3. cat dat2/product_master  <-- display the Product Master 2nd INPUT to be TABLED
     =======================    - only 1st 3 records, see all 8 on page '7D1' above
      # product_master - Tabled in memory, looked-up for description & price
      #        1         2         3         4         5
      #2345678901234567890123456789012345678901234567890
      #prod#====Description===========price=============
      BBQ010    BAR-B-Q             0019500
      CHR015    LAWN CHAIR          0004500
      HAM010    CLAW HAMMER         0000950

 #4. uvcopy extendsales3,fili1=dat2/sales_items,fili2=dat2/product_master,filo1=tmp/sales_itemsx2
     ============================================================================================
      - copy sales_items, load/lookup product_master TABLE to get price & description

 #4a. uvcopy extendsales3   <-*- same as above but easier, filenames default as shown above
      ===================      - see filenames coded within the job listed on page above

 #5. cat tmp/sales_itemsx2  <-- investigate the OUTPUT file
     =====================    - Note addition of--> price  ExTAmount Description
      130140  44 20200801 INV11001  HAM010  000010 0000950 000009500 CLAW HAMMER
      130140  44 20200801 INV11001  CHR015  000020 0004500 000090000 LAWN CHAIR
      139923  21 20200802 INV11002  BBQ010  000010 0019500 000195000 BAR-B-Q
      139923  21 20200802 CR5421    SAW051  000005 0008500 000042500 POWER SAW
      250825  44 20200803 INV11003  HAM099  000004                    ** ERR product# INVALID **
      401210  21 20200804 INV11004  SAW011  000025 0001975 000049375 HAND SAW

 #6. l tmp   <-- list output files in tmp/...
     =====     - 'sales_itemsx1' from extendsales2 & 'sales_itemsx2' from extendsales3
      -rw-rw-r-- 1 uvadm apps 456 Aug  3 12:14 sales_itemsx1
      -rw-rw-r-- 1 uvadm apps 456 Aug  3 13:55 sales_itemsx2

 #6. diff tmp/sales_itemsx1 tmp/sales_itemsx2   <-- prove 2 output files same ?
     ========================================
      - diff shows NO output if files are identical

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

7E3. Re-run extendsales3 - with debug option

See 'Part_8' for documentation on the uvcopy debugger. You activate with Run OPtion 'd' - append ',rop=d' on the uvcopy command. Here is a debug session for extendsales3. Null entries execute 1 instruction & prompt for a command. I have high-lighted the commands by repeating on the right with short description.


 uvcopy extendsales3,rop=d   <-- Execute with DEBUG option ',rop=d'
 =========================
      0         opn .. all                      open all f
 debug>
    136         rtb ..c1 fili2,c0(100),c0(100)    read pro
 debug>
    344 man20   get .. fili1,a0                 read next
 debug>
    528         skp >. man90                    (cc set >
 debug> p12 c0(100)                                                <-- p12 c0(100)
        0000-->#2345678901234567890123456789012345678901234567890    - Print 12 lines area c (table)
        0100-->#prod#====Description==========price==============
        0200-->BBQ010    BAR-B-Q             0019500
        0300-->CHR015    LAWN CHAIR          0004500
        0400-->HAM010    CLAW HAMMER         0000950               <-- 1st table lookup below
        0500-->HAM035    JACK HAMMER         0029500
        0600-->SAW011    HAND SAW            0001975
        0700-->SAW012    RIP SAW             0002500
        0800-->SAW051    POWER SAW           0008500
        0900-->TAB012    LAWN TABLE          0008500
        1000-->~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 debug>
    664         cmc .. a0(1),'#'                #comment t
 debug> p a0                                                       <-- p a0
         -----># sales_items - extendsales2 table load & lookup      - Print area a (input)
 debug> t1 man22                                                   <-- t1 man22
    936 man22   mvc .. b0(100),a0               copy input           - goto Tag 'man22'
   1072         lok ..z1 cc0(100),cc0(6),a30(6)   lookup t
   1232         skp =. man30                    (skp cc eq
 debug> r                                                          <-- r (display Registers)
 registers: c=400,u=100,v=44,x=400,z=44,                             - c=400 points to HAM010
                                                                     - cc30 = c430 = price
   1688 man30   mvn .. b45(7),cc30(7)           price from
   1824         mvn .. b53(9),cc30(7)           price to a
   1960         mpy .. b53(9),b38(6)            master pri
   2096         mvc .. b63(20),cc10             product ds
   2232 man40   put .. filo1,b0                 write outp
   2416         skp .. man20                    return to
 debug> p a0                                                       <-- p a0 (Print input record)
         ----->130140  44 20200801 INV11001  HAM010  000010
 debug> p b0                                                       <-- p b0 (Print output record)
         ----->130140  44 20200801 INV11001  HAM010  000010 0000950 000009500 CLAW HAMMER
 debug> g                                                          <-- g (Go to EOJ)
 20200804:330006:extendsales3: EOF fili01 rds=10 size=576: dat2/sales_items
 20200804:330006:extendsales3: EOF fili02 rds=12 size=518: dat2/product_master
 20200804:330006:extendsales3: EOF filo01 wrts=6 size=456: tmp/sales_itemsx2

See all debugger commands in 'Part_8'

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

Part_8. UVdemos1 - Introduction to Vancouver Utilities

Part_8 - uvcopy DEBUGGER


8A1. Debugging uvcopy jobs - Run OPtion rop=d
Listing of $UV/pf/demo/fixUSstates1.csv uvcopy job to demo debugging

8A2. Debug demo session#1 - using uvcopy fixUSstates1 & testfile USstates.csv
uvcopy fixUSstates.csv,rop=d - USstates.csv to fixed-field

8B1. Debug Command Summary (group1) - Display Data-Areas, Counters, Registers
'd' (or 'p') to Display (or Print) Data Areas (a,b,c...x,y,z)
'a' (or 'c') to display Accumulators (or Counters)

8B2. Debug Command Summary (group2) - Breakpoints & Gotos
 b# tag - store break-point tags b1,b2,b3 for gotos g1,g2,g3,g4,g5
 b1/b2/b3/b4/b5 tag - set breakpoint tags for corresponding gotos g1/g2/g3/g4/g5
 b1/b2/b3/b4/b5 - - clear breakpoint if tag spcfd as '-'
 g# - execute until reaching an instruction with label matching b#
 g1/g2/g3/g4/g5 - executes until finding a label matching stored b1/b2/b3/b4/b5
 g - executes until finding a label matching any 1 of b1/b2/b3/b4/b5
 g1/g2/g3/g4/g5 tag - store this tag in b1/b2/b3/b4/b5 & execute until we find it
 g tag - ERROR: tag Allowed only with g1/g2/g3/g4/g5
 G - executes until the end of the job, close files,& exit uvcopy
s1 - set Subrtn display mode, shows instructions between bal & ret
s0 - set Subrtn suppression, don't show instructions between bal & ret (default)

8C1. Debug demo session#2 - uvcopy extendsales1,rop=d

8C2. I/O files for extendsales1 uvcopy job (to demo debugging).
dat1/productmaster - tabled in memory
dat1/salesitems - INPUT file
dat1/salesextended - OUTPUT extended with product price & dscrptn **

8C3. debug session#2 --> uvcopy extendsales1,rop=d
- null entries to step thru instructions for 1st record cycle
- d (or p) to Display (or Print) Data Areas (a,b,c...x,y,z)
- a (or c) to display Accumulators or Counters (after 1st record)

8C4. p8 p0(50) - to display 1st 8 records in table area 'p' (50 bytes each)
r - to display Registers

8C5. g3 man90 - to store label 'man90' in brkpt g3 & go to it
c - to display counters (total for all records)
G - to Goto EOJ (close files & end job)

8C6. Debug session#3 to demo Breakpoints & Gotos
- see 8B2 above for summary of Breakpoint & Goto commands

8C7. debug session#4 - demo using only 'goto's without setting breakpoints
8C8. debug session#4 - Why product# ERRORs cause description '~~~~~~~~~'

8D1. Debug Command 'x' to Display Hexadecimal data

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

8A1. 'DEBUGGING' uvcopy parameter files - run option 'd'

Most uvcopy programs will not require the debug option, but it can be useful for for larger complex programs especially if using index registers and program loops.

Debug mode is invoked by appending ',rop=d' to the command line. You may also set debug mode via 'export UVCOPYROP=d' (for uvcopy jobs within scripts). In debug mode, uvcopy will display each instruction before execution & wait for an operator command. See the "Command Summary" on pages '8B1' & '8FB2

But first we will present a sample debug session to give you a good idea of debugging. We will demo the debug option using $UV/pf/demo/fixUSstates.csv listed below, & then executed with the debug option on the next page.

 # fixUSstates.csv - convert dat1/USstates.csv to tmp1/USstates.fix
 #                 - convert csv fields to space-filled 20 byte fixed-fields
 #
 #     ----- sample INPUT 1st 3 records -----
 # abr,state,state-pop,capital,capital-pop
 # AL,Alabama,4908620,Montgomery,205764,
 # AK,Alaska,734002,Juneau,31275,
 #
 #     ----- sample OUTPUT 1st 3 records -----
 # abr                 state               state-pop           capital             capital-pop
 # AL                  Alabama             4908620             Montgomery          205764
 # AK                  Alaska              734002              Juneau              31275
 #
 rop=r1    # EOF option prompt to view output file (vi,cat,more,head,etc)
 fili1=?dat1/USstates.csv,typ=LST,rcs=4096
 filo1=?tmp1/USstates.fix,typ=LST,rcs=4096
 @run
         opn     all                     open files
 # begin loop to get & put records until EOF
 getrec  get     fili1,a0                get record into area 'a'
         skp>    EOF                     (cc set > at EOF)
         mvc     b0(4096),a0             move in-area 'a' to out-area 'b'
 #-----------------------------------
         fix     b0(20),a0(100),6,','    convert csv to fixed-fields 20 apart
 #-----------------------------------
 putrec  put     filo1,b0                write to out-file from area 'b'
         add     $ca1,1                  count records for EOF msg
 return  skp     getrec                  return to get next record
 #
 EOF     cls     all                     close files
         msgv1   '$ca1 records converted to fixed-field from $fili1 to $filo1'
         eoj                             end job

 uvcopy fixUSstates.csv  <-- run demo job to convert USstares.csv to fixed-field
 ======================    - without debugging (omitting ',rop=d' from uvcopy command)
                           - see below to run with debugging (by appending ",rop=d")
Note
  • You can run these demos, enter suggested debug commands,& match your results
  • login as uvadm OR yourself if you have copied $UV/demo/* to your $HOME/demo/...

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

8A2. Debugging uvcopy jobs - Run OPtion rop=d

Debug session#1 - prior to command summary


 uvcopy fixUSstates.csv,rop=d   - run demo job to convert USstares.csv to fixed-field
 ============================   - 'rop=d' causes uvcopy to display each instruction
                                   & wait for operator command
                                - 'null entry' executes next instruction
      0         opn    all                     open files
 debug>
    152 getrec  get    fili1,a0                get record into area 'a'
 debug>
    352         skp>   EOF                     (cc set > at EOF)
 debug>
    504         mvc    b0(4096),a0             move in-area 'a' to out-area
 debug>
    656         fix    b0(20),a0(100),6,','    convert csv to fixed-fields 2
 debug>
    880 putrec  put    filo1,b0                write to out-file from area '
 debug>
   1080         add    $ca1,1                  count records for EOF msg
 debug>
   1232         skp    getrec                  return to get next record
 debug> p a0
                        1         2         3         4         5         6         7         8         9       100
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->abr,state,state-pop,capital,capital-pop
 debug> p b0
                        1         2         3         4         5         6         7         8         9       100
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->abr                 state               state-pop           capital             capital-pop
 debug> a                                     <-- 'a' to display accumulators
        accumulators: ca1=1,
 debug> r                                     <-- 'r' to display registers
        registers: u=4096,v=39,x=100,z=92,
 debug> G                                     <-- 'G' to Goto EOJ
 20201109:472804:fixUSstates.: EOF fili01 rds=51 size=1916: dat1/USstates.csv
 20201109:472804:fixUSstates.: EOF filo01 wrts=51 size=4423: tmp1/USstates.fix
 51 records converted to fixed-field from dat1/USstates to tmp1/USstates
 uvcopy fixUSstates.csv start 2020/11/09_11:46:08 end 11:47:28 elapsed 001_19_700
 EOJ, Output File written to: tmp1/USstates.fix
 ----- enter: vi,cat,more,lp,uvlp13,etc (default null) --> head -3
 abr                 state               state-pop           capital             capital-pop
 AL                  Alabama             4908620             Montgomery          205764
 AK                  Alaska              734002              Juneau              31275

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

8B1. Debug Command Summary (group1) - Display Data

Here is the Debug Command Summary, in 2 groups (Display DATA & Breakpoints/Gotos). You can try these out using the demo jobs listed on the preceding & following pages.

Display data areas, accumulators, registers

d/p
  • 'd' Display data area, or 'p' Print a data area
p a0(100)
  • print(display) area 'a' from byte 0 - 99 (100) bytes default
  • print area may be any 1 of 'a' - 'z'
p a
  • same as above since displacement defaults to 0 & length to 100
p b100(100)
  • print area 'b' bytes 100-199 (max line width 100 bytes)
p5 c0(100)
  • print 5 lines c0(100,c100(100),c200(100),c300(100),c400(100)
pe e0
  • Display area e0(100) translating Ebcdic to ascii
px4 x0
  • Display area x0(100),x100(100),x200(100),x300(100) in hexadecimal
  • 3 line groups: line1 character, line2 hex zones, line3 hex digits
  • characters on line1 with unprintable bytes replaced by periods
a/c
  • 'a' display Accumulators, or 'c' Counters (synonym)
c
  • display counters, non-zero acums in bank 'a' $ca0-$ca24 (default)
    Example: counters: ca1=100,ca2=25,ca4=4,
c b
  • display non-zero acums in bank 'b' $cb0-$cb24 example:
    ----- etc - 9 banks (a-i) of 25 acums -----
c i
  • display non-zero acums in bank 'i' $ci0-$ci24 example:
    Example: cb1=300,cb2=2300000,
  • Note: 9 banks (a-i) of 25 acums each
r
  • display Registers (in decimal, only non-zero registers)
    Example: registers: a=20000,b=84,d=20,s=1,u=50,v=200,x=50,z=80,
      ------- Display Data,Counters,Registers EXAMPLEs based on fixUSstates.csv (page '8A1') -------
 p a0
                 1         2         3         4         5         6         7         8         9       100
        1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
  ----->abr,state,state-pop,capital,capital-pop
 p b0
                 1         2         3         4         5         6         7         8         9       100
        1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
  ----->abr                 state               state-pop           capital             capital-pop
 a                                     <-- 'a' to display accumulators
 accumulators: ca1=1,
 r                                     <-- 'r' to display registers
 registers: u=4096,v=39,x=100,z=92,

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

8B2. Debug Command Summary (group2) - Breakpoints & Gotos

Breakpoints

null entry
  • single step, execute the instruction on display, then
  • then display the next instruction & prompt for a command
    or null to continue executing 1 at a time.
b# tag
  • store break-point tags b1,b2,b3,b4,b5 for gotos g1,g2,g3,g4,g5
b1/b2/b3/b4/b5 tag
  • store breakpoint tags for gotos g1/g2/g3/g4/g5
b1/b2/b3/b4/b5 -
  • clear breakpoint if tag spcfd as ' -'
      ------- Breakpoint examples based on fixUSstates.csv (page '8A1') -------
 b1 getrec   - set Breakpoint#1 on the instruction with label 'getrec'
 b2 putrec   - set Breakpoint#2 on the instruction with label 'putrec'
 b3 EOF      - set Breakpoint#3 on the instruction with label 'EOF'

Breakpoints are set using the labels on uvcopy instructions. The examples above are based on the uvcopy job listed on page '8A1' & the debug session on page '8A2'. Max 5 breakpoints at any 1 time, but you may redefine.

Gotos

g#
  • execute until reaching an instruction with label matching b#
g1/g2/g3/g4/g5
  • executes until finding a label matching stored b1/b2/b3/b4/b5
g
  • executes until finding a label matching any 1 of b1/b2/b3/b4/b5
g1/g2/g3.g4/g5 tag
  • store this tag in b1/b2/b3/b4/b5 & execute until we find it
g tag
  • ERROR: tag Allowed only with g1/g2/g3/g4/g5
G
  • executes until the end of the job, close files,& exit uvcopy
      ------- Goto examples based on fixUSstates.csv (page '8A1') -------
 g2         <-- execute until reaching label 'putrec' (stored in b2 above)
 g          <-- execute until label matching any 1 of tags stored in b1/b2/b3/b4/b5
 g3 EOF     <-- replaces any existing b3 tag with 'EOF'
                & executes until we find it

Sub-Routine display instructions or Suppress

s1
  • set Subrtn display mode, shows instructions between bal & ret
s0
  • set Subrtn suppression, will not show instructions between bal & ret
  • the default is 's0' to inhibit showing subroutine instructions

Display Data-Areas, Counters, Registers

At any breakpoint, you may display areas,counters,registers as shown on prior page

p a0
  • display areas relevant to current breakpoint
    1 2 3 4 5 6 7 8 9 100 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 abr,state,state-pop,capital,capital-pop
c a
  • display counters, non-zero acums in bank 'a' $ca0-$ca24 (default)
    counters: ca1=100,ca2=25,ca4=4,
r
  • display Registers (in decimal, only non-zero registers)
    registers: a=20000,b=84,d=20,s=1,u=50,v=200,x=50,z=80,

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

8C1. Debug demo#2 - uvcopy extendsales1

$UV/pf/demo/extendsales1 - 2nd job to demo debugging

 # extendsales1 - demo uvcopy table load (rtb) & table lookup (lok)
 #              - load product master file into memory table at begin job
 #              - extend sales items by looking up product master for price & dscrptn
 #              - see documentation at https://uvsoftware.ca/uvcopy3.htm#rtb
 #Note - also used to demo uvcopy debugging, see https://uvsoftware.ca/uvcopy2.htm#J1
 #
 # uvcopy extendsales1,fili1=dat1/salesitems,fili2=dat1/productmaster,filo1=tmp1/salesextended
 # ===========================================================================================
 # uvcopy extendsales1,rop=d  - same as above (files default as shown)
 # =========================  - ',rop=d' to debug, displays instructions before executing
 #  ** sample 1st record from input salesitems,productmaster,& output salesextended **
 #          1         2         3         4         5         6         7         8
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # cust#    date   invoice# product qty
 # 130140 20200802 IN001001 BBQ010 000010
 #          1         2         3         4
 # 1234567890123456789012345678901234567890
 # Product#  Description      unit-price
 # BBQ010    BAR-B-Q             0019500
 #        1         2         3         4         5         6         7         8
 # 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 # cust#    date   invoice# product qty     price   extended product description
 # 130140 20200802 IN001001 BBQ010 000010  0019500 000195000 BAR-B-Q
 #
 rop=r1       # EOF option prompt to view output file (vi,cat,more,etc)
 fili1=?dat1/salesitems,rcs=80,typ=LST      # sales item file
 fili2=?dat1/productmaster,rcs=80,typ=LST   # product master file
 filo1=tmp1/salesextended,rcs=100,typ=LST   # output items extended w price/dscrptn
 @run
        opn    all                      open all files
        rtb    fili2,p0(50),p0(50)      read product master into memory area 'p'
 #      ===
 # begin loop: read sales items, extending with price & dscrptn from table lookup
 man20  get    fili1,a0                 read next sales item record
        skp>   man90                    (cc set > at EOF)
 man22  mvc    b0(80),a0                copy input to output area
        lokz1  pp0(50),pp0(6),a25(6)    lookup table by product code
 #      ===
        skp=   man26                    (cc unequal if nomatch)
 man24  msg    'ERROR - product code not found',a25(6)
 man26  mvn    b40(7),pp30(7)           price from table
        mvn    b48(9),pp30(7)           price to amount for extension
        mpy    b48(9),b32(6)            master price * item qty = amount
 man28  mvc    b58(16),pp10             product dscrptn from table
        add    $ca1,b48(9)              accumulate total sales for EOF msg
 man30  put    filo1,b0                 write output
        skp    man20                    return to get next record
 # EOF - close files & end job (rop=r1 prompts to show output file)
 man90  cls    all
        msgv1  'Total sales = $ca1 in $filo1'
        eoj

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

8C2. Debug demo#2 - uvcopy extendsales1

Here are the I/O files for the above extendsales1 uvcopy job (to demo debugging). This job was used to demo the 'rtb' instruction (documented at uvcopy3.htm#rtb), by tabling a product master file, then looking it up by product# to extend a sales item file using the product master price & description.

dat1/productmaster - to be tabled in memory

 Product#  Description      unit-price
          1         2         3         4
 1234567890123456789012345678901234567890
 ========================================
 BBQ010    BAR-B-Q             0019500
 HAM010    CLAW HAMMER         0000950
 HAM020    BALL HAMMER         0001200
 HAM035    JACK HAMMER         0029500
 SAW011    HAND SAW            0001975
 SAW012    RIP SAW             0002500
 SAW051    POWER SAW           0008500

dat1/salesitems - INPUT file

 cust#  slsmn  date  invoice#  product quantity
          1         2         3         4
 1234567890123456789012345678901234567890
 ========================================
 cust#    date   invoice# product qty
 130140 20200802 IN001001 HAM035 000010
 139923 20200802 IN001002 SAW011 000020
 139923 20200802 IN001003 HAM020 000030
 250825 20200804 IN001104 BBQ010 000040
 250825 20200804 IN001004 SAW099 000050
 401210 20200816 IN001005 SAW051 000060

dat1/salesextended - OUTPUT extended with product price & dscrptn

 cust#  slsmn  date  invoice#  product quantity  price   amount  product-dscrptn
          1         2         3         4         5         6         7         8
 12345678901234567890123456789012345678901234567890123456789012345678901234567890
 ================================================================================
 cust#    date   invoice# product qty     price   extended product description
 130140 20200802 IN001001 HAM035 000010  0029500 000295000 JACK HAMMER
 139923 20200802 IN001002 SAW011 000020  0001975 000039500 HAND SAW
 139923 20200802 IN001003 HAM020 000030  0001200 000036000 BALL HAMMER
 250825 20200804 IN001104 BBQ010 000040  0019500 000780000 BAR-B-Q
 250825 20200804 IN001004 SAW099 000050  0000000 000000000 ~~~~~~~~~~~~~~~~
 401210 20200816 IN001005 SAW051 000060  0008500 000510000 POWER SAW

 uvcopy salesextend,rop=d  <-- execute uvcopy job to demo 'rtb' & 'lok'
 ========================    - ',rop=d' to debug (display instructions before executing)
 - see the uvcopy job listed on the previous page.

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

8C3. Debugging uvcopy jobs (rop=d)

debug session#2 using $UV/pf/demo/extendsales1

Please refer to uvcopy job listing on page '8C1' & the I/O files on '8C2' above. We will single step (null entries) to end of 1st loop processing 1st instruction. Then display the relevant I/O data areas, registers & accumulators.


 uvcopy extendsales1,rop=d
 =========================
        0000         opn    all                      open all files
 debug> 0152         rtb    fili2,p0(50),p0(50)      read product master into memory
 debug> 0376 man20   get    fili1,a0                 read next sales item record
 debug> 0576         skp>   man90                    (cc set > at EOF)
 debug> 0728 man22   mvc    b0(80),a0                copy input to output area
 debug> 0880         lokz1  pp0(50),pp0(6),a25(6)    lookup table by product code
 debug> 1056         skp=   man26                    (cc unequal if nomatch)
 debug> 1360 man26   mvn    b40(7),pp30(7)           price from table
 debug> 1512         mvn    b48(9),pp30(7)           price to amount for extension
 debug> 1664         mpy    b48(9),b32(6)            master price * item qty = am
 debug> 1816 man28   mvc    b58(16),pp10             product dscrptn from table
 debug> 1968         add    $ca1,b48(9)              accumulate total sales for EO
 debug> 2120 man30   put    filo1,b0                 write output
 debug> 2320         skp    man20                    return to get next record
 debug> p a0        <-- display the 1st INPUT record (in area 'a')
                        1         2         3         4         5         6         7         8
               123456789012345678901234567890123456789012345678901234567890123456789012345678901
         ----->130140 20200802 IN001001 HAM035 000010
 debug> p b0        <-- display the 1st OUTPUT record (in area 'b')
                        1         2         3         4         5         6         7         8         9        1
               12345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->130140 20200802 IN001001 HAM035 000010  0029500 000295000 JACK HAMMER
 debug> c
        counters: ca1=295000,

      130140 20200802 IN001001 HAM035 000010  0029500 000295000 JACK HAMMER
      ================================================<-48(9)->==============

        add    $ca1,b48(9)              accumulate total sales for EOF msg
        ==================

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

8C4. Debugging uvcopy jobs (rop=d)

debug session#2 (extendsales1) - continued

 debug> p8 p0(50)   <-- display the product lookup file (tabled in memory by rtb)
                      - 'rtb' tabled 40 byte records as 50 byte entries to simplify addresses
                      - 'lok' looks-up the table by product# key to get description & price
                         1         2         3         4
               12345678901234567890123456789012345678901234567890
        0000-->BBQ010    BAR-B-Q             0019500
        0050-->HAM010    CLAW HAMMER         0000950
        0100-->HAM020    BALL HAMMER         0001200
        0150-->HAM035    JACK HAMMER         0029500
        0200-->SAW011    HAND SAW            0001975
        0250-->SAW012    RIP SAW             0002500
        0300-->SAW051    POWER SAW           0008500
        0350-->~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 debug> r
        registers: p=150,u=100,v=38,x=150,z=70,

        lokz1  pp0(50),pp0(6),a25(6)    lookup table by product code
        ============================
        mvn    b40(7),pp30(7)           price from table
        mpy    b48(9),b32(6)            master price * item qty = am
 man28  mvc    b58(16),pp10             product dscrptn from table
        ===================

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

8C5. Debugging uvcopy jobs (rop=d)

debug session#2 (extendsales1) - continued

 debug> g3 man90                    <-- goto man90 (label at EOF)
        2472 man90   cls    all
 debug> c                           <-- display counters at EOF
        counters: ca1=1785500,
 debug> G
        ERROR - product code not found SAW099
 20201119:044903:extendsales1: EOF fili01 rds=6 size=234: dat1/salesitems
 20201119:044903:extendsales1: EOF fili02 rds=7 size=266: dat1/productmaster
 20201119:044903:extendsales1: EOF filo01 wrts=6 size=416: tmp1/salesextended

Total sales = 1660500 in tmp1/salesextended

 uvcopy extendsales1 start 2020/11/19_11:04:35 end 11:04:49 elapsed 000_14_125
 EOJ, Output File written to: tmp1/salesextended
 ----- enter: vi,cat,more,lp,uvlp13,etc (default null) --> cat
 130140 20200802 IN001001 HAM035 000010  0029500 000295000 JACK HAMMER
 139923 20200802 IN001002 SAW011 000020  0001975 000039500 HAND SAW
 139923 20200802 IN001003 HAM020 000030  0001200 000036000 BALL HAMMER
 250825 20200804 IN001104 BBQ010 000040  0019500 000780000 BAR-B-Q
 250825 20200804 IN001004 SAW099 000050  0000000 000000000 ~~~~~~~~~~~~~~~~
 401210 20200816 IN001005 SAW051 000060  0008500 000510000 POWER SAW

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

8C6. debug session#3 to demo Breakpoints & Gotos

The previous Debug session on page '8C3' illustrated stepping thru the job & displaying Data-Areas, Counters,& Registers, but did not illustrate Breakpoints & Gotos. Please also refer backto page '8C1' which listed all instructions in extendsales1 (vs just those executed in the debug session on page '8C3').


 uvcopy extendsales1,rop=d
 =========================
      0         opn    all                      open all files
 debug> b1 man20
 debug> b2 man24
 debug> b3 man30

debug> g1 <-- goto tag 'man20' (breakpoint 'b2 man20' above)

    376 man20   get    fili1,a0                 read next sales item record
 debug> g3
   2120 man30   put    filo1,b0                 write output
 debug> p a0  <-- display 1st INPUT record (in area 'a')
                         1         2         3         4         5         6         7         8         9        1
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->130140 20200802 IN001001 HAM035 000010
 debug> p b0  <-- display 1st OUTPUT record (in area 'b')
                         1         2         3         4         5         6         7         8         9        1
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->130140 20200802 IN001001 HAM035 000010  0029500 000295000 JACK HAMMER
Note
  • We are now at the end of the 1st record cycle at tag 'man30'
    please see tag 'man30' on the listing of extendsales1 on page '8C1'
  • We now want to investigate the "ERROR - product code not found"
    caused by product code 'SAW099' on record #6 in dat1/salesitems listed on '8C2'

debug> g2 <-- goto tag 'man24' (breakpoint 'b2 man24' above)

1208 man24 msg 'ERROR - product code not found',a25(6)

 debug> g3    <-- goto tag 'man30', which will be the end of the ERROR record#6
              ERROR - product code not found SAW099
   2120 man30   put    filo1,b0                 write output
 debug> p a0  <-- display INPUT record#6 causing the ERROR
                - product code SAW099 not found in the productmaster (tabled in memory)
                         1         2         3         4         5         6         7         8         9        1
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->250825 20200804 IN001004 SAW099 000050
 debug> p b0  <-- display OUTPUT record#6 (ERROR will omit price, amopunt, description)
                         1         2         3         4         5         6         7         8         9        1
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->250825 20200804 IN001004 SAW099 000050  0000000 000000000 ~~~~~~~~~~~~~~~~
 debug> c     <-- display accums at end of ERROR record#6
        counters: ca1=1150500,   <-- total of 1st 5 good records

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

8C7. debug session#3 demo Breakpoints & Gotos - Continued

 debug> g5 man90                 <-- goto man90 (tag at EOJ to close files)
                                   - did not setup 'b5 man90' at begin debug
   2472 man90   cls    all
 debug> c     <-- display accums at EOF (total missing $amt of ERROR record#6)
        counters: ca1=1660500,   <-- total of 1st 5 & 7th records
 debug> G     <-- Goto EOJ (end of program)
 20201119:244201:extendsales1: EOF fili01 rds=6 size=234: dat1/salesitems
 20201119:244201:extendsales1: EOF fili02 rds=7 size=266: dat1/productmaster
 20201119:244201:extendsales1: EOF filo01 wrts=6 size=416: tmp1/salesextended
 Total sales = 1660500 in tmp1/salesextended
 uvcopy extendsales1 start 2020/11/19_17:22:33 end 17:24:42 elapsed 002_09_013
 EOJ, Output File written to: tmp1/salesextended

debug session#4 - demo using only 'goto's without breakpoints

Session#4 will show you do not need to set brkpts with 'b# tagxx'; you can use goto for both setting brkpts & going to them. You must code 'g# tagxx' on 1st use but can subsequently code just the 'g#' to goto that tagxx. Use 'b#' brkpts when you want to plan ahead on big programs, use 'g# brkpts' for more specific bugs.

Question - Why did invalid product code 'SAW099' cause description '~~~~~~~~~~~~~~~~' ? Session#2 on page '8C4' explained how the 'lok' (table lookup instruction) sets register 'p' to the matching entry in the productmaster tabled in memory. Here are just the relevant instrns.

        lokz1  pp0(50),pp0(6),a25(6)    lookup table by product code
        skp=   man26                    (cc unequal if nomatch)
 man24  msg    'ERROR - product code not found',a25(6)
 man26  ...                             - omitting less relevant instrns
        mvc    b58(16),pp10             product dscrptn from table
 man30  put    filo1,b0                 write output

We know the bad product code is record#6, which causes the 'lok' instrn to set condition code unequal & executes the 'man24 msg ERROR...' instrn. So we can use 'g1 man24' to go directly to the problem record#6, bypassing the 1st 5 good records that do not execute the 'man24 msg ERROR' instrn.

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

8C8. debug session#4 - Why product# ERRORs cause description '~~~...'

debug session#4 - investigate '~~~' description if bad product#


 uvcopy extendsales1,rop=d
 =========================
      0         opn    all                      open all files
 debug> g1 man24           <-- go directly to man24 where ERROR detected
                             - bypasses 1st 5 records that have no ERROR

1208 man24 msg 'ERROR - product code not found',a25(6)

 debug> g2 man28
               ERROR - product code not found SAW099
   1816 man28   mvc    b58(16),pp10             product dscrptn from table
 debug>                  <-- null entry to execute 'mvc b58(16),pp10' (description)
                           - so we can examine the output record & the registers
   1968         add    $ca1,b48(9)              accumulate total sales for EOJ
 debug> p b0             <-- display output record#6 with bad product code 'SAW099'
                         1         2         3         4         5         6         7         8         9        1
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
         ----->250825 20200804 IN001004 SAW099 000050  0000000 000000000 ~~~~~~~~~~~~~~~~
 debug> r                <-- display the Registers to see WHY description '~~~~~~~~~~~~~~~~' ?
        registers: p=350,u=100,v=38,x=350,z=38,
        0000-->BBQ010    BAR-B-Q             0019500
        0050-->HAM010    CLAW HAMMER         0000950
        0100-->HAM020    BALL HAMMER         0001200
        0150-->HAM035    JACK HAMMER         0029500
        0200-->SAW011    HAND SAW            0001975
        0250-->SAW012    RIP SAW             0002500
        0300-->SAW051    POWER SAW           0008500
        0350-->~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 debug> g1          <-- could search for any more ERRORs (at tag man24)
                      - do not need to code 'g1 man24' (already assigned)
                      - will goto EOF/EOJ since only the 1 ERROR in this file
 20201120:150104:extendsales1: EOF fili01 rds=6 size=234: dat1/salesitems
 20201120:150104:extendsales1: EOF fili02 rds=7 size=266: dat1/productmaster
 20201120:150104:extendsales1: EOF filo01 wrts=6 size=416: tmp1/salesextended
 Total sales = 1660500 in tmp1/salesextended

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

8D1. Debug Command 'x' to Display Hexadecimal data

Display area 'x' Reserved for Registers, Counters, etc

You can skip this page if not interested in the binary bits of how stuff works. You don't really need to know this sicne you can address registers by their symbolic name example: $ra for register 'a' vs x0(4b) where actually stored. And you can address counters by thier symbolic names example, for example: $ca1 vs x208(8b) where actually stored.

You can see the detailed layout of area 'x' at uvcopy2.htm#A1. Here is just the 1st few Registers & Counters:

 absolute    | symbolic |     item
 address     | address  | description
 x0(4b)        $ra       index register 'a'
 x4(4b)        $rb       index register 'b'
 x8(4b)        $rc       index register 'c'
  ...          ...              ...
 x100(4b)      $rz       index register 'z'
 x200(8b)      $ca0      user counter set 'a' counter# 0
 x208(8b)      $ca1      user counter set 'a' counter# 1
  ...          ...           ...
 x392(8b)      $ca24     user counter set 'a' counter# 24
 x1800(8b)     $ci0      instruction counter i0
  ...          ...           ...

But, you can display area 'x' if desired, for example, here is the 1st 300 bytes of area 'x' at label 'man90' (EOF) from 'extendsales1' shown on page '8C1'.

 px3 x0(100)  - display area 'x' in hexadecimal - area 'x' reserved for Registers, Accumulators, etc
                      1         2         3         4         5         6         7         8         9      100
            0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
     0000-->................................................................................d...&...............
            0000000000000000000000000000000000000000000000000000000000009000000000000000000060002000000090000000
            0000000000000000000000000000000000000000000000000000000000006000000000000000000040006000000060000000
     0100-->F...........X.......G...:...................................(................................L......
            40000000000058000000410031001000000000000000E10001000F00E0002000900000000000000000000000000004000000
            600000000000804000007B00AB001000000000000000C30009000A008300810000000000000000000000000000000C000000
     0200-->........X...........................................................................................
            0000000058000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
            0000000080400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 debug> r
        registers: p=150,u=100,v=38,x=150,z=70,
 debug> c
        counters: ca1=295000,

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

Part_9. UVdemos1 - Introduction to Vancouver Utilities

Part_9 - Linux Applications & Vancouver Utilities


9A1. Useful Tools for Linux Administrators

9B1. vim - Vi IMproved, powerful editor for Linux, Unix,& Windows
- command line text file editor
- links to documentation
vimrc - control file to set desired features
- highlighting, cursor position, yank buffers, tabstop, spell check

9B2. test .vimrc added features

9C1. .vimrc - Run Control file to customize vim behaviour
- listing of .vimrc used at UV Software

9D1. - create script to copy ".vimrc" to all homedirs & execute
- created automatically by uvfix1 from a user list (ls /home >tmp/users)
  for input to uvfix1 & enter 3 instructions at the prompt

9E1. create script to chown .vimrc for each user & execute
- created automatically by uvfix1 from a user list (ls /home >tmp/users)
  for input to uvfix1 & enter 2 instructions at the prompt
Note
  • Also create scripts to copy your master copy of .bash_profile & .bashrc
    to all user homedirs found in /home/... (non-system userids => 1000)
  • These tools can save Linux system admins a lot of editing time
    at sites that may have hundreds of users.

9F1. add exception words to vim's spellfile
- while editing with :set spell, ]s, & zg commands
- or with separate file of words to be added with script

9F2. run script 'updatespellfile' to add separate file of exception words

9G1. multicol1 - list file of exception words multi-columns across
- general purpose utility for any file with short lines

9H1. repage1 - reformat paragraphs with no LineFeeds to specified line width
- example for word documents or emails with long paragraphs
- to enable printing as text files

9H2. Run repage1 test/demo to split pararaphs with lines up to 110 characters
to lines with max 90 chars/line.

9H3. Repaginate Logic & Options

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

9A1. Useful Tools for Linux Administrators

Useful Tools for Linux Administrators

'Part_9' is a good example of how useful the Vancouver Utilities can be to Linux System Administrators.

Page '9C1' lists a .vimrc file that greatly enhances the capabilities of 'vim' (highlight search words & cursor line, remember cursor position, spell check, etc).

Page '9D1' shows you how to use uvfix1 to create a script to copy .vimrc to all user homedirs. The script is generated automatically from 'ls /home >tmp/users' as input to 'uvfix1' that creates a 'cp $APPSADM/env/vimrc /home/userxx' for each user.

Page '9E1' shows you how to create another script to set the permissions so that the users can customize their .vimrc file if they so desire.

Note
  • Also create scripts to copy your master copy of .bash_profile & .bashrc
    to all user homedirs found in /home/... (non-system userids => 1000)

These tools save me a lot of time (vs creating scripts with editor only). I had 60 userids (because I setup a sperate login for each client).

These tools could save many commercial Unix/Linux sites a lot more time since they could have hundreds of users.

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

9B1. Useful Tools for Linux Administrators

Vim editor - for Linux,Unix,Windows

Here are some links to VIM documentation. You can Google 'Vim documentation' to see many more links to vim documentation & tutorials.

www.uvsoftware.ca/uvtrain.htm#1C1


www.vim.org www.vim.org/docs.php

www.vimdoc.sourceforge.net/htmldoc/spell.html

.vimrc - control file to set desired features

You can edit '.vimrc' in your homedir to set additional capabilities beyond the defaults. See our preferred .vimrc listed on page '9C1'. Here is a short summary of additional features we selected. The #1,#2,etc references here are coded as --> "#1,"#2,etc in the vimrc file, since the comment symbol in .vimrc files is the '"' double quote (vs the usual '#' for unix scripts)


 #1. Highlighting
 #1a. set hlsearch    <-- HighLights search words (yellow)
 #1b. set cursorline  <-- Highlights cursor line (light blue)

 #2. restore cursor to previous position when reopening a file
      - very convenient to continue editing from where you left off
      - see actual code in vimrc '9C1' (a bit complex to show here)

 #3. increase yank max lines per buffer a-z, from default (50 lines) to 1000 lines
      - see actual code in vimrc '9C1' (a bit complex to show here)

 #4. set tabstop 4   <-- set tab expansion to 4 (vs 8 default)
     set expandtab   <-- tried to expand the tab to actual space characters
                       - but did not work (omitted from our .vimrc file)

 #5. set spell       <-- set spell checking
      - allows a file of your unique exception words (codes,filenames,etc)
      - my exception file for UV Software documentation as follows:
     set spellfile=/home/appsadm/admin/spell/en.utf-8.add
      - see the more complex details in the vimrc listed on page '9C1'

 #6. :set spell  <-- I prefer to set spell on ONLY when I want to spell check
                    - so "set spell" is commented out in the .vimrc file

 #7. spell check commands:
      ]s   <-- search to next misspelled word
      zg   <-- add word to "g"ood list in /home/appsadm/admin/spell/en.utf-8.add

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

9B2. Vim editor - for Linux,Unix,Windows

test .vimrc added features

Now, let's test the 7 vimrc added features listed on the previous page. You might test by running 'vi' or 'vim' on doc/UVdemos1.doc, which is pure text (unrelated to Microsoft doc files).

Note that it does not matter if you enter 'vi' or 'vim', since 'vi' is aliased to 'vim'. After you test with vi/vim, then rerun the same tests using '\vi', which will call original 'vi' (the backslash defeats the alias).


 vim $UV/doc/UVdemos1.doc   <-- edit a file with vim (or vi same by alias)
 ========================
   --> /uvsoftware   <-- search for any word & all matching words on screen
                         highlighted in yellow (#1a page above or .vimrc page below)
   --> n             <-- enter 'n' to goto the Next match
                       - note current line highlighted in BLUE (#1b on page above)
   --> :q            <-- quit, so we can re-edit to see cursor on current line

 vim $UV/doc/UVdemos1.doc   <-- Re-edit & note cursor on the prior edit current line
 ========================     - as per #2 on page above (or "#2 in .vimrc page below)
   --> "a 200yy      <-- Yank 200 lines into buffer "a" to test #3 above
   --> :q                 - quit, so we can edit a tmp/file & put buffer "a"

 vim tmp/xxx         <-- edit a tmp/file
 ===========
   --> "ap           <-- put buffer "a" (200 lines, vs 50 if #3 above omitted)
   --> \t            <-- hit tab, only 4 spaces (vs default 8) as per #4 above
   --> :set spell    <-- set spell checking on (#6 page above or "#6 .vimrc below)
   --> ]s            <-- search to next spelling error (#7 above or "#7 .vimrc below)
   --> zg            <-- zg should add current word to "g"ood words
                       - spelling error highlight should disappear

Now edit with the original 'vi' (vs 'vim'), by entering '\vi' to defeat the alias


 \vi doc/UVdemos1.doc   <-- edit a file with vim (or vi same by alias)
 ====================
   -->  ...          <-- repeat the edit tests listed above for 'vim'
                       - note that the vim features do not work

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

9C1. Useful Tools for Linux Administrators

vimrc - Run Control file to customize vim behaviour

 " vimrc - master copy of .vimrc stored in /home/uvadm/env/vimrc & /home/appsadm/env/vimrc
 "       - copy to your homedir & rename as .vimrc (see doc at www.vim.org)
 "       - updated Sep2020 by Owen Townsend, UV Software
 "------------------------------------------------------------------------------
 "#1. set HighLighting for search matches & current cursor line
 set hlsearch     "<-- HighLights search words (yellow)
 set cursorline   "<-- Highlights cursor line (light blue)
 "------------------------------------------------------------------------------
 "#2. restore cursor to previous position when reopening a file
 if has("autocmd")
   au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
     \| exe "normal! g'\"" | endif
 endif
 "------------------------------------------------------------------------------
 "#3. increase yank max lines per buffer a-z, from default (50 lines) to 1000 lines
 set viminfo='20,<1000
 " note - the 20 is the max files to save buffers for
 "------------------------------------------------------------------------------
 "#4. set tabstop 4 (wanted real spaces, tried set expandtab & set paste, not working)
 set tabstop=4
 "------------------------------------------------------------------------------
 "#5. spellcheck customization for UV Software's code words,filenames,abrevs,HTMLlinks,etc
 " - see /home/appsadm/admin/spell/en.utf-8.add
 " - run $UV/sf/adm/updatespellfile if any new words added with editor (vs ']s' & 'zg')
 " cd $APPSADM         <-- change to /home/appsadm
 " sf/updatespellfile  <-- script to add any admin/spell/spellfile_adds to en.utf-8.add
 " vi admin/spell/en.utf-8.add  <-- edit spellfile to run mkspell (recreate fast search)
 " :mkspell! %                  <-- re-generate en.utf-8.add.spl (fast search version)
 set spelllang=en
 set spellfile=/home/appsadm/admin/spell/en.utf-8.add
 set spellcapcheck=""
 syn match wordDigitUpper '\<\p*\d\|\u\p*\>' contains=@NoSpell
 syntax on
 autocmd Syntax markdown syn match wordDigitUpper
 "#6. :set spell  <-- I prefer to set spell on ONLY when I want to spell check
 "------------------------------------------------------------------------------
 "#7. vi doc/UVdemos1.doc  <-- sample edit with spell check, search next, add word
 " :set spell           <-- set spell check on
 " ]s                   <-- search to next misspelled word
 " zg                   <-- add word to "g"ood list in $SPELLDIR/en.utf-8.add
 " -------------------- end of .vimrc ----------------------

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

9D1. Useful Tools for Linux Administrators

create script to copy ".vimrc" to all homedirs

I used 'uvfix1' to create a script to copy .vimrc to all (60+) user homedirs at UV Software. I have 60+ logins because I setup an account for each current client. I saved hours of manual editing by using uvfix1 to perform the copy & then to set the owner:group & permissions so each user could update their .vimrc without having to use root (or sudo).

Do not do this if you are performing the UVdemos1 tutorials online with 'ssh' But, Do this if you have Vancouver Utilities at your site - all your users will greatly appreciate the expanded capabilities of VIM that .vimrc provides.

We assume here that you setup user 'appsadm' (administrator for user logins, etc). /home/appsadm stores the master copies of bash_profiles & common_profiles (so not lost when new versions of uvadm installed). $APPSADM also holds various admin scripts, functions, & log files.


 #1. Login appsadm   <-- Login to appsadm on your own machine, assuming
     =============       Vancouver Utilities installed as per install.htm
     --> passxx      <-- enter your password for appsadm

 #2. cp /home/uvadm/env/vimrc appsadm/env/  - vimrc should be same in both
     =====================================    uvadm/env/. & appsadm/env/.
      - unnecessary if both uvadm & appsadm setup as per install.htm

 #3. mkdir tmp tmp1 tmp2         <-- setup tmp & tmp1 if not already present
     ===================
 #3a. rm -f tmp*/*               <-- OR clear tmp files if already present
      ============                 - tmp*/* same as tmp/* tmp1/* tmp2/*

 #4. ls /home >tmp1/vimrc_homes  <-- create list of all homedirs, naming to
     ==========================      indicate a script copying vimrc to homedirs

 #4a. head tmp1/vimrc_homes      <-- show a few user logins (homedirs)
      =====================
      appsadm
      client01
       --- 60 logins omitted ---
      client99
      uvadm
      uvtest

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

9D2. create script to copy ".vimrc" to all homedirs


 #5. uvfix1 tmp1/vimrc_homes      <-- run uvfix1 script (to solicit instructions)
     =======================        - OMITTING options screen & filename prompts
                                    - until the '.' prompt for instructions
                                    - see uvfix1 OPTIONS listed on page '5B2'

     #5a. mvf b0(100),'cp -v /home/appsadm/env/vimrc'
          ===========================================

     #5b. mvf b40(60),'/home/USER/.vimrc'
          ===============================

     #5c. repf4 b40(60),'USER',a0(20)  <-- REPlace 'USER' with actual login name
          ===========================    - option 'f4' stops replace at right space/null

     #5d. .                            <-- enter '.' period to execute
          ====
      20200919:572606:uvfix1: EOF fili01 rds=64 size=476: tmp1/vimrc_homes
      20200919:572606:uvfix1: EOF filo01 wrts=64 size=3868: tmp/vimrc_homes
      20200919:572606:uvfix1: EOF filo02 wrts=28 size=1542: tmp/vimrc_homes.pf
      uvcopy uvfix1 start 2020/09/19_17:56:03 end 17:57:26 elapsed001_23_488
      EOJ, Output File written to: tmp/vimrc_homes

 #6. cp tmp/vimrc_homes sf/    <-- save tmp/output to a permanent directory
     ======================      - /home/appsadm/sf/... ('sf' abbrev 'Script Files')

 #7. vi sf/vimrc_homes         <-- edit to insert #!/bin/bash & a few #comment lines
     =================           - to identify script-name, purpose, when created, etc

 #8. head sf/vimrc_homes       <-- show a few lines of the script created by uvfix1
     ===================           (after adding a few #comment lines)
      #!/bin/bash
      # vimrc_homes - script to copy master version of vimrc to .vimrc in all homedirs
      #             - created by uvfix1, Sep19/2020, stored in /home/appsadm/sf/...
      cp -v /home/appsadm/env/vimrc           /home/appsadm/.vimrc
      cp -v /home/appsadm/env/vimrc           /home/client01/.vimrc
                       --- 60 logins omitted ---
      cp -v /home/appsadm/env/vimrc           /home/client99/.vimrc
      cp -v /home/appsadm/env/vimrc           /home/uvadm/.vimrc
      cp -v /home/appsadm/env/vimrc           /home/uvtest/.vimrc

 #9. chmod 755 sf/vimrc_homes  <-- set execute permissions
     ========================

 #10. sudo sf/vimrc_homes       <-- Execute script to copy .vimrc to all homedirs
      ===================         - need root permissions, sudo prompts for a
                                    password in the sudoers file (/etc/sudoers)
Note
  • Also create scripts to copy your master copy of .bash_profile & .bashrc
    to all user homedirs found in /home/... (non-system userids => 1000)

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

9E1. Useful Tools for Linux Administrators

create script to chown .vimrc for each user

After executing the vimrc_homes script to copy env/vimrc to .vimrc in each homedir, the .vimrc file would be owned by appsadm. The .vimrc would work, but we should change the owner to each user, so they could customize their .vimrc if desired. We might also ensure the permissions are 664 so the users (or appsadm in same group) could update.

We can use the same input file of user logins (in tmp1/vimrc_homes) to create another script (in /home/appsadm/sf/vimrc_chown).


 #1. cp tmp1/vimrc_homes tmp1/vimrc_chown  <-- copy/rename user logins appropriate
     ====================================      for script-name to chown .vimrc's

 #2. head tmp1/vimrc_chown      <-- show a few user logins (homedirs)
     =====================
      appsadm
      client01
       --- 60 logins omitted ---
      client99
      uvadm
      uvtest

 #3. uvfix1 tmp1/vimrc_chown      <-- run uvfix1 script (to solicit instructions)
     =======================        - OMITTING options screen & filename prompts
                                    - until the '.' prompt for instructions
                                    - see uvfix1 OPTIONS listed on page '5B2'

     #3a. mvf b0(100),'chown USER:apps /home/USER/.vimrc'
          ===============================================

     #3c. repf4 b0(100),'USER',a0(20)  <-- REPlace 'USER' with actual login name
          ===========================    - option 'f4' stops replace at right space/null

     #3d. .                            <-- enter '.' period to execute
          ====
      20200919:572606:uvfix1: EOF fili01 rds=64 size=476: tmp1/vimrc_chown
      20200919:572606:uvfix1: EOF filo01 wrts=64 size=3868: tmp/vimrc_chown
      20200919:572606:uvfix1: EOF filo02 wrts=28 size=1542: tmp/vimrc_chown.pf
      uvcopy uvfix1 start 2020/09/19_17:56:03 end 17:57:26 elapsed001_23_488
      EOJ, Output File written to: tmp/vimrc_chown

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

9E2. create script to copy ".vimrc" to all homedirs


 #4. cp tmp/vimrc_chown sf/    <-- save tmp/output to a permanent directory
     ======================      - /home/appsadm/sf/... ('sf' abbrev 'Script Files')

 #5. vi sf/vimrc_chown         <-- edit to insert #!/bin/bash & a few #comment lines
     =================           - to identify script-name, purpose, when created, etc

 #6. head sf/vimrc_chown       <-- show a few lines of the script created by uvfix1
     ===================           (after adding a few #comment lines)
      #!/bin/bash
      # vimrc_chown - script to change owner of '.vimrc's to user login names
      #             - created by uvfix1, Sep19/2020, stored in /home/appsadm/sf/...
      chown appsadm:apps /home/appsadm/.vimrc
      chown client01:apps /home/client01/.vimrc
                       --- 60 logins omitted ---
      chown client99:apps /home/client99/.vimrc
      chown uvadm:apps /home/uvadm/.vimrc
      chown uvtest:apps /home/uvtest/.vimrc

 #7. chmod 755 sf/vimrc_chown  <-- set execute permissions
     ========================

 #8. sudo sf/vimrc_chown       <-- Execute script to copy .vimrc to all homedirs
     ===================         - need root permissions, sudo prompts for a
                                    password in the sudoers file (/etc/sudoers)
Note
  • Also create scripts to copy your master copy of .bash_profile & .bashrc
    to all user homedirs found in /home/... (non-system userids => 1000)

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

9F1. Useful Tools for Linux Administrators

adding exception words to vim's spellfile

You can add your exception words to vim spellfiles (while editing files) by using ']s' Search for next misspelled word & 'zg' add to the "g"ood words.

Or, you could create a separate file with your list of exception words & add them to vim spellfiles using the ':mkspell! %' command. Here is a script I used to add my separate file of exception words to vim's spellfile & regenerate the fast search file with ':mkspell! %'.

updatespellfile - add exception words to vim spellfile

 #!/bin/bash
 # updatespellfile - update spellfile for vim
 #  - script stored in /home/appsadm/sf/updatespellfile
 #    (search precedence over /home/uvadm/sf/adm/updatespellfile)
 #  - by Owen Townsend, UV Software, Sept 2020
 # Assumptions:
 # 1. common_profile contains:
 #    export APPSADM=/home/appsadm
 #    export SPELLDIR=$APPSADM/admin/spell/
 # 2. our .vimrc contains :setspellfile=$SPELLDIR/en.utf-8.add
 # 3. new words have been edited to $SPELLDIR/spellfile_adds
 #
 # This script will:
 # - backup existing spellfile $SPELLDIR/en.utf-8.add to $SPELLDIR/en.utf-8.add_20yymmdd_HHMMSS
 # - sort $SPELLDIR/spellfile_adds into $SPELLDIR/en.utf-8.add & overwrite existing
 #
 cp $SPELLDIR/en.utf-8.add $SPELLDIR/en.utf-8.add_$(date +%Y%m%d_%H%M%S)
 sort -u $SPELLDIR/spellfile_adds $SPELLDIR/en.utf-8.add -o tmp/en.utf-8.add
 echo "spellfile_adds sorted with existing en.utf-8.add, output in tmp/en.utf-8.add"
 ls -l $SPELLDIR       #<-- list files in spelldir
 echo " $SPELLDIR/files listed above (after sort any manual adds with existing .add)"
 echo " - enter to copy tmp/en.utf-8.add to existing $SPELLDIR/en.utf-8.add"; read reply
 cp -v tmp/en.utf-8.add $SPELLDIR/en.utf-8.add
 ls -l $SPELLDIR       #<-- list files in updated spelldir
 echo " - updated $SPELLDIR/files listed above, may inspect sorted en.utf-8.add as follows"
 echo "more $SPELLDIR/en.utf-8.add"
 #
 echo "Then need to --> vim, :set spell,& :mkspell! % <-- as shown below:"; read reply
 echo "vim $SPELLDIR/en.utf-8.add  #<-- edit the updated spell add file"
 echo ":mkspell! %                 #<-- recreate fast search version of spellfile adds"
 echo "==============              #    en.utf-8.add ---> en.utf-8.add.spl"
 exit 0
 # Could print $SPELLDIR/en.utf-8.add 6 words across, 14 chars/word as follows:
 # uvcopy multicol1,fili1=$SPELLDIR/en.utf-8.add,uop=c6d14
 # uvlp14D tmp/en.utf-8.add   <-- print at 14 cpi Duplex

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

9F2. Optimizing the capabilities of VIM

run script to add separate file of exception words

'multicol1' is a uvcopy job I used to list my vim exception word file in 6 columns across to minimize the number of pages to list my exception words.


 #1. ssh uvsoftxx@uvsoftware.ca  <-- Online userid in range uvsoft00-uvsoft99
     ==========================  <-- passxx <-- enter your password at the prompt
 #1a. Login userxx   <-- Alternative Login if VU installed on your machine
     =============   <-- passxx <-- enter your password at the prompt

 #2. cd /home/appsadm   <-- change to VU appsadm admin login account
     ================

 #3. tree admin/spell   <-- show files in /home/appsadm/admin/spell/...
     ================
      admin/spell
      |-- en.utf-8.add     <-- my list of exception words
      |-- en.utf-8.add.spl <-- fast search version of my exceptions
      |   |                  - created from my exceptions by ':mkspell! %'
      |-- en.utf-8.add_20200917_170726  <-- script makes a backup file
      `-- spellfile_adds   <-- my new exceptions to be sorted into en.utf-8.add

 #4. updatespellfile       <-- execute script (see listing on page above)
     ===============

My exception file was over 600 words (based on UVdemos1 & UVdemos2). I wanted to list them on hardcopy, but not if I had to list 1 word per line.

See how I used the 'multicol1' uvcopy job below, to list 6 words across.

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

9G1. Useful Tools for Linux Administrators

multicol1 - list file words multi-columns across

'multicol1' is a uvcopy job I used to list my vim exception word file in 6 columns across to minimize the number of pages to list my exception words.


 #5. uvcopy multicol1,fili1=admin/spell/en.utf-8.add,uop=c6d14
     =========================================================
      - output file defaults to tmp/en.utf-8.add
      - re: options 'uop=c6d14', c6 for 6 Columns, d14 for 14 chars per column

 #6. uvlp14D tmp/en.utf-8.add   <-- list at 14 cpi Duplex
     ========================

 #6a. head tmp/en.utf-8.add     <-- show 1st 10 lines
      =====================       - if no printer available
 # multicol1 - reformat input records into multi-columns (2up,3up,4up,etc)
 # 2020/09/23_08:38:21  uvsoft5 appsadm InputFile: admin/spell/en.utf-8.add
 #===============================================================================
 AIX            Ascii          BLKSIZE        CATLG          CAnadian       CNVDATA
 COBDIR         COND           CONDitions     CRs            CUTMAS         DEFAULTs
 DISAM          DISP           DSN            EMP            EOD            EOF
 EOG            FB             FBA            FilePatterns   GLMASTER       HISTSIZE
 HOSTNAME       Hoskins        IPreplace      InDir          JCL            JCLConversions
 JCLs           KeyWord        Korn           LD             LF             LIBrarieS
 LOGDIR         LOGNAME        LRECL          LST            LSTt           LineFeed
 LineFeeds      LinePatterns   Linefeeds      LoginUser      MVS            MainFrame
 MatchOps       MatchOptns     NDP            NextRecord     ODBC           ODBCINI
 ODBCSQL        ODBCSYSINI     OPtion         ORs            Offline        Online
                        ------ 96 lines omitted ------
 uvtest         uvtrain        ver            vimrc          vsejcl         vsetest
 wc             wildcard       wrtbig         wrts           www            x'FF
 xtod           xxxxx          yourdir        yourname       yyy            yyyy
 yyyymmdd       zz             zzz
 Totals: InRecords 633, OutLines 106, OutFile=tmp/en

You could use the 'multicol1' utility whenever you wish to list a file with many short lines in a multi-column format. The default options are uop=c4d20, but we used uop=c6d14 since we knew our maximum misspelled word was 12 characters.

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

9H1. Useful Tools for Linux Administrators

repage1 - reformat paragraphs with no LineFeeds

'repage1' is a uvcopy utility to reformat paragraphs with no LineFeeds to a shorter line width that will enable printing by unix/linux utilities. Word documents & emails may have long paragraphs that make printing difficult with unix/linux utilities.

 Our test/demo file tf/UVdemos1_promo has lines over 100 characters long, that we will
 repaginate to lines with maximum 90 characters so we can print on 8 1/2 paper at 13 cpi.
 Note that this documentation is printed Duplex at 13 cpi by $UV/sf/util/uvlp13D
 - 1 of many scripts calling the uvlist utility (see $UV/src/uvlist.c).

If you print this documentation with uvlp13D, you will see some text missing from the end of the lines (up to 110 characters). If you are reading on the screen, it depends on your screen (my screen allows 160 characters across).

We have limited our test file lines to 110 chars for convenience, but repage1 would handle long paragraphs with no LineFeeds until end of paragraph (max 4000 characters).

tf/UVdemos1_promo - INPUT file to be re-paginated

Subject: UVdemos1 - New Tutorial From: owen@uvsoftware.ca Date: September 22/2020

'UVdemos1' (subset of 'UVdemos2') is an easy way to become familiar with the Vancouver Utilities and using unix/linux on the command line. UVdemos1 was inspired by my grand children. I wanted to allow them to login to my website and run the C compiler & UV demos without having to download/install the Vancouver Utilities.

tf/UVdemos1_promo - OUTPUT file after repagination

Subject: UVdemos1 - New Tutorial From: owen@uvsoftware.ca Date: September 22/2020

'UVdemos1' (subset of 'UVdemos2') is an easy way to become familiar with the Vancouver Utilities and using unix/linux on the command line. UVdemos1 was inspired by my grand children. I wanted to allow them to login to my website and run the C compiler & UV demos without having to download/install the Vancouver Utilities.

Repaginate Logic

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

9H2. repage1 - reformat paragraphs with no LineFeeds

You can run this demo either online or offline (if VU installed on your machine).

Execute repage1 to split long paras to lines < 90


 #1a. ssh uvsoftxx@uvsoftware.ca  <-- login (userids uvsoft00-uvsoft99)
      ==========================   --> passxx <-- enter your password at the prompt
 #1b. Login userxx           <-- Alternative Login on your own machine
      ============               if you have installed Vancouver Utilities
 #2. cdm   <-- ensure you are in the demo/... subdir
     ===     - /home/uvsoftxx/demo/... for ssh to UVsoftware website
             - /home/userxx/demo/..... for logins on user machines
 #3. rm -f tmp*/*           <-- clear All tmp files
     ============             - tmp*/* same as tmp/* tmp1/* tmp2/*

 #4. cat tf/UVdemos1_promo   <-- inspect INPUT test/demo file
     =====================     - see INPUT listing on page above & below

 #5. uvcopy repage1,fili1=tf/UVdemos1_promo,uop=e10m80n90
     ====================================================
      - repaginate to line widths < 90 characters (option n90)
      - see options displayed & discussed on the next page
      repage1 - copy a text file modifying line width
      uop=q1b1d0e10m80n90p1s1t1 - option defaults
            b1              - reduce multiple blank lines to 1
              d0            - drop lines begining with # (currently disabled)
                e10         - scan back e# cols for . to determine line width
                   m80      - minimum leave as is (longer lines will be repaged)
                      n90   - maximum length for lines in repaginated paragraphs
                    p1      - replace unprintable chars with . periods
                  t1        - replace tabs with 1 space
                s1          - squeeze line data left (1 blank between words)
      User OPtion (uop) defaults  = q1b1d0e10m80n90p1t1s1m80n90e10
      -->null to accept or enter/override -->   <-- null accept option defaults
      20200922:373601:repage1: EOF fili01 rds=23 size=1370: tf/UVdemos1_promo
      20200922:373601:repage1: EOF filo01 wrts=27 size=1365: tmp/UVdemos1_promo

 #6. cat tmp/UVdemos1_promo   <-- inspect repaginated OUTPUT file
     ======================     - see OUTPUT listing on page above & below
                                - output in tmp/... same name as input file

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

9H3. repage1 - Repaginate Logic & Options

tf/UVdemos1_promo - INPUT (rpeated for discussion)

Subject: UVdemos1 - New Tutorial From: owen@uvsoftware.ca Date: September 22/2020

'UVdemos1' (subset of 'UVdemos2') is an easy way to become familiar with the Vancouver Utilities and using unix/linux on the command line. UVdemos1 was inspired by my grand children. I wanted to allow them to login to my website and run the C compiler & UV demos without having to download/install the Vancouver Utilities.

tf/UVdemos1_promo - OUTPUT file after repagination

Subject: UVdemos1 - New Tutorial From: owen@uvsoftware.ca Date: September 22/2020

'UVdemos1' (subset of 'UVdemos2') is an easy way to become familiar with the Vancouver Utilities and using unix/linux on the command line. UVdemos1 was inspired by my grand children. I wanted to allow them to login to my website and run the C compiler & UV demos without having to download/install the Vancouver Utilities.

repage1 actions

Repaginate Logic

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

20A1. Relevant Vancouver Utilities Documentation

Here are links to other relevant Vancouver Utilities Documentation.


 https://uvsoftware.ca/uvdemos2.htm
  ==================================
  - Vancouver Utilities for any Unix/Linux site
  - minimizing JCL conversion & maximizing General Purpose use
  - many useful command line utilities & scripts
  - Selectjobs, Tablejobs, UVscripts
  - presented in a demo/tutorial manner
  - run the commands & see if your outputs matches expected results

 https://uvsoftware.ca/uvhd.htm
  ===============================
  - interactive data file investigation utility
  - displays records in 'vertical hexadecimal'
  - great for mainframe type files with packed/binary data
  - browse,search,update,select,print,etc
  - most customer's favorite utility

 https://uvsoftware.ca/uvsort.htm
  =================================
  - Vancouver Utility replacement for mainframe SORT
  - JCL converter automatically converts SORT steps to uvsort syntax
  - handles all but a few complex DFSORT functions such as JOIN & PARSE
    which are handled by uvcopy with some manual coding required

 https://uvsoftware.ca/uvcp.htm
  ===============================
  - Vancouver Utility replacement for IDCAMS, IEBGENER, etc
  - JCL converter converts IDCAMS,IEBGENER,etc to uvcp
  - can select/delete records, reformat records, etc

 https://uvsoftware.ca/uvcopy1.htm
  ==================================
  - most powerful Vancouver Utility
  - replaces mainframe utilities
    (IEBGENER,SORT JOINKEYS,PARSE,ICETOOL,QUIKJOB,EASYTRIEVE,etc)
  - documentation in 3 parts

 https://uvsoftware.ca/uvcopy2.htm
  ==================================
  - uvcopy functions (vs instructions in uvcopy3)
  - file declarations, file types,
  - options, work areas, variable names

 https://uvsoftware.ca/uvcopy3.htm
  ==================================
  - uvcopy instructions (over 100 instructions)
  - uvcopy an extremely powerful data manipulation utility
  - the power of assembler language without the complexity
  - interpretive, just create/modify a parameter file & execute it

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


 'https://uvsoftware.ca/install.htm'
  ==================================
  Install Vancouver Utilities

 https://uvsoftware.ca/uvtrain.htm
  ==================================
  Vanvouver Utilities Training Guide
  - for uvsort, uvcp, uvcopy, uvhd, uvlist
  - examples & exercises

 https://uvsoftware.ca/uvhelp.htm
  =================================
  - command line menus to most useful utilities
  - both unix system utilities & Vancouver Utilities
  - handy way to find the syntax of many useful commands
  - just enter --> uvhelp <-- at your shell prompt

 https://uvsoftware.ca/scripts1.htm
  ===================================
  many useful scripts calling both unix utilities & Vancouver Utiliites
  - just a few examples are: renaming files,
  - counting lines in all files in directory
  - counting files in all subdirs of a superdir
  - running unix 'diff' for all files in 2 directories
  - listing, moving, removing files older than a number of days, etc

 https://uvsoftware.ca/jclcnvbrief.htm
  ======================================
  JCL Conversion - a 'SHORTER' more concise version
  (not yet complete as of May 2020)

 https://uvsoftware.ca/jclcnv1demo.htm
  ======================================
  JCL Conversion - the 'LONG' version

 https://uvsoftware.ca/jclcnvbrief.htm
  ======================================
  JCL Conversion - a 'SHORTER' more concise version
  (not yet complete as of May 2020)

 https://uvsoftware.ca/jclcnv3aids.htm
  ======================================
  Testing aids & utilties that may assist JCL conversions

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

20B1. Links to uvcopy Instructions documeentation

Here are links to uvcopy instructions documented in uvsoftware.ca/uvcopy3.htm

Clicking on these links take you into that separate document, so you should "right-click" on these links to open in a new tab, so you will not lose your place in this uvdemos1.doc.

INDEX to uvcopy INSTRUCTIONS

 add = add op2 data to op1 data & store result in op1                   
anc = ANd Character (erase bits in op1 with 0 bits in op2)
bal = branch & link to a subroutine
bcr = Branch on Condition & Return
bcr example = testbcr1 test/demo job for bcr instruction
cat = concatenate op2 data onto op1 data (within op1 limits)
can = cancel the uvcopy job
chx = convert character representation of hex to true hex data
clr = clear the op1 area to the op2 byte value
cls = close a file
cmc = compare and set internal condition code for following skp
cmn = compare numeric & set condition code for following skp
cnt = count the number of op2 patterns in the op1 area
ctr = center data within the op1 area
data type & sign codes
dat = convert dates between: calendar,julian,& days-since-1900
del = delete a record in an Indexed file
div = divide the op1 data by the op2 data & store result in op1
dlm = convert Fixed-Field to "delimited","format"
dtf = Delimited To Fixed-field
edt = edit op2 data into op1 area controlled by op3 mask
env = get value for any specified environmental variable
eoj = end the job
evt = get & table the values for all environmental variables
evs = copy text, expanding any environmental variables
expandevs1 = using "evs" to expand $VARIABLEs in DB2 scripts
fix = convert variable field format to fixed length fields
ftd = Fixed-field To Delimited
fxt = add a uvcopy instruction to the execution table
get = next record from a sequential file & store in the op2 area
getrecsizes1 = demo recsizes stored in register 'v' by 'get'
getcopydir1 = demo 'get' filenames from directory & copy all files
hxc = convert hex data to hex character representation
ins = insert op2 data prior to op1 data
lck = lock a D-ISAM Indexed file
lok = look-up a table of data (op1) for match to argument (op2)
mpy = multiply op1 data by op2 data & store result in op1
msg = display a msg (1 or 2 lines) on stdout
msgw = display message & wait for reply (option "w" of msg)
mvc = move character data from op2 to op1 for op1 length
mvf = move op2 to op1 for lth op2 & fill excess op1 with op3 char
mvr = move data op2 to op1 right adjust, left fill with op3 char
mvp = move op2 to op1,if all EBCDIC blanks,convert to ASCII blanks
mvn = move numeric data depending on op1/op2 types & lengths
mvu = move op2 data to op1 area until the op3 pattern detected

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

INDEX to uvcopy INSTRUCTIONS (continued)

 opn = open a file - or all files declared if op1 = 'all'               
orc = OR Character - set 1 bits in op1 with matching 1 bits in op2
pac = pack the op2 data into the op1 area
pop = process option string into process/user option storage
put = a record to a sequential file
ran = generate random numbers
rel = set file pointer (relative record# or relative byte#)
red = read a record from an indexed file
ret = return from subroutine (to the instruction following the bal)
rep = scan op1 replacing all op2 patterns with the op3 data
rpt = replace by table
rtb = read a table of data into the op1 area (at run time)
rts = scan a table for a pattern & replace with an alternate
rtt = replace patterns in data table via search/replace table
scn = scan op1 area for op2 pattern & set cc equal if found
sct = scan by table
set = set key of reference & file pointer in an Indexed file
shf = shift data a specified number of bits left or right
skeleton1 = template job to copy, rename,& modify as required
skp = skip to tag (or number of instrns) if condition code matches
skptable = demo job lookup table of Record-Types & Process-Labels
sort (external) - sxo, sxp, sxs, sxg, sxc
sqz = squeeze out occurrences of the op2 character from op1
sqf = squeeze multiple contiguous fields & blank fill at the end
srt = internal sort (tables, record arrays, etc)
sst = scan using table patterns to match or not-match
sta = search data tables & count matches in a pattern table
sts = scan a table for a character string
stt = search data tables for any match to a pattern table
sub = subtract op2 data from op1 data & store result in op1
subrtn example = cymd compare 6 digit dates for Year 2000
swp = swap left & right sides of data in op1 based on op2 separator
sys = issue system commands - call the shell to execute op1 string
table overview = build tables in memory to dump at EOJ
table formats = supplied formats available (f1-f12)
table entry layout = dumped by tbd (unedited)
tbl = build tables in memory to be dumped at end of job
tbf = declare formats to use when editing tables to output files
tbh = declare table column (field) headings
tbp = print (edit) the table entries into a file (usually at eoj)
tbd = dump (unedited) table entries into a file (usually at eoj)
tim = get current date & time & store in area y for user access
tra = translate to ASCII (from EBCDIC)
tre = translate to EBCDIC (from ASCII)
trl = translate to lower case (any UPPER case present)
tru = translate to UPPER case (any lower case present)
trt = translate via user specified (or modified) translate table
trs = translate/search command
tst = test each op1 sub-field for match to any op2 sub-field
tsb = test 1 byte of data for any match to bits in the 1 byte op2
tts = scan data table lines for matches to pattern table
ttx = scan data table groups for matches to pattern table

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

INDEX to uvcopy INSTRUCTIONS (continued)

 ulk = unlock a D-ISAM Indexed file                                     
unp = unpack the op2 data into the op1 area
und = convert "delimited","format" to Fixed-Field
update_rel reldemo1 - update in place
upd = update a record in an Indexed file
upw = update/write record depending on key present/absent
var = convert multi fixed length fields to variable length string
vhx = convert data to vertical hexadecimal representation
vnf = Verify Numeric Field
wat = wait a specified number of seconds
wrt = write a new record into an Indexed file
wtb = write a table of data from the op1 area (at run time)
xft = crossfoot multiple op2 fields & store the result in op1
xor = eXclusive OR (bit manipulation)
xxa = call user subfunction (written in C & linked to uvcopy)

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

Visitor Counters for ThisYear and LastYear