utility
|
cmd_head.c,
count_tokens.c,
cp_file.c,
errmsg.c,
file_opened.c,
find_line.c,
find_string.c,
fn_base.c,
fn_dir.c,
fn_ext.c,
fn_root.c,
gchoice.c,
gdata_line.c,
gdouble.c,
gfield.c,
gint.c,
gntoken.c,
graphics_ok.c,
gstring.c,
lock.c,
lower.c,
mat_multiply.c,
mat_transform.c,
mat_transpose.c,
mv_file.c,
new_extension.c,
nolead.c,
notrail.c,
ordinal.c,
pfield.c,
squish_blanks.c,
test.c,
unlock.c,
upper.c,
utility.h,
utility.make,
valchars.c,
vec_angle.c,
vec_crossprod.c,
vec_diff.c,
vec_dotprod.c,
vec_length.c,
vec_norm.c,
|
|
|
#include "utility.h"
int gdouble(prompt,null_ok,range_check,minimum,maximum,number)
/*============================================================================*/
/* PURPOSE: GET A DOUBLE 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 DOUBLE 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;
double minimum;
double maximum;
double *number;
{
char response[100]; /* USER INPUT. */
double candidate; /* POSSIBLY VALID DOUBLE TO BE CHECKED. */
int status; /* USER INPUT STATUS. */
while(TRUE)
{
status=gstring(prompt,null_ok,response);
if (status==ABORT_ENTRY || status==NULL_ENTRY) return(status);
if (! valchars(response,"-0123456789.eE"))
fprintf(stderr,"Error: Invalid response.\n\n");
else
{
candidate=atof(response);
if (range_check && (candidatemaximum))
fprintf(stderr,"Error: Response out of range.\n\n");
else
{
*number=candidate;
return(VALID_ENTRY);
}
}
}
}
|