Thema: Delphi Variants und Arrays

Einzelnen Beitrag anzeigen

matashen

Registriert seit: 29. Jan 2007
Ort: daheim
460 Beiträge
 
Delphi XE2 Enterprise
 
#1

Variants und Arrays

  Alt 2. Jun 2014, 17:04
Hallo,

ich bekomme von einer dll ein Array in Form eines Variants. Im PDF zur dll ist das so beschrieben für VB

GetBarcodeReturn the barcode if detected. To use GetBarcode, the barcode reading functionality needs to be
enabled by BarcodeInit method.

Code:
Function GetBarcode () As Variant
Dim aa As Variant
BarCodeReturn = v.GetBarcode
List1.Clear
VarType (BarCodeReturn)
If UBound(BarCodeReturn) >= LBound(BarCodeReturn) Then
For f = LBound(BarCodeReturn) To UBound(BarCodeReturn)
List1.AddItem BarCodeReturn(f, 0) 'BarCodeString
List1.AddItem BarCodeReturn(f, 1) 'BarCode Type
List1.AddItem BarCodeReturn(f, 2) 'BarCode Orientation.
List1.AddItem BarCodeReturn(f, 3) 'BarCode Location
Next f
End If
Wie setz ich das in Delphi um?
was ich bisher versucht habe ist leider misslungen und zu Variants hab ich nichts brauchbares im Netz/Forum gefunden.

bisheriger Code (nur das wesentliche, rest rausgeschmissen wegen Übersicht)
Delphi-Quellcode:
var aa:variant;
..
aa:=video.GetBarcode;
if varisarray(aa) then begin
 if VarArrayHighBound(aa, 1)>VarArrayLowBound(aa, 1) then
    
  for I := VarArrayLowBound(aa, 1) to VarArrayHighBound(aa, 1) do
      begin
             label12.Caption:=vararrayget(aa,i);
Wenn ich die Größe des Array auslesen will und das Ergebnis in ein Memo schreibe bekomme ich nur Low=0 und High=0 oder Low=0 und High=-1
Delphi-Quellcode:
memo1.Lines.Add(inttostr(VarArrayLowBound(aa, 1)));
    memo1.Lines.Add(inttostr(VarArrayHighBound(aa, 1)));
Matthias
Das Leben ist eines der härtesten.
  Mit Zitat antworten Zitat