check if word starts with uppercase or lowercase

Hi,

I have a word: korado. But I want to check if it starts(so first character) with uppercase or lowercase.

I do it now like this:

RecSalesHeaderQuote.FncCheckBOM('orado');

koradoval1 := 'korado';
//koradoval2 := 'Korado';

IF koradoNewVal := (UPPERCASE(COPYSTR(koradoval1,1,1)) OR  koradoNewVal :=  LOWERCASE(COPYSTR(koradoval1,1,1))) THEN BEGIN
       RecSalesHeaderQuote.FncCheckBOM(koradoNewVal);

But this doesnt work. I get an error

IF koradoNewVal :=
will not work

:= means assignment of a value, you can’t use that in a comparison (the IF statement).

My suggestion: use .Net interop.

Go with Char.IsUpper(string) where string is the first character of the value you want to test.
Like: IF Char.IsUpper(koradoval[1]) THEN

And What is the subtype what I have to declare?

Create a variable, e.g. DotNetChar of subtype:
System.Char.‘mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’

(Assembly = mscorlib, Type = System.Char)

Then do:
IF DotNetChar.IsUpper(koradoval[0])

I can’t really tell from you description whether your goal is to determine whether the first character is an uppercase letter, or to determine whether the first character is anything other than a letter (either upper or lower case). In either case, you should be able to tweak this example to suit your needs.

In this example, the function will return true if the first character is A-Z or a-z, and false otherwise.

//65…90 = upper A-Z
//97…122 = lower a-z

case true of
((checkword[1] >= 65) and (checkword[1] <= 90)),
((checkword[1] >= 97) and (checkword[1] <= 122)):
exit(true);
end;

Thanks [mention:df63323c54514a31905af9a763346d59:e9ed411860ed4f2ba0265705b8793d05] - that’s the same I’ve been using before, just with a twist, to support Danish ÆØÅ characters.

[mention:5c9cb1234ea24fe88a9f3664f096d8bc:e9ed411860ed4f2ba0265705b8793d05] does the dotnet control support special characters like that?

Yes, the .Net type Char does support Unicode characters. It works with those specific Danish characters.
Tested it to be sure, and it nicely distinguished between Æ and æ

Nice. Gotta try the .net way next time I need this.

Just checked: msdn.microsoft.com/…/system.char_methods(v=vs.110).aspx
That control does have a few more “interesting” methods.
I see that I could also use it to change the first character to upper, using the ToUpper method.

Thank you. Very nice