program ArrayConsts;
{$MODE OBJFPC}
{$IfDef windows} {$APPTYPE CONSOLE} {$EndIf}
{$LONGSTRINGS ON}
const
ArrayCount = 18; // adjust this and the const to suit
type
TIntStrArray = array[0..Pred(ArrayCount)] of array of String;
const
IntStrArray: TIntStrArray = (('V17','V08','V19'),
('V10','V17','V08','V19'),
('V08','V09','V19'),
('V10','V08','V09','V19'),
('V30','V08','V09'),
('V10','S21','V08','V09'),
('V08','V17','V12','V19'),
('V08','V10','V17','V12','V19'),
('V08','V09','V19'),
('V08','V10','V09','V19'),
('V08','S21','V09'),
('V08','V10','S21','V09'),
('V08','V12','V19'),
('V08','V10','V12','V19'),
('V08','V09','V19'),
('V08','V10','V09','V19'),
('V08','S21','V09'),
('V08','V10','S21','V09'));
function FoundIndexedItemInArrayNamed(const aName: String; anIndex: Integer; out Item: String): Boolean;
var
i: Integer = -1;
begin
Item := '';
Result := False;
case aName of
'V021111': i := 0;
'V021112': i := 1;
'V021121': i := 2;
'V021122': i := 3;
'V021131': i := 4;
'V021132': i := 5;
'V021211': i := 6;
'V021212': i := 7;
'V021221': i := 8;
'V021222': i := 9;
'V021231': i := 10;
'V021232': i := 11;
'V021311': i := 12;
'V021312': i := 13;
'V021321': i := 14;
'V021322': i := 15;
'V021331': i := 16;
'V021332': i := 17;
else Exit;
end;
if anIndex <= High(IntStrArray[i]) then
begin
Result := True;
Item := IntStrArray[i][anIndex];
end;
end;
var
what, outStr: String;
begin
what := 'V021121';
if FoundIndexedItemInArrayNamed(what, 2, outStr) then
WriteLn(what,' index ',2,' is ',outStr)
else
WriteLn(what,' index ',2,' not found');
ReadLn;
end.