padded_integer.sh
Last updated: May27,2020

Build a zero-padded, right-adjusted string from an integer value. I use this to build PAS name strings based of the obs,exp value of a particula image set. I also use to build name of profiles.sh data tables.
  
% padded_integer.sh --help

Usage: padded_integer.sh 14 3 N 
arg1 - integer value to be padded
arg2 - number of characters requested in output (right-justified) string 
arg3 - Run in a debug/verbose mode 

Examples:
# To make a 3-char observation string for lmap   
% padded_integer.sh 14 3 N 
% cat padded_integer.out
014

# To make a 2-char exposure string for lmap   
% padded_integer.sh 1 2 N 
% cat padded_integer.out
01


Presently this is a rather klunky code that handles a maximum output lenght of only 5 characters. This routine does very little error checking. If it gets into trouble it dumps the string "000" into the output file (padded_integer.out).




Back to SCO code page