[fpc-pascal] Strings greater than 255 characters

James Richters james.richters at productionautomation.net
Wed Dec 20 03:02:36 CET 2023


>3) There are some other smaller differences impacting compatibility with
code designed to work with type shortstring (e.g. related to used character
sets etc.).

Here's a difference I discovered... 

I see that if I try to do something like:
If MyString[1]='~' Then  ...

If MyString is an AnsiString that is empty then you get a rangecheck error,
which is understandable as there is nothing in character 1, but
If MyString is just a String and is empty then it runs just fine.... so I
have a lot of those kinds of things.
So some of these I just changed them back to a string for now, but
If I want to change them anyway then I just do 
If  (Length(MyString)>0) and (MyString[1]='~') Then  ...

And that fixes the issue as well, and it's probably better code as I
shouldn't be testing a particular character if there isn't a character
there.

James



More information about the fpc-pascal mailing list