Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-04

Run-time generated combo-boxes.

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

A.J. Venter

Hi,
For my administration interface, I have two sections (password changing and user deletion) where the user can select a username from a combobox. I wrote a procedure called fillUserList, which when run will read /etc/passwd, drop system users (below UID 500) and place the rest into a the combobox, then this list needs to become the contents of the combobox. It has to be redone whenever the user goes to the relevant section, because the list can and will change during operation, e.g. a user may be deleted and another's password have to be changed.

Everything works like that, but the catch is when to run it. Right now I have it linked to the comboBox's onDropDown event, but this is not working. The first time you open the list, only the first user appears, only if you close and reopen it, does the full list show up.

How do I do this ?

The code looks like this:

procedure TForm4.FillUserList;
    Var AllUsers : Tstrings;
          Users : Tstrings;
          S : String;
          CNT : Integer;
begin
{ComboPop is a boolean, used to keep track of whether the comboBox has
allready been populated on this run, it is reset to false when the form
closes}
If not ComBoPop then
Begin
AllUsers := tStringlist.Create;
Users := tstringList.Create;
AllUsers.LoadFromFile ('/etc/passwd');
For CNT := 0 to AllUsers.Count -1
Do
  Begin
  S :=  Allusers[cnt];
  Delete(S,1,pos(':',S));
  Delete(S,1,pos(':',S));
  S := Copy(S,1,pos(':',S) - 1);
  If (StrToInt(S) >= 500) AND
(Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1)  'admin') then
   Users.Add(Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1));
  end;
Form4.ComboBox1.Items.Assign(Users);
AllUsers.Free;
Users.Free;
end;
end;
Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email

Mattias Gaertner
to A.J. Venter
Show quoted text 14 lines
Hi, For my administration interface, I have two sections (password changing and user deletion) where the user can select a username from a combobox. I wrote a procedure called fillUserList, which when run will read /etc/passwd, drop system users (below UID 500) and place the rest into a the combobox, then this list needs to become the contents of the combobox. It has to be redone whenever the user goes to the relevant section, because the list can and will change during operation, e.g. a user may be deleted and another's password have to be changed. Everything works like that, but the catch is when to run it. Right now I have it linked to the comboBox's onDropDown event, but this is not working. The first time you open the list, only the first user appears, only if you close and reopen it, does the full list show up.

Fixed.

Mattias

Show quoted text 48 lines
How do I do this ? The code looks like this: procedure TForm4.FillUserList; Var AllUsers : Tstrings; Users : Tstrings; S : String; CNT : Integer; begin {ComboPop is a boolean, used to keep track of whether the comboBox has allready been populated on this run, it is reset to false when the form closes} If not ComBoPop then Begin AllUsers := tStringlist.Create; Users := tstringList.Create; AllUsers.LoadFromFile ('/etc/passwd'); For CNT := 0 to AllUsers.Count -1 Do Begin S := Allusers[cnt]; Delete(S,1,pos(':',S)); Delete(S,1,pos(':',S)); S := Copy(S,1,pos(':',S) - 1); If (StrToInt(S) >= 500) AND (Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1) 'admin') then Users.Add(Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1)); end; Form4.ComboBox1.Items.Assign(Users); AllUsers.Free; Users.Free; end; end; -- Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

