Documentation
Back to website >

String (Pascalscript)

EULANDA® uses for ANSI strings, which can be up to 2 gigabytes long.

The reserved word string works like a generic type identifier. For example, the following line declares a variable called S in which a string is stored:

var S: string;

The default function Length returns the number of characters in a string. The comparison of strings is defined by the value of the characters at the corresponding positions of the ASCII table. When comparing strings of different lengths, any character in the longer string that does not correspond to any character in the shorter string is considered"greater". For example,'AB' is larger than 'A'. This means that 'AB' >'A' has the value True. Strings with length zero contain the lowest values.

You can index a string variable like an array. If S is a string variable and i is an integer expression, S[i] represents the ith character - or strictly speaking the ith byte in S. The MyString[2] := 'A' instruction assigns the value A to the second character of MyString. In the following source code, MyString is converted to uppercase using the standard UpCase function:

var
  I: Integer;
  MyString : String;

begin
  I := Length(MyString);
  while I > 0 do
    begin
      MyString[I] := UpCase(MyString[I]);
      I := I - 1;
    end;
end;

If you index strings in this way, you must ensure that you do not write beyond the end of the string, since this would lead to an index error. You should also not pass indexes for strings as var parameters, as this results in inefficient code.
You can assign the value of a string constant or another expression that returns a string to a string variable. The length of the string changes dynamically during assignment. Here are a few examples:

MyString  ='Hello World';

MyString  ='Hello ' +'World';
MyString  = MyString + '!';
MyString  = ' '; { Space }
MyString  = ''; { Empty string }