Hi,
I dont know much from programming, but i want to learn atleast something.

I got some simple programs source and trying to improve it.

So how it works now
in CSV file there are such entrys
Code:
1;10-man-normal (maps without heroic mode)
2;25-man-normal (or heroics pre 3.2)
4;10-man heroic
8;25-man-heroic
15;Spawned in all maps
and function to load string from file:
Code:
procedure LoadStringListFromFile(List: TStrings; csvname: string); forward; export;

procedure LoadStringListFromFile(List: TStrings; csvname: string);
var
  i: integer;
  n: integer;
  F, s: string;
begin
  F := dmMain.ProgramDir+'CSV\'+csvname+'.csv';
  if FileExists(F) then
  begin
    List.LoadFromFile(F);
    List.BeginUpdate;
    try
      for i:=0 to List.Count - 1 do
      begin
        s := List[i];
        n := Pos(';', s);
        List[i] := midStr(s, n+1, MAX_ITEM_LENGTH);;
        List.Objects[i] := pointer( StrToInt(MidStr(s, 1, n-1)));
      end;
    finally
      List.EndUpdate;
    end;
  end;
end;
So it loads only strings no matter what integers inside and with (1 shl i) calculates integer depending what is checked and showing result in field.

Code:
procedure TUnitFlagsForm.btOKClick(Sender: TObject);
var
  i: integer;
  skip: boolean;
begin
  skip := false;
  FFlags := 0;
  for i := 0 to clbMain.Items.Count - 1 do
    if clbMain.Checked[i] then FFlags := FFlags or (1 shl i) else skip := true;
  if not skip then fflags := -1;  
end;

procedure TUnitFlagsForm.FormCreate(Sender: TObject);
begin
  dmMain.Translate.CreateDefaultTranslation(TForm(Self));
  dmMain.Translate.TranslateForm(TForm(Self));
end;

procedure TUnitFlagsForm.Load(What: string);
begin
  Caption := What;
  LoadStringListFromFile(clbMain.Items, What);
  if clbMain.Items.Count <= 16  then clbMain.Columns := 1;
end;

procedure TUnitFlagsForm.Prepare(Text: string);
var
  i: integer;
begin
  FFlags := StrToInt64Def(Text,0);
  for i := 0 to clbMain.Items.Count - 1 do
  begin
    if FFlags and (1 shl i) <> 0 then
      clbMain.Checked[i] := true;
  end;
end;
Result(image):

http://img823.imageshack.us/img823/1839/84257356.jpg

What i want to change:
using (1 shl i) i can get the proper result if i click all first 4 checkboxes(result "15"), but if i want to use just 1 checkbox that should give the same value 15 without using any temp solution, it doesnt work(now gives 16).
As this funcion used not only for this 1 flag window, then it must be done some not hacky way.
So i decided best way would be, that depending what is checked, number would be loaded from csv file and shown in field and also in checkboxes.

Conditions:
+ If checked more then 1, then those are summed;
+ when loaded window, first should be checked csv file for such digit and if not then summing is applied to find what should be checked, for example, if in field used "3", then in window should be checked first 2 checkboxes. If "15" then checked is last checkbox);
+ if used like 40, what is not possible by summing even all, then none checkboxes should be checked;

If any could help me to get this done, would be really great

G