Script Name: IXSplit
Script Description Improved version of XSplit
Author: Dual (http://soldatcentral.com/index.php?page=profile&u=57)
Hosted by: Soldat Central - http://soldatcentral.com/ (http://soldatcentral.com/)
Core Version: 2.6.3
Compile Test: (http://soldatcentral.com/images/pass.gif) Passed
IXSplit() splits a string into an array of strings. SOURCE determines a string to be splitted by the Delimiter.
To put it in a nutshell, it's an improved version of the common used XSplit (http://forums.soldat.pl/index.php?topic=12742.msg142224#msg142224).
function IXSplit(const SOURCE: string; Delimiter: string): array of string;
var
i, x, d: integer;
s, b: string;
begin
d:= length(Delimiter);
i:= 1;
SetArrayLength(Result, 0);
while (i <= length(SOURCE)) do
begin
s:= Copy(SOURCE, i, d);
if (s = Delimiter) then
begin
SetArrayLength(Result, x + 1);
Result[x]:= b;
Inc(i, d);
Inc(x, 1);
b:= '';
end else
begin
b:= b + Copy(s, 1, 1);
Inc(i, 1);
end;
end;
if (b <> '') then
begin
SetArrayLength(Result, x + 1);
Result[x]:= b;
end;
end;
Parameters:
SOURCE: string
String to be splitted into an array of string.
Delimiter: string
Defines a string as split point.
Return Value:
Depending on the amount of delimiters the SOURCE string contains, the elements count of the string array will increase.
Note:
IXSplit() will not return any array element if SOURCE is blank.
In case the delimiter is not found in the string, IXSplit() will return one array element containing the whole SOURCE string.
If you intent to split a string which is read from a file I recommend to use this function:
function ReadFromFile(File_Name: string): string;
begin
Result:= ReadFile(File_Name);
Result:= Copy(Result, 0, length(Result) - 2);
end;
You find more information about this problem here (http://forums.soldat.pl/index.php?topic=32817).
(http://soldatcentral.com/images/download.gif) (http://soldatcentral.com/dl.php?id=100&act=1)
(Size 629 B)
- http://soldatcentral.com/index.php?page=script&f=100 -
** Script hosted by Soldat Central (http://soldatcentral.com/index.php?page=script&f=100)! Please visit the author's script page (http://soldatcentral.com/index.php?page=script&f=100) and Rate this script **