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

9.270 SubStr

Synopsis

 
function SubStr (S: String; FirstChar: Integer): String;
or
 
function SubStr (S: String; FirstChar, Count: Integer): String;

Description

`SubStr' returns a sub-string of S starting with the character at position FirstChar. If Count is given, such many characters will be copied into the sub-string. If Count is omitted, the sub-string will will range to the end of S.

If `Count' is too large for the sub-string to fit in S or if `FirstChar' exceeds the length of S, `SubStr' triggers a runtime error. (For a function returning the empty string instead, see section 9.53 Copy.)

Conforming to

`SubStr' is a ISO 10206 Extended Pascal extension.

Example

 
program SubStrDemo;
var
  S: String (42);
begin
  S := 'Hello';
  WriteLn (SubStr (S, 2, 3));   { yields `ell' }
  WriteLn (SubStr (S, 3));      { yields `llo' }
  WriteLn (SubStr (S, 4, 7));   { yields a runtime error }
  WriteLn (SubStr (S, 42));     { yields a runtime error }
end.

See also

section 9.53 Copy, section 8.5 Accessing parts of strings (and other arrays).



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