#! /bin/sh
#
# @(#)setPAGELENGTH	1.3	LPS_UNX_COM	01/18/95
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# setPAGELENGTH
#
# A script that produces a value for attribute PAGELENGTH.
#
# Parameters:
#    $1 - LPS class identifier, one of {PC, MC, PS, ENV}
#    $2 - Operating system type identifier (eg: SV2, BSD, etc)
#    $3 - Print client type identifier (eg: AIX, BSD, SV3, etc)
#    $4 - PrintServer printer model (eg: LPS17, LPS20)
#    $5 - Default value for the attribute
#    $6 - Path of the output file to receive the final attribute value
#
# Global variables:
#    ECHON
#    FUNCS
#    PAGER
#    TR    (for the checknumrange() function)
#
# Exit values:
#    0 - Success, output file contains newly set attribute value.
#    1 - Error or interruption occurred, error messages go to stderr,
#	 contents of the output file are undefined.
###

CLASS=$1
OSTYPE=$2
PCTYPE=$3
PSMODEL=$4
DEFVAL=$5
OUTFILE=$6

. $FUNCS   # Import the standard LPS shell functions

if [ "$CLASS" = "ENV" ]
then
   NOTES="
You are now being asked to enter a page LENGTH value that will be used 
as the default response when a Print Client is configured.

A typical site will choose the default response to this question."
fi

showhelp true "
Default page length (in lines)?

When a plain ASCII text file is sent to a Print Client, the file will
be converted to PostScript(R) before being sent to the printer.  To
perform the conversion, the Print Client must use a page length value
(how many lines per page) and a page width value (the maximum number of
characters that can fit on one line).

If the user does not specify the page width and/or length when the
print job is submitted, then the Print Client will use the values set
when the Print Client was configured.

Nearly any combination of values can be made to work, with a certain
amount of trial and error.  Typically, portrait-mode printing uses 
66 lines of 80 characters, while landscape-mode printing uses 
66 lines of 132 characters.

For reasons of general sanity, this procedure constrains you to enter only
values that fall in the specified range.  
$NOTES"

MIN=20
MAX=150
DEF=$DEFVAL

while true
do
    echo
    $ECHON "Default number of lines per page ($MIN-$MAX) [$DEF] ? "
    read resp
    if checknumrange $MIN $MAX $DEF "$resp"
    then
	echo "$RESPONSE" > $OUTFILE
	exit 0
    fi
done
