Hi,
The solution suggested by @paweld works great, but I now have a variation of the problem, for which I beg your help again. It is not really so complicated by I am somewhat at a loss because I cannot devise a simple way of handling it.
In my initial example, for indicating that a given feature 'controls' another, a simple arbitrary notation like '2:5' was used, in this case indicating that the second value (state) of a feature controls the feature number 5. So, if in a given computer brand the soundcard is absent, then the "soundcard type" feature is automagically disabled in the feature tree. The solution proposed by @paweld works fine when that state of a feature controls
just one other feature (eg., 2:5). But it happens that I may cases in which a feature can control
more than one other feature. So, alongside a "soundcard type", I can also have a feature "soundcard power", which should also be disabled in the feature tree if the soundcard is absent. In this case, the control rule becomes "2:5-6", indicating that state 2 controls features 5 and 6. In fact, I could even have a rule like "2:5-7", indicating that state 2 controls features 5, 6, and 7., and so on.
It seems clear to me that any modifications should be added to the method below:
procedure TForm1.CheckInapplicables(SelectedIndex: integer);
var
j, k, StateNo, FeatureIdx: integer;
begin
if SelectedIndex >= 0 then
begin
for j := 0 to Length(Features) - 1 do
begin
if (Length(Features[J].Controls) > 0) and (pos(':', Features[J].Controls) > 0) then
begin
if TryStrToInt(Features[J].Controls.Split([':'])[0], StateNo) and
TryStrToInt(Features[J].Controls.Split([':'])[1], FeatureIdx) then
begin
if (StrToIntDef(Computers[SelectedIndex].attributes[j], 0) = StateNo) then
DiffrentIconChildState(FeatureIdx);
end;
end;
end;
end;
end;
However, I could not come up with a clear way of implementing it. Could anyone give me a hand?
Thanks in advance!
With
best wishes,