Contents | Prev | Next | Index


String Types

Canterbury Pascal supports a string type. Its declaration always starts with the reserved word STRING. It may be followed by an integer constant enclosed in squared brackets for specifying a maximum number of characters. If omitted the default value for the maximum string length is HIGH(LONGINT), that is 2147483647 characters. 16-bits UNICODE characters are being used for strings. The memory for string variables is always automatically allocated and can grow dynamically, as needed for holding string values. This compiler always maps string types to the Java type java.lang.StringBuffer. If the string type has an explicitly specified upper length specified in its definition, then possible truncations can take place for assignments and for value parameters during runtime.

 
string_type ::= STRING [ const_expr ]
::= STRING

 

The character elements of a string type are of type CHAR and are indexed from 1 to the length of the string. The standard function Length(S) returns the current length of the string. Unlike other Pascal compilers, e.g. Borland Object Pascal, no element is defined at index 0, hence it is not possible to get the current string length from an expression like ORD(S[0]). Also, unlike Borland Object Pascal, there are no different flavors of string types such as ShortString or WideString. Standard function HIGH(S) always returns the defined maximum index. Pascal supports the concatenation operator for STRING expressions. Canterbury Pascal also permits assignments to and from expressions or variables of the Java type java.lang.String.


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com