0 Members and 2 Guests are viewing this topic.
function xsplit(const source: string; const delimiter: string):TStringArray;var i,x,d:integer; s:string;begin d:=length(delimiter); x:=0; i:=1; SetArrayLength(Result,1); while(i<=length(source)) do begin s:=Copy(source,i,d); if(s=delimiter) then begin inc(i,d); inc(x,1); SetArrayLength(result,x+1); end else begin result[x]:= result[x]+Copy(s,1,1); inc(i,1); end; end;end;
[19:52:22] <DorkeyDear> Hello.[19:52:53] <DorkeyDear> I have a question... I downloaded the 2.6.1 dedicated server pre-release, and was wondering whats up with the Split function.[20:04:54] <EnEsCe> split is being removed[20:05:01] <EnEsCe> problems with TStringArray[20:05:07] <EnEsCe> can still use xsplit and getpiece
People are gonna have to use xsplit, I can not include Split as built-in now because the TStringArray variable causes access violations when being used between soldatserver<->script.
File := XSplit(ReadFile('CashSpot.txt'),chr(13) + chr(10));for i := 0 to ArrayHigh(File) do WriteConsole(ID,InttoStr(i) + '/' + InttoStr(ArrayHigh(File)) + ': ' + File,$FF33FFAA);
{SS} Curtle the TurtleÆ400,100{SS} Curtle the TurtleÆ400,101{SS} Curtle the TurtleÆ400,102{SS} Curtle the TurtleÆ400,103{SS} Curtle the TurtleÆ1,2
GetArrayLength(File) - 1
I swear! This doesn't work!!!QuoteFile := XSplit(ReadFile('CashSpot.txt'),chr(13) + chr(10));for i := 0 to ArrayHigh(File) do WriteConsole(ID,InttoStr(i) + '/' + InttoStr(ArrayHigh(File)) + ': ' + File,$FF33FFAA);where as the file is:Quote{SS} Curtle the TurtleÆ400,100{SS} Curtle the TurtleÆ400,101{SS} Curtle the TurtleÆ400,102{SS} Curtle the TurtleÆ400,103{SS} Curtle the TurtleÆ1,2and File[0] is the only outcome and it contains the whole file... and yes, it is on a windows server...
ArrayHigh(File)
Did you declare File as TStringArray?
OK... I found an interesting bug:If I put the xsplit inside a "for" statement and call the function really fast, the resulting variable from the xsplit function is not cleared of items (might be really specific for TStringArray), thus the first item of the resulting list would begin with the string gotten from the previous call of xsplit. Thus, there needs to be a line "SetArrayLength(Result,0);" right before "SetArrayLength(Result,1);".
can you show us the code snippet you did this with?