Autor Beitrag
Ironhead
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP,Kanotix 5

BeitragVerfasst: Do 13.07.06 14:52 
Hallo Leute, brauch mal wieder Hilfe von Euch.

habe mir eine kleine Benutzerabfrage mit ner ini Datei gemacht,

Der Benutzer gibt in einem Edit seinen Benutzernamen ein und auf den klick aufn
Butten wird der Name mit den einträgen in der ini verglichen.

Das klappt ja alles sehr gut, nur muss es doch ne Möglichkeit geben das kompakter
und besser zu schreiben als ich das getan hab, sonst wird das ja mit der Zeit zu lang.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if  (Form1.Edit1.Text = ini.ReadString('user', 'name',''))or
    (Form1.Edit1.Text = ini.ReadString('user2', 'name',''))or
    (Form1.Edit1.Text = ini.ReadString('user3', 'name',''))or
    (Form1.Edit1.Text = ini.ReadString('user4', 'name',''))or
    (Form1.Edit1.Text = ini.ReadString('user5', 'name',''))or


ich möchte das gerne bis zu 200 einträgen machen, nur wird das ja zu lang,
kann mir einer von Euch mal sagen wie ich das besser und kürzer hinbekomme.

Vielen Dank
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 15:00 
Vorher musst du aus der INI noch die Anzahl der Einträge auslesen (in die Variable count)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var i,count:integer;
   
for i := 1 to count do
begin
  if (Form1.Edit1.Text=ini.readstring('user'+inttostr(i)),'name','') then ...
end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 13.07.06 15:03 
Es gibt auch etwas wie ReadSection. Schau mal in der OH nach.
Ironhead Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP,Kanotix 5

BeitragVerfasst: Do 13.07.06 15:21 
Ja toll, das war sehr gut, dank dir Marco D., hat mir sehr weitergeholfen