Alien-Judy

 view release on metacpan or  search on metacpan

src/judy-1.0.5/test/jbgraph  view on Meta::CPAN

# - use getopts.
# Note:  FUNCTION__getopt is run twice, in order to support:
#        FUNCTION_TITLE_COLHEAD()	# Set Column headings from file.

    ${v}echo "${C}.${0}:  beginning at `date`"	# beginning of function

    USAGE="${C} [ -E -G -H -I -M -S -V -i -l -m -q -r -u -v ]
	[ -C GNU_CMDFILE ]
	[ -D LP_DEV ]
	[ -L axis ]
	[ -N not option ] (turn off option), Example:  -NL
	[ -P GNU_PSFILE ]
	[ -c COLUMN_NUMBER ]
	[ -d differential_type ]
	[ -g GNU_GEOMETRY ]
	[ -o LP_OPT ]
	[ -x xRANGE ]
	[ -y yRANGE ]

    ${C}:  wrapper for gnuplot

    -c plot column number.  This is useful to plot by column number.
    -i plot insert; default if no other plots selected.      CMN=2
    -r plot retrievals; default if no other plots selected.  CMN=4
    -I plot memory used / index.                             CMN=12
    -m plot memory malloced.                                 CMN=9
    -M plot memory used and free.                            CMN=8
    -l plot leaf data.                                       CMN=11
    -d plot derivative data.  Useful with -i, -r, -m.  CMN=2,4,9

    -x xRANGE, scale range;  example:  -x [1000:5000] or -x1000:5000
    -y yRANGE, scale range;  example:  -y [1M:10M]    or -y1M:10M
	 1[kK] = 1,000; 1[mM] = 1,000,000; 1[gG] = 1,000,000,000.

    -n number plot descriptions; Use column numbers before the description.
    -L set logscale axis; default,
	Example:  Turn off logscale with -NL, then turn on, on only one axis:
	  \"-NL -Lx\" or \"-NL -Ly\", Turn off both with -NL
    -G grid lines on.
    -H default column headings.
    -g geometry description.
	 default=\"${GNU_GEOMETRY_DEF}\", # 4x3 aspect ratio.

    -E use embedded options, default, Turn off with -NE. 
      Sets TITLE, COLHEAD, GETOPT from the FIRST data file encountered.
      Example:  embedded options in the data file begin in column 1:
      # TITLE This is the title to pass to gnuplot
      # COLHEAD 1 This is the heading for column 1.
      # XLABEL This is the x-axis label
      # YLABEL This is the y-axis label
      # GETOPT -c2 -c3 -G	# These are the options to use.

    -p print the plot.
    -o LP_OPT printer option(s);  default \"${LP_OPT_DEF}\".
	 Example:  \"-ootray2\" will print on clear slides, emits \"-otray2\"
	 Example:  \"-on2\" will print two copies, emits \"-n2\"
    -D LP_DEV printer device;  default \"${LP_DEV_DEF}\".

    -C GNU_CMDFILE name;  default is generated and removed: 
         ${OUTPUT_DIR}/{DATE_TIME}.GNU_CMDFILE
	 Useful to do your own gnuplot command editing and debugging.
    -P GNU_PSFILE name.  default is generated and removed:
         ${OUTPUT_DIR}/{DATE_TIME}.GNU_PSFILE
    -S Save files.
	 Generated and working file names are deleted unless -S or -C is on.
	 User provided file names are not deleted in any case (-C, -P).

    -q quiet mode, verbose mode off;  default.
    -v verbose mode on.

    -V vi the plot file.
       quit using \"q\"

    -N not option;  Turn specified option off.  Example:  -NL
         Note, -N is not available for all options.
    -NL Turn off:  -L set logscale axis; default
    -NH Turn off:  -H default column headings.

    -u Usage message.

    Sample usage:
    ${C} -i  -f data/datafile	# -i is the same as -c1.
    ${C} -c1 -f data/datafile	# -i is the same as -c1.

     "

    ${v}echo "${C}.${0}:  OPTIONS=${*}"

# Parse options, using getopt:
#
# - "a" option, no parameter; "b:" indicates a parameter.
# - Order of options is "man 5 ascii".

    getopt_PARM="?C:D:EGIL:MN:P:SVc:d:g:ilmno:prsuvx:y:"
    set -- `getopt ${getopt_PARM} $*`	# Place options in argc/argv.
    if [ "${?}" != "0" ]; then		# If getopt returns an errror.
        ${v}echo "${C}.${0}:  \${?}=${?}, USAGE message from return code."
        echo "${USAGE}"
	exit 1
    fi

    while [ ${#} -gt 0 ]		# while there are options...
    do					# ( for vi parenthesis matching
        ${v}echo "${C}.${0}:  parsing option \"${1}\", then \"${2}\""
        case ${1} in

        -C)
	    OPT_C="${1}"
            OPT_C_PARM="${2}"		# GNU_CMDFILE name.
            ${v}echo "${C}.${0}:  OPT_C=${OPT_C}, # -C GNU_CMDFILE name."
	    ${v}echo "${C}.${0}:  OPT_C_PARM=${OPT_C_PARM}, # GNU_CMDFILE name."
            export GNU_CMDFILE="${OPT_C_PARM}"
	    MSG="# GNU_CMDFILE name."
	    ${v}echo "${C}.${0}:  GNU_CMDFILE=${GNU_CMDFILE}, ${MSG}"
            shift
            ;;				# ( for vi parenthesis matching

        -D)
	    OPT_D="${1}"
            OPT_D_PARM="${2}"		# LP_DEV name.
            ${v}echo "${C}.${0}:  OPT_D=${OPT_D}, # -D LP_DEV printer device."

