String Evaluation to a Number?

Is this something that should yield a valid result?

IF CLIP(LOC:ExcludeNonMembers) >= '100' ...

I want to test for values that are 100 or above (obviously).

LOC:ExcludeNonMembers is a STRING. I know things would go much better if it were numeric, but for various reasons, a string is best.

the trouble is (I think) you want to do numeric comparisons but you are showing a string comparison.

it can be a bit confusing because Clarion often automatically converts strings to numbers for you.

but if you think about it, say LOC:ExcludeNonMembers had the value β€˜8’. That is going to be greater than a string β€˜100’ because it will compare the first digit and say β€œ8 is greater than 1” and doesn’t need to go any further.

BUT if you get rid of the quotes on β€˜100’ and do a numeric comparison

LOC:ExcludeNonMembers >= 100

you should be right to go.

BTW get rid of the useless clip()

you might want to decide what if LOC:ExcludeNonMembers has letters like β€˜abc’. In that case it would convert to a number zero as it is not numeric. There are tricks you can do like

if deformat(LOC:ExcludeNonMembers) >= 100

as deformat will strip out non-numeric chars.

you could also look at using Evaluate() instead - read the help and make sure you bind fields.

hth and cheers

Geoff R

If numeric(loc:excludeNonMembers) and loc:excludeNonMembers >= 100
  ! Do whatever.
1 Like

thank you - problem fixed thanks to your help!! This is how I ended up coding the IF:

IF LOC:ExcludeNonMembers >= 100