1. NUMERIC INPUT

The 20/Aug/97 Jeff Zeitlin <jeff.zeitlin at EARTH.EXECNET.COM> wrote:
> ... I find that for a project I am working on, I need some
> "bulletproof" routines for numeric input which allow for "full"
> input editing (at least supporting destructive backspace).  At a
> minimum, I need to be able to optionally restrict input to
> integral values; best would be if I could both restrict the type
> (integer vs. float/atom) and the range (lowest and highest
> allowed values, allowing for open-ended ranges).
--
Hi Jeff,
I send a routine who can be adapted to your needs. You can
add  restriction in the loop and prune the unnecessary.
Hope that help you.
-- Jean.Hendrickx. j.hendrickx at euronet.be

UUENCODED file attachment

BEGIN--cut here--CUT HERE
begin 600 NUMFILTR.ex
6<GTI#0H_(&9N=6UB97(@*C,@+S,-"@``
`
end

END--cut here--CUT HERE

new topic     » topic index » view message » categorize

2. NUMERIC INPUT

Hey to all!

Jean Hendrickx wrote recently:

>> ... I find that for a project I am working on, I need some
>> "bulletproof" routines for numeric input which allow for "full"
>> input editing (at least supporting destructive backspace).  At a
>> minimum, I need to be able to optionally restrict input to
>> integral values; best would be if I could both restrict the type
>> (integer vs. float/atom) and the range (lowest and highest
>> allowed values, allowing for open-ended ranges).

>Hi Jeff,
>I send a routine who can be adapted to your needs. You can
>add  restriction in the loop and prune the unnecessary.
>Hope that help you.
>-- Jean.Hendrickx. j.hendrickx at euronet.be

The code in your post seemed a little involved for what =

Jeff is trying to do.  Here is a couple of suggestions:

First of all, try using the INPUT.E include file.
It will give you the means necessary to get numeric
input.  Here it is:

include get.e
global function input(sequence prompt)
  sequence dummy
  puts(1,prompt)
  dummy =3D get(0)
  return dummy[2]
end function
  =

Now, you said you needed to restrict the numbers
the user types to certain kinds.  Try
declaring types.  Example: if the user
can only type in an integer, then do this:

object junk
while 1 do
  junk =3D input("Enter a number:")
  if integer(junk) then
    exit
  else
    puts(1,"Please enter an integer only.")
  end if
end while

If you need to set a certain range for your
input, then declare a type.  For example,
if you needed input that is greater than 0 and =

less than 256, then do this:

type character(integer x)
  return x > 0 and x < 256
end type

Now, just use that code above, replacing all
"integer"s with "character"s.

I hope this helps out a little.  =


Regards,
  Bryan Watts
  =

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu