SRL Archive - Bugs

Unknown Identifier 'Explode'


YoHoJo

2010-02-13 16:17:40

THIS IS THE SIMBA FORUM
  sa := Explode(#10,  s);  

Does we need sum explodes?!

Frement

2010-02-13 16:21:57

srl_explode :)

E: I made one once:
program ExplodeFunction;

type ExplodeArray = array[1..65536] of String;

var arr: ExplodeArray;

function explode( delimeter, str: String ): ExplodeArray;
var i, l, a: Integer;
r: ExplodeArray;
s: Char;
p: String;
begin
l := Length( str );
a := 1;
p := '';
for i := 1 to l do
begin
s := StrGet( str, i );
if ( s = delimeter ) then
begin
r[a] := p;
p := '';
a := a + 1;
end else
begin
p := p + s;
end;
end;
r[a] := p;
Result := r;
end;

begin
arr := explode( '.', 'lol.asd.fail' );
Writeln( arr[3] );
end.

Could be improved.

E2: Did not notice this was in simba forum, sorry :( Thought my code still works :)

MylesMadness

2010-02-13 16:32:12

Explode is in scar 3.20+

senrath

2010-02-13 16:36:18

From: MylesMadness
Explode is in scar 3.20+


This is the Simba forum…

MylesMadness

2010-02-13 16:52:45

CRAP! First is was icefire doing this, nows its me…

mixster

2010-02-13 19:58:51

Or you can use srl_Explode which predates Scar's explode.

function Explode(str, del: string): TStringArray;
var
i, l, dL: Integer;
begin
i := 0;
l := -1;
SetLength(Result, 0);
if (str = '') then
Exit;
dL := Length(del) - 1;
repeat
Inc(l);
SetLength(Result, l + 1);
i := Pos(del, str);
if i <= 0 then
Break;
Result[l] := Copy(str, 1, i - 1);
Delete(str, 1, i + dL);
until false
Result[l] := Copy(str, 1, Length(str));
end;

Or export FPC's explode to PS :)

mastaraymond

2010-02-14 05:44:15

Does FPC export one? Than that should be used indeed ^_^..

If you include SRL it will wrap around some missing SCAR functions..