src/judy-1.0.5/test/jbgraph  view on Meta::CPAN

	# Grab the FIRST TITLE line (head -1) and use it.
	TITLE="`grep '^# *TITLE' ${FTC_FILE} | head -1 |
	  sed -e 's/^# *TITLE *//g'`"
        ${v}echo "${C}.${0}:  TITLE=${TITLE}"

	# Grab the FIRST XLABEL line (head -1) and use it.
	XLABEL="`grep '^# *XLABEL' ${FTC_FILE} | head -1 |
	  sed -e 's/^# *XLABEL *//g'`"
        ${v}echo "${C}.${0}:  XLABEL=${XLABEL}"

	# Grab the FIRST YLABEL line (head -1) and use it.
	YLABEL="`grep '^# *YLABEL' ${FTC_FILE} | head -1 |
	  sed -e 's/^# *YLABEL *//g'`"
        ${v}echo "${C}.${0}:  YLABEL=${YLABEL}"

	# Find each COLHEAD, and put it in the correct CHA[INDEX].
        let i=0
        while [ ${i} -lt ${#CHA[*]} ]	# For each COLHEAD
        do
	    # Grab one COLHEAD line at a time, put it into CHA[].
	      # Note, "@" not allowed in COLHEAD string.
	    LINE="`grep \"^#.*COLHEAD\" ${FTC_FILE} |	# Find COLHEAD.
	      sed -e 's/^#.*COLHEAD*//g' \
		  -e 's/^ *//g' \
		  -e 's/@//g' | # Remove COLHEAD.
	      expand | sed -e 's/^0*//g' | # Remove leading zeros.
	      grep ^${i} |		# Find a line matching ${i}.
	      head -1 `"		# Make sure there is only 1.

	    # Grab the INDEX number, could do numeric check if problems.
	    INDEX="`echo ${LINE} | cut -d\" \" -f1`" # field 1 is number.

	    # If INDEX is not empty, save this COLHEAD.
	    if [ "${INDEX}" != "" ]; then
	        # Grab the rest of the line and save it into CHA.
	        REMAINDER="`echo ${LINE} | sed -e \"s@^${INDEX} *@@g\"`"
	        CHA[${INDEX}]="${REMAINDER}"
                ${v}echo "${C}.${0}:  CHA[${INDEX}]=\"${CHA[${INDEX}]}\""
	    fi

	    let i=i+1
        done

	# GETOPT, pull in options to be set for this data.
	GETOPT="`grep '^# *GETOPT' ${FTC_FILE} | head -1 |
	  sed -e 's/^# *GETOPT *//g'`"
	if [ "${GETOPT}" != "" ]; then
            FUNCTION__getopt ${GETOPT}		# Parse the options.
	fi
	unset GETOPT

    fi

    ${v}echo "${C}.${0}:  completed at `date`\n"	# end of function
} # FUNCTION_TITLE_COLHEAD()		# Set Column headings from file.

FUNCTION_n()				# -n number plot descriptions.
{
# ADD COLUMN NUMBER TO EACH ELEMENT IN CHA:
#
# - This is done for comparing plots, and/or debugging.

    ${v}echo "${C}.${0}:  beginning at `date`"	# beginning of function
    ${v}echo "${C}.${0}:  OPT_n=${OPT_n}, # -n number plot descriptions"

    let i=0
    while [ ${i} -lt ${#CHA[*]} ]
    do
       CHA[${i}]="${i} ${CHA[${i}]}"
       ${v}echo "${C}.${0}:  CHA[${i}]=\"${CHA[${i}]}\""
       let i=i+1
    done
    ${v}echo "${C}.${0}:  completed at `date`\n"	# end of function
} # FUNCTION_n()			# -n number plot descriptions.

FUNCTION_units()			# Resolve units.
{
#
# Expand units of the form 1K to 1000, 1M to 1000000, et.al.
# Used to format the gnuplot parameters xRANGE and yRANGE.
# gnuplot data format:  "set xrange [1:1000000]"
#

    Fu_IN="${1}"			# Units in.
    echo "["${Fu_IN}"]" |
      sed -e "s/[kK]/000/g"	      | # 1,000
      sed -e "s/[mM]/000000/g"	      | # 1,000,000
      sed -e "s/[gG]/000000000/g"     | # 1,000,000,000
      sed -e "s/^\[\[/\["/g	      | # Ensure single leading bracket.
      sed -e "s/\]\]$/\]"/g	        # Ensure single trailing bracket.
}

FUNCTION_a()				# -a Option description.
{
#
# Replace with description of this function.
#

    ${v}echo "${C}.${0}:  beginning at `date`"	# beginning of function
    ${v}echo "${C}.${0}:  OPT_a=${OPT_a}, # -a Option description."
    ${v}echo "${C}.${0}:  completed at `date`\n"	# end of function
} #

FUNCTION_b()				# -b Option description.
{
#
# Replace with description of this function.
#

    ${v}echo "${C}.${0}:  beginning at `date`"	# beginning of function
    ${v}echo "${C}.${0}:  OPT_b=${OPT_b}, # -b Option description."
    MSG="# -b   Parameter description."
    ${v}echo "${C}.${0}:  OPT_b_PARM=${OPT_b_PARM}, ${MSG}"

    if [ -r "${OPT_b_PARM}" ]; then	# Ensure this is a file.
        echo ${OPT_b_PARM} |
          while read -r FILE; do
            ${v}echo "${C}.${0}:  FILE=${FILE}"
          done
    else				# Or use elif (form of elseif).
        ${v}echo "${C}.${0}:  ERROR, ${OPT_b_PARM} is not a readable file."



( run in 0.646 second using v1.01-cache-2.11-cpan-5511b514fd6 )