0

I tried to look at some steps about making the word automatically become uppercase letters in the first letter. I used to use it on VCL and it works very well, but why on mobile applications it doesn't work properly. I use this code, but in edit2, the result is that I lost the first letter and the words start with the second letter that I entered in edit1, even though it starts with uppercase. Maybe someone can help me. Thank you very much

    var i, j : integer;
        s, edt2 : string;
Procedure
         j := length(edt1.Text);
            s := '';
            for i := 2 to j do
            begin
              s := s + LowerCase(edt2.Text[i]);
            end;
            edt2 := UpperCase(edtProduk.Text[1]) + s;
Alfred
  • 103
  • 9
  • 1
    Very inefficient to create new strings character by character. Modify the text in place. Also, do expect that your code will fail with international text. – David Heffernan Sep 16 '18 at 08:10

1 Answers1

3

In Delphi mobile platforms you have to understand that strings are zero-based (just like arrays).

To avoid issues, if you want to access the first index and last index of a string in a cross platform safe way, use the System.Low and System.High intrinsics on the string.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Xor-el
  • 84
  • 1
  • 1
  • 3