"For developers", "Server scripts", "Functions description", "Strings", "Fetch".
"Cutting" a substring of a specified string from beginning to the first delimiter.
function Fetch(var sOriginal:string; sDelimiter: string): string;
Parameter |
Type |
Value |
---|---|---|
sOriginal |
string |
source string; |
sDelimiter |
string |
string delimiter. If there is no delimiter in the source string, then the whole string will be cut. |
Returns the cut string from the first position to the delimiter. The delimiter is not included to the result. Found part is cut from the beginning of the string. If the delimiter is an empty string or it does not exist in the source string, then the whole string will be cut.
const
sText = 'You get a shiver in the dark|' +
'It''s been raining in the park but meantime|' +
'South of the river you stop and you hold everything|' +
'A band is blowing Dixie double four time|' +
'You feel all right when you hear|' +
'That music ring';
var
s, sMsg: string;
i: integer;
begin
s := sText;
i := 0;
while length(s) > 0 do begin
sMsg := Fetch(s, '|');
inc(i);
mLogScript(sMsg, inttostr(i));
end;
end..
[19:19:50] (Log "Fetch"): [1] You get a shiver in the dark
[19:19:50] (Log "Fetch"): [2] It's been raining in the park but meantime
[19:19:50] (Log "Fetch"): [3] South of the river you stop and you hold everything
[19:19:50] (Log "Fetch"): [4] A band is blowing Dixie double four time
[19:19:50] (Log "Fetch"): [5] You feel all right when you hear
[19:19:50] (Log "Fetch"): [6] That music ring
[19:19:50] (Run "Fetch"): Script operation time: 6 ms
[19:19:50] (Run "Fetch"): Script done successfully.