Переименованный, чтобы просто присоединиться, не может требовать его быстро ..
function stringlist_mmg_Join(const LogicalUnitList, LUNList: TStringList): TStringList;
const NotFound = -1;
function ExtractTextBetween(const Txt, StartTag, EndTag : string; out iValue : integer): Boolean;
var
value : string;
iStartTag, iEndTag : integer;
begin
Result := False;
iStartTag := Pos(StartTag, Txt);
if (iStartTag = NotFound) then Exit;
iEndTag := PosEx(EndTag, Txt, iStartTag);
if (iEndTag = NotFound) then Exit;
Inc(iStartTag, Length(StartTag));
Value := MidStr(Txt, iStartTag, iEndTag-iStartTag);
Result := TryStrToInt(Value, iValue);
end;
var
i, v, ix: Integer;
begin
Result := TStringList.Create;
// iterate, Parse and write Value as Object
for i := 0 to LogicalUnitList.Count - 1 do begin
If ExtractTextBetween(LogicalUnitList[i], 'SCSILogicalUnit=', ';', v) then begin
LogicalUnitList.Objects[i] := Pointer(V+1);
end;
end;
// iterate, Parse and write Value as Object
for i := 0 to LUNList.Count - 1 do begin
If ExtractTextBetween(LUNList[i] + ';', 'LUN ', ';', v) then begin
LUNList.Objects[i] := Pointer(V+1);
end;
end;
// Match
for i := 0 to LogicalUnitList.Count - 1 do begin
ix := LUNList.IndexOfObject(LogicalUnitList.Objects[i]);
if (ix = NotFound) then Continue;
Result.Add(LogicalUnitList[i] + ' =>>>' + LUNList[ix] + ';');
end;
end;
Ouput:
SCSIBus=0;SCSILogicalUnit=43;SCSIPort=2;SCSITargetId=0;Status=OK =>>> LocationInformation REG_SZ Port(2,2,3,3) Bus 0, Target ID 0, LUN 43;
SCSIBus=0;SCSILogicalUnit=44;SCSIPort=2;SCSITargetId=0;Status=OK =>>> LocationInformation REG_SZ Port(2,2,3,3) Bus 0, Target ID 0, LUN 44;
SCSIBus=0;SCSILogicalUnit=45;SCSIPort=2;SCSITargetId=0;Status=OK =>>> LocationInformation REG_SZ Port(2,2,3,3) Bus 0, Target ID 0, LUN 45;