Janilabo Posted October 21, 2012 Share Posted October 21, 2012 Rewrote my ancient Explode() function (just for fun). Functions [A & B] below, with small example/test: function StrExplodeA(d, str: string): TStrArray; var p, i, l: Integer; begin l := Length(d); SetLength(Result, Length(str)); repeat p := Pos(d, str); if (p > 0) then begin Result[i] := Copy(str, 1, (p - 1)); Delete(str, 1, ((p + l) - 1)); Inc(i); end else Result[i] := Copy(str, 1, Length(str)); until (p = 0); SetLength(Result, (i + 1)); end; function StrExplodeB(d, str: string): TStrArray; var o, p, i, l, x: Integer; begin l := Length(d); x := Length(str) SetLength(Result, x); o := 1; repeat p := PosEx(d, str, o); if (p > 0) then Result[i] := Copy(str, o, (p - o)) else Result[i] := Copy(str, o, ((x - o) + 1)); o := (p + l); Inc(i); until (p = 0); SetLength(Result, i); end; var str: string; f: Integer; TSA: TStrArray; begin ClearDebug; f := OpenFile(Replace(AppPath, 'bin\', '') + 'changelog.txt', False); ReadFileString(f, str, FileSize(f)); CloseFile(f); f := GetSystemTime; TSA := StrExplodeA(#13#10, str); WriteLn('StrExplodeA: ' + IntToStr(GetSystemTime - f) + ' ms. [' + IntToStr(High(TSA)) + ']'); SetLength(TSA, 0); f := GetSystemTime; TSA := StrExplodeB(#13#10, str); WriteLn('StrExplodeB: ' + IntToStr(GetSystemTime - f) + ' ms. [' + IntToStr(High(TSA)) + ']'); SetLength(TSA, 0); f := GetSystemTime; TSA := Explode(#13#10, str); WriteLn('Explode: ' + IntToStr(GetSystemTime - f) + ' ms. [' + IntToStr(High(TSA)) + ']'); SetLength(TSA, 0); end. Quote Link to comment Share on other sites More sharing options...
BryceTheCoder Posted October 21, 2012 Share Posted October 21, 2012 Nice job. How did u get VIP anyways haha? do u buy it? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 21, 2012 Share Posted October 21, 2012 Nice job. How did u get VIP anyways haha? do u buy it? Donations might push Freddy to give you VIP. But Janilabo is more than just that. He's been around for a long time on the different scar forums. He probably joined around 2006 or so? W/e. Looks cool Jani. Wish I could figure out half your functions. One day I will sit down and try to figure some more out Also...I think without Jani SCAR wouldn't be how it is today. He donated big time and in more ways than just money too... Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 21, 2012 Author Share Posted October 21, 2012 Donations might push Freddy to give you VIP. But Janilabo is more than just that. He's been around for a long time on the different scar forums. He probably joined around 2006 or so? W/e. Looks cool Jani. Wish I could figure out half your functions. One day I will sit down and try to figure some more out Also...I think without Jani SCAR wouldn't be how it is today. He donated big time and in more ways than just money too... Heh thanks for cheering me mate.. You made my day! But yeah, I have been around these SCAR-related communities since summer 2004 (thats when Reines invited me to join ReiNet & RSCheatNet), I also lurked at Kaitnieks without registering for almost half year, before I finally registered there December 2004. I used "LaBo" as my nick for all those 3 ancient communities, but I wasn't ever all that active, I think at Kaitnieks.com my post count was around 100-150 (or something like that).. Just like I am not even these days so active (good example is my post count here, without all these functions etc in Code Bin), but thats who I am, it's my personality really.. I am a pretty quiet guy in real life too. Communities that are still alive and where I am registered to: Freddy1990.com, Moparisthebest & SRL-Forums. Also LJ; you are already catching me up everyday - bit by bit! Soon you'll be kicking my butt! +You have to remember, we all have our strong/weak fields.. I think my strong field would be these string handling things, no idea why.. Where as my weak part can be found from creating bigger scripts/projects, for some reason I usually lose my motivation with em (MSSL could be an exception, I have sticked with it for good amount of time by now). -Jani Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 21, 2012 Share Posted October 21, 2012 Heh am i that inspirational? Jk. If you think you fail at big projects, you're building the house and all the parts fit together and effect each other. MSSL is a such a small project Jani, no wonder you have no post count . Nah I can't even go through one part of MSSL without going over to the mssl forums and spazzing about what does what. MSSL is titanic in size, it just needs to miss the no explanation glacier so I can dive into it more. ahaha some word play [scar]but thats who I am, it's my personality really.. I am a pretty quiet guy in real life too. [/scar] scar noms on that statement... Woot Jani! Cheers for 8 years+ of your commitment to this! Quote Link to comment Share on other sites More sharing options...