Morgan
13 years agoFrequent Contributor
Delphi Split function
I am trying to convert some vbscript to delphi and am having trouble with the Split function (error says Unknown name : Split) //The windows are all named the same. Find the one I want. ...
- 13 years agoHi Morgan,
I'm afraid that you'll need a custom Split() function. Something like this (of top of my head, untested, based on 'DelphiScript - Working With Strings' help topic):
function DelphiSplit(strString : string; strSeparator : string = ',');
var prevSep;
var iLen, i;
var arr
begin
// Assign list separator to space character
prevSep := aqString.ListSeparator;
try
aqString.ListSeparator := strSeparator;
iLen = aqString.GetListLength(strString);
arr = CreateVariantArray(0, iLen - 1);
for i := 0 to iLen - 1 do
arr := aqString.GetListItem(strString, i));
result := arr;
finally
// Restore previous separator
aqString.ListSeparator := prevSep;
end;
end;