fungsi split di delphi

function split(input: string; schar: Char; s: Integer): string;
var
  c: array of Integer;
  b, t: Integer;
begin
  Dec(s, 2);  // for compatibility with very old & slow split function
  t := 0;     // variable T needs to be initialized...
  setlength(c, Length(input));
  for b := 0 to pred(High(c)) do 
  begin
    c[b + 1] := posex(schar, input, succ(c[b]));
    // BREAK LOOP if posex looped (position before previous)
    // or wanted position reached..
    if (c[b + 1] < c[b]) or (s < t) then break 
    else 
      Inc(t);
  end;
  Result := Copy(input, succ(c[s]), pred(c[s + 1] - c[s]));
end;

penggunaan:
SPLIT(‘this is a test ‘,’ ‘,3) = ‘is’
SPLIT(‘data;another;yet;again;more;’,’;’,4) = ‘yet’

3 thoughts on “fungsi split di delphi

  1. buat semuanya metode apa saja yang bisa digunakan dalam split dengan menggunakan VB 6.0 dan konsep dasar dari metode non order split

  2. mas , kalo mau membedakan data input semisal 123INIDATANYA123 maka data akan masuk di field pertama

    berupa data INIDATANYA, kalo data input 456INIDATANYA456 maka data akan masuk di field kedua berupa

    data INIDATANYA gimana caranya ya mas?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s