Echo_
2011-07-23 08:14:02
So somebody asked me about a substring function. I didn't find one, so I made one myself.
But when I execute this script:
This is the result:
What am I doing wrong?
function Substring(str: string; start, finish: Integer): string;
var
char1, char2: Char;
begin
char1 := StrGet(str, start);
char2 := StrGet(str, finish);
Result := Between(char1, char2, str);
end;But when I execute this script:
program new;
const
RANDOM_STRING = 'This is a random string.';
function Substring(str: string; start, finish: Integer): string;
var
char1, char2: Char;
begin
char1 := StrGet(str, start);
char2 := StrGet(str, finish);
Result := Between(char1, char2, str);
end;
begin
Writeln(Substring(RANDOM_STRING, 1, 10));
end.This is the result:
hisWhat am I doing wrong?