file: 10-C-utils.t package: muf status: alpha
This function prompts the user for a float value via
@$s.queryOutput and then reads it via
@$s.queryInput. It loops until
it obtains a value greater than or equal to
min and less than or equal to max
and then returns that value.
It is currently implemented as:
: queryForFloat { $ $ $ $ -> $ } -> max -> was -> min -> what
was min >= if
[ "The '%s' was %g.\n" what was
| ]print @$s.queryOutput writeStream
fi
do{
[ "Please enter new float value for '%s':\n" what
| ]print @$s.queryOutput writeStream
@$s.queryInput readStreamLine pop trimString -> string
string "%f" unprint[ |pop -> result ]pop
result min < if
[ "Sorry, the '%s' must be at least %g.\n" what min
| ]print @$s.queryOutput writeStream
continue
fi
result max > if
[ "Sorry, the '%s' must be at most %g.\n" what max
| ]print @$s.queryOutput writeStream
continue
fi
result return
}
;
'queryForFloat export
Go to the first, previous, next, last section, table of contents.