Board index » delphi » easy question (I think)

easy question (I think)

Hello,

I want to read a real var, but I want to prevent that wen sommeone types a
number, he can type an infinite long number. It can't be too difficult, but
I can't find it in the helpfiles.

Thanks,

Pieter

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 

Re:easy question (I think)


how about :
for 8 digits plus '.' a total string[9] variable

then reading one 'char' at a time checking to make sure it is a valid
integer (and for only one '.' if you are doing a real number)

writing each character to screen and allowing for backspace and line
delete characters

then once 'carriage return' entered on valid string - converting it
to a real number?

Quote
Pieter Cogghe wrote:

> Hello,

> I want to read a real var, but I want to prevent that wen sommeone types a
> number, he can type an infinite long number. It can't be too difficult, but
> I can't find it in the helpfiles.

> Thanks,

> Pieter

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:easy question (I think)


Quote
"Pieter Cogghe" <piecog14-...@freeweb.be> wrote:
>I want to read a real var, but I want to prevent that wen sommeone types a
>number, he can type an infinite long number. It can't be too difficult, but
>I can't find it in the helpfiles.

If you're reading a floating point number, it doesn't hurt if
they enter extra digits.

Re:easy question (I think)


JRS:  In article <3b0acfcd_4@newsfeeds>, seen in
news:comp.lang.pascal.borland, Pieter Cogghe <piecog14-...@freeweb.be>
wrote at Tue, 22 May 2001 22:54:37 :-

Quote

>I want to read a real var, but I want to prevent that wen sommeone types a
>number, he can type an infinite long number. It can't be too difficult, but
>I can't find it in the helpfiles.

You should be wanting to prevent any invalid number, IMHO; 3..5 is worse
than 3.50000000000000000000000000000000000000008 is.

Just use Val, and loop until an acceptable number is given.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk  Turnpike v4.00   MSIE 4 ?
 <URL: http://www.jibbering.com/faq/> FAQ for comp.lang.javascript by Jim Ley.
 <URL: http://www.merlyn.demon.co.uk/js-index.htm>  Javascript maths, sources.
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

Other Threads