Question
· Oct 24

I want to test if two fields are numeric and positive, do subtraction, and test if the result is positive.

If both fields are numeric and the result of subtraction of field1-field2 is positive, only then put the result is a data field.

I am doing this within an Iris DTL.

I don't find any functions like IsNumeric(). Once I get that, I can test if field1>0 and field2>0, do the subtraction, and test if diff>0.

I just need a function to determine if they are numeric, rather than some cumbersome way like a regex where the only characters are 0-9.

I see functions in documentation but don't see them used at tests, only in WRITE statements.

Thanks,

Jonathan

Product version: IRIS 2023.3
Discussion (10)2
Log in or sign up to continue

True, but the problem definition is:

If both fields are numeric and the result of subtraction of field1-field2 is positive.

My understanding/interpretation is that the subtraction and further test should be performed only "If both fields are numeric", so the code should check that condition.

If the first part of the problem (If both fields are numeric) is irrelevant....then the question/problem definition is misleading.

Hi Enrico, my sample code does that exactly. It takes number1 and converts it to a number than it compares the result to the original number1 field. 
Quirk of type conversion in ObjectScript if a value is converted from string to number ObjectScript walks the values from left to right and stops at the first non numeric character ie.
123ABC   becomes 123

The if clause checks then if 123 = 123ABC so the org value is non numeric.

Using && in the IF clause means do a logical AND check but short circuit the check ie. if condition 1 is already false go directly to the else clause and do not check cond2 and3