String Compare in C/Al

Hi @ALL, I have a new problem and maybe somebody out there is able to help me ?? I would like to programm a string-compare, which doesn’t care on upper or lower case writing, e.g. compare a Text and a Code Field. First at all I tried to find a function in the C/AL refernce like STRCompare, but without any result. How can I realize that?? Thank You very much for your help ;-))

Hello, as CODE is always UPPERCASE, write your own short function. If you want to compare Text and Text, use Uppercase on both variables. Regards Walter

IF STRPOS(UPPERCASE(string_to_search_in),UPPERCASE(string_to_search_for)) <> 0 THEN…

If you are looking to compare a Code to Text, you will probably need to convert the Code to a Text string using the FORMAT command.

or using the KISS approachStrMatchesCode = UPPERCASE(MyTextStr) = MyCodeStr;[;)]<-- Hey Heinz here it is[8D]

tip: Search this form on the keyword: “SOUNDEX”. I think you’ll not need it, but still it very nice to know this info!

quote:


Originally posted by David Singleton
or using the KISS approachStrMatchesCode = UPPERCASE(MyTextStr) = MyCodeStr;


David, you forgot a : [;)]

Emiel, What is SOUNDEX and where do I search for it?

Sorry David, your code is still buggy [:D] To be precise, you fixed a bug which I didn’t notice [:p] Your code was and still is missing a colon (’:’), not a semicolon (’;’). I should have used the names instead of the symbols. The assignment of the boolean value to the variable requires a ‘:=’, not a ‘=’, unless you are programming in C, where the comparison would have required a ‘==’ instead of a ‘=’ [:D][:D]

In short : SOUNDEX is a way to compare strings that sound a like. With SOUNDEX this will match: ANDERSON, ANDERSEN BERGMANS, BRIGHAM BIRK, BERQUE, BIRCK FISHER, FISCHER LAVOIE, LEVOY see: http://www.navision.net/forum/topic.asp?TOPIC_ID=2527&SearchTerms=soundex

quote:


Originally posted by xorph Your code was and still is missing a colon (‘:’), …


Do you seriously think I debug and compile a line in a posting? [?] I just type and what comes out comes out. This was in any case not a bug in the code. This is in fact a compiler error.

quote:


Originally posted by David Singleton
I just type and what comes out comes out.


LOL I think I will use this answer the next time someone of our users complains about a bug [:D][:D][:D] PS: Seriously, I know a missing : is far too trivial to merit discussion, let alone getting into an argument over it, David. Of course I know that you know the correct syntax. I was merely pointing this out because someone else might not and just copy the code literally, then get confused about the error message. Peace? [8D]

It was meant in fun. I just hate using the silly icons.