File parseing

Please discuss general Delphi programming topics here.

File parseing

Postby werdnareid » January 23rd, 2005, 5:46 pm

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 .
werdnareid
Active Member
Active Member
 
Posts: 22
Joined: August 6th, 2003, 5:35 pm

Postby Stefan » January 24th, 2005, 12:51 pm

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;
User avatar
Stefan
Moderator
Moderator
 
Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

Postby werdnareid » January 24th, 2005, 5:22 pm

Thanks Stefan , i think that will work .. and thanks for the link...it has some greate tips..
werdnareid
Active Member
Active Member
 
Posts: 22
Joined: August 6th, 2003, 5:35 pm


Return to Delphi Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron