ASerge,
I try to simplify the program here, so I may be able to catch what you wrote here.
So in the first part, we need to specify what will we call Option 1 (like selecting the "1selection.radio" from radiogroup + "1selection.combo" from combobox)
type
TOption1 = (combobox1.itemindex=1, radiogroup1.itemindex=1);
TOption2 = (combobox1.itemindex=2, radiogroup1.itemindex=2);
TOption3 = (combobox1.itemindex=3, radiogroup1.itemindex=3);
TOption4 = (combobox1.itemindex=1);
TOption5 = (radiogroup1.itemindex=1);
And then, we defined these options to a value string. Sort of a matrix I guess.... but this part is a bit shady for me
const
COption1: array[TOption1] of string = ('1selection.combo, '1selection.radio');
COption2: array[TOption2] of string = ('2selection.combo', '2selection.radio');
COption3: array[TOption3] of string = ('3selection.combo', '3selection.radio');
COption4: array[TOption4] of string = ('1selection.combo', '');
COption5: array[TOption5] of string = ('', '1selection.radio');
And then we implemented them to a drop down list (combobox)
ComboBoxOp1.Items.AddStrings(COption1, True);
ComboBoxOp1.ItemIndex := 0;
ComboBoxOp1.Items.AddStrings(COption2, True);
ComboBoxOp1.ItemIndex := 1;
ComboBoxOp1.Items.AddStrings(COption3, True);
ComboBoxOp1.ItemIndex := 2;
ComboBoxOp1.Items.AddStrings(COption4, True);
ComboBoxOp1.ItemIndex := 3;
ComboBoxOp1.Items.AddStrings(COption5, True);
ComboBoxOp1.ItemIndex := 4;
and then, a calculation function came in.... this is dark, i loast it from here
function OptionsToCode(Op1: TOption1; Op2: TOption2;Op3: TOption3;Op4: TOption4;Op5: TOption5): Int64;
begin
Result := Ord(Op1);
Result := Result * (Ord(High(Op2)) + 1);
Inc(Result, Ord(Op2));
Result := Result * (Ord(High(Op3)) + 1);
Result := Ord(Op3);
Result := Result * (Ord(High(Op4)) + 1);
Inc(Result, Ord(Op4));
Result := Result * (Ord(High(Op5)) + 1);
Inc(Result, Ord(Op5));
Result := Result * (Ord(High(Op6)) + 1);
end;
picture load- you load in the prev procedure
image1.picture.loadfromfile(Format('%s\drawings\%n.jpg',
[dir, OptionsToCode(TOption1(ComboBoxOp1.ItemIndex), TOption2(ComboBoxOp2.ItemIndex),TOption3(ComboBoxOp3.ItemIndex),TOption4(ComboBoxOp4.ItemIndex),TOption5(ComboBoxOp5.ItemIndex));
And the reverse function
procedure CodeToOptions(Code: Int64; out Op1: TOption1; out Op2: TOption2; out Op3: TOption3;out Op4: TOption4;out Op5: TOption5;);
begin
Op5 := TOption5(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op5)) + 1);
Op4 := TOption4(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op4)) + 1);
Op3 := TOption3(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op3)) + 1);
Op2 := TOption2(Code mod (Ord(High(Op2)) + 1));
Code := Code div (Ord(High(Op2)) + 1);
Op1 := TOption1(Code);
end;
And I guess it should look something like this: (feel free to call me retard t throw up to this
)
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
TOption1 = (combobox1.itemindex=1, radiogroup1.itemindex=1);
TOption2 = (combobox1.itemindex=2, radiogroup1.itemindex=2);
TOption3 = (combobox1.itemindex=3, radiogroup1.itemindex=3);
TOption4 = (combobox1.itemindex=1);
TOption5 = (radiogroup1.itemindex=1);
const
COption1: array[TOption1] of string = ('1selection.combo, '1selection.radio');
COption2: array[TOption2] of string = ('2selection.combo', '2selection.radio');
COption3: array[TOption3] of string = ('3selection.combo', '3selection.radio');
COption4: array[TOption4] of string = ('1selection.combo', '');
COption5: array[TOption5] of string = ('', '1selection.radio');
ComboBoxOp1.ItemIndex := 0;
ComboBoxOp1.Items.AddStrings(COption2, True);
ComboBoxOp1.ItemIndex := 1;
ComboBoxOp1.Items.AddStrings(COption3, True);
ComboBoxOp1.ItemIndex := 2;
ComboBoxOp1.Items.AddStrings(COption4, True);
ComboBoxOp1.ItemIndex := 3;
ComboBoxOp1.Items.AddStrings(COption5, True);
ComboBoxOp1.ItemIndex := 4;
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Image1: TImage;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
function OptionsToCode(Op1: TOption1; Op2: TOption2;Op3: TOption3;Op4: TOption4;Op5: TOption5): Int64;
begin
Result := Ord(Op1);
Result := Result * (Ord(High(Op2)) + 1);
Inc(Result, Ord(Op2));
Result := Result * (Ord(High(Op3)) + 1);
Result := Ord(Op3);
Result := Result * (Ord(High(Op4)) + 1);
Inc(Result, Ord(Op4));
Result := Result * (Ord(High(Op5)) + 1);
Inc(Result, Ord(Op5));
Result := Result * (Ord(High(Op6)) + 1);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
image1.picture.loadfromfile(Format('%s\drawings\%n.jpg',
[dir, OptionsToCode(TOption1(ComboBoxOp1.ItemIndex), TOption2(ComboBoxOp2.ItemIndex),TOption3(ComboBoxOp3.ItemIndex),TOption4(ComboBoxOp4.ItemIndex),TOption5(ComboBoxOp5.ItemIndex));
end;
procedure CodeToOptions(Code: Int64; out Op1: TOption1; out Op2: TOption2; out Op3: TOption3;out Op4: TOption4;out Op5: TOption5;);
begin
Op5 := TOption5(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op5)) + 1);
Op4 := TOption4(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op4)) + 1);
Op3 := TOption3(Code mod (Ord(High(Op5)) + 1));
Code := Code div (Ord(High(Op3)) + 1);
Op2 := TOption2(Code mod (Ord(High(Op2)) + 1));
Code := Code div (Ord(High(Op2)) + 1);
Op1 := TOption1(Code);
end;
end. [/code]