CCL Home Page
Up Directory CCL gint
#include "utility.h"

int gint(prompt,null_ok,range_check,minimum,maximum,number)
/*============================================================================*/
/* PURPOSE: GET AN INTEGER SUBJECT TO RANGE CONSTRAINTS FROM THE USER.
/* INPUTS:
/*	PROMPT		PROMPT STRING TO BE DISPLAYED FOR USER.
/*	NULL_OK		TRUE/FALSE IF NULL ENTRY IS VALID.
/*	RANGE_CHECK	TRUE/FALSE IF RANGE CHECKING IS DESIRED.
/*	MINIMUM		MINIMUM ALLOWED INPUT IF RANGE_CHECK IS TRUE.
/*	MAXIMUM		MAXIMUM ALLOWED INPUT IF RANGE_CHECK IS TRUE.
/* OUTPUTS:
/*	NUMBER		VALID INTEGER BETWEEN MINIMUM AND MAXIMUM IF
/*			RANGE_CHECK IS TRUE.
/*	FUNCTION VALUE	STATUS OF USER RESPONSE (AS IN UTILITY.H).
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   char prompt[];
   int null_ok;
   int range_check;
   int minimum;
   int maximum;
   int *number;
   {
   char response[100];
   int candidate;
   int status;

   while(TRUE)
      {
      status=gstring(prompt,null_ok,response);

      if (status==ABORT_ENTRY || status==NULL_ENTRY) return(status);
      else if (! valchars(response,"-0123456789"))
         fprintf(stderr,"Error: Invalid response.\n\n");
      else
         {
         candidate=atoi(response);
         if (range_check && (candidatemaximum))
            fprintf(stderr,"Error: Response out of range.\n\n");
         else
            {
            *number=candidate;
            return(VALID_ENTRY);
            }
         }
      }
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5265 times since Sat Apr 17 21:58:56 1999 GMT