uses IniFiles, math;
function RightsToString(RightsList: TStrings;
Columns:
array of integer):
string;
var
Rights: TStringlist;
i: integer;
begin
Result := '
';
Rights := TStringlist.Create;
try
for i := Low(Columns)
to High(Columns)
do
if RightsList[Columns[i]] <> '
'
then
Rights.Add(RightsList[Columns[i]]);
Result := Rights.CommaText;
finally
Rights.Free;
end;
end;
procedure SaveUserToIni(AIni: TIniFile; DataList: TStrings;
NameIndex, PWIndex: integer; RightsList:
array of integer);
const
USERSECTION = '
Benutzer';
ACCESSSECTION = '
Zugang';
begin
Assert(Assigned(AIni), '
Keine IniFile-Instanz übergeben');
Assert(Assigned(DataList), '
Keine Liste übergeben');
if DataList.Count - 1 < MaxIntValue([NameIndex, PWIndex,
MaxIntValue(RightsList)])
then
raise Exception.Create('
Liste enthält zuwenig Elemente');
AIni.WriteString(USERSECTION, DataList[NameIndex], DataList[PWIndex]);
AIni.WriteString(ACCESSSECTION, DataList[NameIndex],
RightsToString(DataList, RightsList));
end;