A.J. Venter
to A.J. Venter: For my administration interface, I have two sections (password changing and user…

Thanks Mattias,
I take it then that there was a bug in lazarus causing it. I�ll grab the latest CVS version, and give it a try.

A.J.

Mattias Gaertner wrote 78 lines
On 11 Apr 2003 09:39:48 +0200 "A.J. Venter" wrote: > Hi, > For my administration interface, I have two sections (password changing > and user deletion) where the user can select a username from a combobox. > I wrote a procedure called fillUserList, which when run will read > /etc/passwd, drop system users (below UID 500) and place the rest into a > the combobox, then this list needs to become the contents of the > combobox. It has to be redone whenever the user goes to the relevant > section, because the list can and will change during operation, e.g. a > user may be deleted and another's password have to be changed. > > Everything works like that, but the catch is when to run it. Right now I > have it linked to the comboBox's onDropDown event, but this is not > working. The first time you open the list, only the first user appears, > only if you close and reopen it, does the full list show up. Fixed. Mattias > How do I do this ? > > The code looks like this: > > procedure TForm4.FillUserList; > Var AllUsers : Tstrings; > Users : Tstrings; > S : String; > CNT : Integer; > begin > > {ComboPop is a boolean, used to keep track of whether the comboBox has > allready been populated on this run, it is reset to false when the form > closes} > If not ComBoPop then > Begin > AllUsers := tStringlist.Create; > Users := tstringList.Create; > AllUsers.LoadFromFile ('/etc/passwd'); > For CNT := 0 to AllUsers.Count -1 > Do > Begin > S := Allusers[cnt]; > Delete(S,1,pos(':',S)); > Delete(S,1,pos(':',S)); > S := Copy(S,1,pos(':',S) - 1); > If (StrToInt(S) >= 500) AND > (Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1) 'admin') then > Users.Add(Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1)); > > end; > > Form4.ComboBox1.Items.Assign(Users); > AllUsers.Free; > Users.Free; > end; > > end; > > -- > Story of my life: "Semper in excretum, set alta variant" > A.J. Venter > DireqLearn Linux Guru > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email

A.J. Venter
to A.J. Venter: For my administration interface, I have two sections (password changing and user…

It works beautifully now.
Thanks everybody.

A.J. Venter wrote 84 lines
Thanks Mattias, I take it then that there was a bug in lazarus causing it. I�ll grab the latest CVS version, and give it a try. A.J. On Fri, 2003-04-11 at 11:04, Mattias Gaertner wrote: > On 11 Apr 2003 09:39:48 +0200 > "A.J. Venter" wrote: > > > Hi, > > For my administration interface, I have two sections (password changing > > and user deletion) where the user can select a username from a combobox. > > I wrote a procedure called fillUserList, which when run will read > > /etc/passwd, drop system users (below UID 500) and place the rest into a > > the combobox, then this list needs to become the contents of the > > combobox. It has to be redone whenever the user goes to the relevant > > section, because the list can and will change during operation, e.g. a > > user may be deleted and another's password have to be changed. > > > > Everything works like that, but the catch is when to run it. Right now I > > have it linked to the comboBox's onDropDown event, but this is not > > working. The first time you open the list, only the first user appears, > > only if you close and reopen it, does the full list show up. > > Fixed. > > > Mattias > > > > > How do I do this ? > > > > The code looks like this: > > > > procedure TForm4.FillUserList; > > Var AllUsers : Tstrings; > > Users : Tstrings; > > S : String; > > CNT : Integer; > > begin > > > > {ComboPop is a boolean, used to keep track of whether the comboBox has > > allready been populated on this run, it is reset to false when the form > > closes} > > If not ComBoPop then > > Begin > > AllUsers := tStringlist.Create; > > Users := tstringList.Create; > > AllUsers.LoadFromFile ('/etc/passwd'); > > For CNT := 0 to AllUsers.Count -1 > > Do > > Begin > > S := Allusers[cnt]; > > Delete(S,1,pos(':',S)); > > Delete(S,1,pos(':',S)); > > S := Copy(S,1,pos(':',S) - 1); > > If (StrToInt(S) >= 500) AND > > (Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1) 'admin') then > > Users.Add(Copy(AllUsers[cnt],1,pos(':',AllUsers[cnt]) -1)); > > > > end; > > > > Form4.ComboBox1.Items.Assign(Users); > > AllUsers.Free; > > Users.Free; > > end; > > > > end; > > > > -- > > Story of my life: "Semper in excretum, set alta variant" > > A.J. Venter > > DireqLearn Linux Guru > > > > _________________________________________________________________ > > To unsubscribe: mail with > > "unsubscribe" as the Subject > > archives at http://www.lazarus.freepascal.org/mailarchives > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives
Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email