Page 1 of 1

File parseing

PostPosted: January 23rd, 2005, 5:46 pm
by werdnareid
Hi...all

I used the tool name sclist to generate a list of the serviecs on my system. the format of the file looks like this: :

--------------------------------------------
- Service list for Local Machine
--------------------------------------------
stopped Alerter Alerter
stopped Apache Apache
stopped Apache2 Apache2
stopped AppMgmt Application Management

the thing is i need to get each column into three seperate lists
i have tried to use readln ..but i think the way the sclist program made the list prevents me from reading in trree variables ....it gives me one line as one .

PostPosted: January 24th, 2005, 12:51 pm
by Stefan
Hi,

Two things:

1. Why use a tool, when you can do it yourself: http://www.chami.com/tips/delphi/040698D.html

2. Use something like this:

Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
  i,a: integer;
  strings: array [0..2] of String;
begin
  s := 'stopped AppMgmt Application Management';
  a := 0;
  for i := 1 to Length(s) do begin
    if (s[i] = ' ') and (a < 2) then begin
      inc(a);
      Continue;
    end;
    strings[a] := strings[a] + s[i];
  end;
  ListBox1.Items.Add(strings[0]);
  ListBox2.Items.Add(strings[1]);
  ListBox3.Items.Add(strings[2]);
end;

PostPosted: January 24th, 2005, 5:22 pm
by werdnareid
Thanks Stefan , i think that will work .. and thanks for the link...it has some greate tips..