Page 1 of 1

Validation

Posted: Wed Jun 08, 2005 8:30 am
by pandu80
Hi,

Iam using the following code Numeric validation.

If Oconv(Trim(InputLink.Col),"MCN") = Trim(InputLink.Col) Or Index(InputLink.Col,'E',1) >=1 Or Index(InputLink.Col,'e',1) >=1 Or InputLink.Col <>'' Then InputLink.Col Else 'Error'

Is the right approach?.

TIA

Posted: Wed Jun 08, 2005 8:52 am
by ArndW
pandu80,

I think your approach is lacking a bit. For instance, the string 'Hello World' would be considered a number, as would any non-empty string (for different reasons).

I don't have a ds system to check right now, but I would use the NUM(<value>) function to start with. If you want a detailed check it is better to do this in a function, that way you can check the STATUS() return code when using ICONV or OCONV to check for different possibilities.

Perhaps you could state exactly what you want to check - with numbers you have integers, real number, floating point and exponential representations - do you want to cater to all of these at the same time?

Posted: Wed Jun 08, 2005 9:59 am
by Sainath.Srinivasan
You can do a
if num(yourvalue) then 'number' else 'not number'