Unwilling assign does not respond well to ToLower statement

Hi can anyone tell me why this does not give the desired result?

I have a local variable called Duur (duration) and a DBfield called Produkt (text)

Product contains for example "Zakelijk 3 Jaar contract" or "Consument 2 jaar contract"

I check for the number of years, but sometimes there is a capital in Jaar and somtimes there isn't.

So i came up with the followinr assign:

SyntaxEditor Code Snippet

If (Index(ToLower(GetProdukt.List.Current.Produkt.Produkt),"5 jaar")>-1,5,
If (Index(ToLower(GetProdukt.List.Current.Produkt.Produkt),"3 jaar")>-1,3,
If (Index(ToLower(GetProdukt.List.Current.Produkt.Produkt),"1 jaar")>-1,1,0)))

It does find the lower case "3 jaar" but not the "3 Jaar".

Something wrong here?

I know I could first fill another local variable with the text and ToLower that and then do the test, but i wonder why this one does not work.

Any help would be appreciated.


Never mind, it already works... might have been a version issue...


Hi Willem,

First of all I like to congratulate you on the brilliant title of your post, it made me chuckle :).

Secondly, the code should work fine. I did a small test just to be sure, and "3 Jaar" gives me 3 as a result. What I expect is that the descriptions contain more than one space between "3" and "Jaar", or perhaps a non-regular space like a non-breaking space, etc. If that's the case you're probably be better of using a regular expression (Regex_Search from the Text Extension).

Thirdly, my personal opionion is that it's cleaner to do what you already said, first apply the ToLower, since you know do it three times, while every time you apply it to the same Text. That'll save you two superfluous ToLower converts, but also makes the if-chain clearer to read.

EDIT: You ninja'd me :). But my third point still stands :).