[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
function SubStr (S: String; FirstChar: Integer): String; |
function SubStr (S: String; FirstChar, Count: Integer): String; |
`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.)
`SubStr' is a ISO 10206 Extended Pascal extension.
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. |
section 9.53 Copy, section 8.5 Accessing parts of strings (and other arrays).