Testing for numeric input
Thomson, Martyn EDUC:EX
Martyn.Thomson@gems1.gov.bc.ca
Tue, 18 May 2004 14:44:17 -0700
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_01C43D21.44BAFAFA
Content-Type: text/plain;
charset="iso-8859-1"
Thanks for the suggestions.
I should have mentioned that depending on the value entered in a previous
field, the user can enter a letter in the range A to H, or a numeric value!
That's why I wanted to be able to test if the value entered was numeric
after the event.
I see that I'm overloading this field and that's not really going to fly, so
now I'm experimenting with a temporary that occurs with the table,
positioned just before the numeric field and will control which field is
ACCEPTed from a silent field before the two. Then I'll have to manually
assign the temporary to the table field, control it's display on prescroll,
postscroll, etc.
-----Original Message-----
From: Pickering, John (NORBORD) [mailto:PICKERIJ@norbord.com]
Sent: May 18, 2004 2:27 PM
To: Thomson, Martyn EDUC:EX; POWERHOUSE NEW (E-mail)
Subject: RE: Testing for numeric input
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_01C43D21.44BAFAFA
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 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=765462321-18052004>Thanks
for the suggestions.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=765462321-18052004>I
should have mentioned that depending on the value entered in a previous field,
the user can enter a letter in the range A to H, or a numeric value! That's why
I wanted to be able to test if the value entered was numeric after the event.
</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=765462321-18052004>I see
that I'm overloading this field and that's not really going to fly, so now
I'm experimenting with a temporary that occurs with the table, positioned
just before the numeric field and will control which field is ACCEPTed from a
silent field before the two. </SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=765462321-18052004>Then I'll have to manually assign the
temporary to the table field, control it's display on prescroll,
postscroll, etc.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=765462321-18052004></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=765462321-18052004></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=765462321-18052004></SPAN></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Pickering, John (NORBORD)
[mailto:PICKERIJ@norbord.com]<BR><B>Sent:</B> May 18, 2004 2:27
PM<BR><B>To:</B> Thomson, Martyn EDUC:EX; POWERHOUSE NEW
(E-mail)<BR><B>Subject:</B> RE: Testing for numeric input<BR><BR></FONT></DIV>
<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></BLOCKQUOTE></BODY></HTML>
------_=_NextPart_001_01C43D21.44BAFAFA--