[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10 Strings in BP and GPC

Strings are "Schema types" in GNU Pascal which is something more advanced than Borland-style strings. For variables, you cannot specify just String as a type like in Borland Pascal; for parameters and pointer types you can. There is no 255 characters length limit. According to Extended Pascal, the maximum string length must be in (parentheses); GNU Pascal accepts [brackets], too, however, like BP.

For more about strings and schema types see section 8.2.10.6 EP's Schema Types including `String'.

GPC supports Borland Pascal's string handling functions and some more (see section 8.10.2 String Operations):

Borland Pascal GNU Pascal
Length Length
Pos Pos, Index (1)
Str Str, WriteStr (1) (2)
Val Val, ReadStr (2)
Copy Copy, SubStr, MyStr[2 .. 7] (3)
Insert Insert
Delete Delete
MyStr[0] := #7 SetLength (MyStr, 7)
=, <>, <, <=, >, >= =, <>, <, <=, >, >= (4)
EQ, NE, LT, LE, GT, GE
n/a Trim

Notes:

(1) The order of parameters of the Extended Pascal routines (`Index', `WriteStr') is different from the Borland Pascal routines.

(2) `ReadStr' and `WriteStr' allow an arbitrary number of arguments, and the arguments are not limited to numbers. `WriteStr' also allows comfortable formatting like `WriteLn' does, e.g. `WriteStr (Dest, Foo : 20, Bar, 1/3 : 10 : 2)'.

(3) `SubStr' reports a runtime error if the requested substring does not fit in the given string, `Copy' does not (like in BP).

(4) By default, the string operators behave like in BP. However, if you use the option `--no-exact-compare-strings' or `--extended-pascal', they ignore differences of trailing blanks, so, e.g., `'foo'' and `'foo '' are considered equal. The corresponding functions (`EQ', ...) always do exact comparisons.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html