Testing for numeric input
Pickering, John (NORBORD)
PICKERIJ@norbord.com
Tue, 18 May 2004 17:27:00 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C43D1E.DB3037A0
Content-Type: text/plain;
charset="iso-8859-1"
How about letting PowerHouse do the job for you. Even though the field is
defined as character in the dictionary or screen you can put NUMERIC on the
field statement along with any of the numeric field statement parameters
such as a suitable picture clause and a values clause. PowerHouse will quite
happily refuse non-numeric entries, will accept the "-" and the "+" and with
appropriate picture will deal with the decimal point correctly.
Stop fighting the tool :-)
-----Original Message-----
From: Thomson, Martyn EDUC:EX [mailto:Martyn.Thomson@gems1.gov.bc.ca]
Sent: Tuesday, May 18, 2004 4:24 PM
To: POWERHOUSE NEW (E-mail)
Subject: Testing for numeric input
Hello listers,
Does anyone know of a simple way to test if the input to a text field is
numeric within a range -999.99 to +999.99 with the "+" being optional.
Using NCONVERT(fieldtext) causes a data expression error when the argument
is not numeric.
I looked at matching against every possible pattern the user could enter,
but since the "-","+" and "." are optional on input, and the range has be
taken into account, the number of combinations soon gets unmanageable.
I could loop through each character matching against characters 0 to 9 , . -
+ but then coding to ensure that the plus, negative and period characters
are in appropriate positions and not repeated, also soon becomes lengthy.
There must be a more elegant method eh?
Regards,
Martyn Thomson
Ministry of Education, Victoria, BC
------_=_NextPart_001_01C43D1E.DB3037A0
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=328372821-18052004><FONT face=Arial color=#0000ff size=2>How
about letting PowerHouse do the job for you. Even though the field is defined as
character in the dictionary or screen you can put NUMERIC on the field statement
along with any of the numeric field statement parameters such as a suitable
picture clause and a values clause. PowerHouse will quite happily refuse
non-numeric entries, will accept the "-" and the "+" and with appropriate
picture will deal with the decimal point correctly.</FONT></SPAN></DIV>
<DIV><SPAN class=328372821-18052004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=328372821-18052004><FONT face=Arial color=#0000ff size=2>Stop
fighting the tool :-)</FONT></SPAN></DIV>
<DIV><SPAN class=328372821-18052004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=328372821-18052004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Thomson, Martyn EDUC:EX
[mailto:Martyn.Thomson@gems1.gov.bc.ca]<BR><B>Sent:</B> Tuesday, May 18, 2004
4:24 PM<BR><B>To:</B> POWERHOUSE NEW (E-mail)<BR><B>Subject:</B> Testing for
numeric input<BR><BR></FONT></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Hello
listers,</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Does anyone know
of a simple way to test if the input to a text field is numeric within a
range -999.99 to +999.99 with the "+" being optional.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Using
NCONVERT(fieldtext) causes a data expression error when the argument is not
numeric.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>I looked at matching
against every possible pattern the user could enter, but since the "-","+" and
"." are optional on input, and the range has be taken into account, the number
of combinations soon gets unmanageable. </FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>I could loop through
each character matching against characters 0 to 9 , . - + but then
coding to ensure that the plus, negative and period characters are in
appropriate positions and not repeated, also soon becomes
lengthy.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>There must be a more
elegant method eh?</FONT></SPAN></DIV>
<P><FONT face=Arial size=2>Regards,</FONT> <BR><FONT face=Arial size=2>Martyn
Thomson</FONT> <BR><FONT face=Arial size=2>Ministry of Education,<SPAN
class=593515719-18052004> </SPAN>Victoria, BC</FONT> <BR><FONT face=Arial
size=2> </FONT> </P>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>
------_=_NextPart_001_01C43D1E.DB3037A0--