Einzelnen Beitrag anzeigen

Benutzerbild von Salomon
Salomon

Registriert seit: 9. Jun 2002
453 Beiträge
 
#1

2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 09:27
Hi,
das folgende Beispiel wollte ich von VB nach Delphi überstetzen. Allerdings gibt es Schwierigkeiten mit der Übergabe eines 2 Dim. OleVariant Array. Ich habe das Array folgendermaßen deklariert:

 tmpObj : array[0..2] of array[0..2] of OleVariant; So erhalte ich allerdings den Fehler: [Error] uRouteFrm.pas(175): Types of actual and formal var parameters must be identical

Hier mal meine nicht funktionierende delphi Übersetzung:

Delphi-Quellcode:

procedure TForm1.Button3Click(Sender: TObject);
Var
  Country, PlzTown, Street : String;
  GeocodeResult : Variant;
   tmpObj : array[0..2] of array[0..2] of OleVariant; // Pseudo 2 Dim array of OleVariant (Funktioniert nicht)
begin
  Country := 'D';
  PlzTown := '20354 Hamburg';
  Street := 'Gänsemarkt';

  GeocodeResult := MGCMapControl1.Map.Geocode(1, Country, PlzTown, Street);

  // Objekt für den Temp-Layer anlegen
  tmpObj [0, 0] := 'ID';
  tmpObj [1, 0] := 1;
  tmpObj [0, 1] := 'X';
  tmpObj [1, 1] := GeocodeResult[egriX, 0];
  tmpObj [0, 2] := 'Y';
  tmpObj [1, 2] := GeocodeResult[egriY, 0];

  // Objekt Darstellung vbRed
  MGCMapControl1.Map.AddressDB.SetTMPSymbol(easSTAR, clred, 50);

  // Data | Layer : OleVar
  MGCMapControl1.Map.AddressDB.Insert(tmpObj, '#TMP'); // <= Hier kommt der oben genannte Fehler
  // tmpObj needs to be a 2*X array

  {
  Inserts a new entry into the address data base.
  The describing VARAINT needs to be a 2*X array,
  where X is the number of describing fields.
  [0,i] should contain the Name of the field
  [1,i] should contain the Value for that field.
  minimum requirements are the ID, X & Y fields.
  If the value field for ID is EMPTY it will be filled by this method.

  ID 1
  x  2342242432
  y  24523452343
  }

 
 MGCMapControl1.RefreshMap;
Hier der original VB Code:

Code:
Private Sub Command1_Click()
Dim GeocodeResult As Variant
    Dim tmpObj
    Dim Country As String, PlzTown As String, Street As String
   
'In diesem Beispiel ist eine Adresse hart codiert
'sie muß zuerst geocodiert werden
    Country = "D"
    PlzTown = "20354 Hamburg"
    Street = "Gänsemarkt"
   
    GeocodeResult = MGCMapControl1.Map.Geocode(1, Country, PlzTown, Street)
   
 'Objekt für den Temp-Layer anlegen
    ReDim tmpObj(1, 2)
    tmpObj(0, 0) = "ID"
    tmpObj(1, 0) = 1
    tmpObj(0, 1) = "X"
    tmpObj(1, 1) = GeocodeResult(egriX, 0)
    tmpObj(0, 2) = "Y"
    tmpObj(1, 2) = GeocodeResult(egriY, 0)
   
'Festlegen wie Objekte im Temp-Layer dargestellt werden sollen
    MGCMapControl1.Map.AddressDB.SetTMPSymbol easSTAR, vbRed, 50
   
'Objekt in den Temp-Layer einfügen
    MGCMapControl1.Map.AddressDB.Insert tmpObj, "#TMP"
   
    MGCMapControl1.RefreshMap
End Sub
Thanx Salomon
01001000 01100001 01101100 01101100 01101111
01010111 01100101 01101100 01110100 00100001

http://www.it-adviser.net
  Mit Zitat antworten Zitat