AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi 2 Dimensionales OleVariant Array erstellen?
Thema durchsuchen
Ansicht
Themen-Optionen

2 Dimensionales OleVariant Array erstellen?

Ein Thema von Salomon · begonnen am 12. Jul 2004 · letzter Beitrag vom 12. Jul 2004
Antwort Antwort
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
neolithos

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#2

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 09:33
Du hast kein Variant-Array erstellt, sondern ein Array mit Variants.

Schau mal in der OH nach VarArrayCreate, dort ist auch ein Bsp.
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat
Benutzerbild von Salomon
Salomon

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

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 09:37
Du hast recht. Das varArrayCreate hatte ich mir schonmal kurz angeschaut. Das sah mir so aus, als ob ich damit nur 1 Dimensionale Variant Array erzeugen kann.
Ich schaus mir aber nochmal an.
01001000 01100001 01101100 01101100 01101111
01010111 01100101 01101100 01110100 00100001

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

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#4

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 09:45
Das Bsp zeigt auch wie man 2 Dim Array's erstellt.
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat
Benutzerbild von Salomon
Salomon

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

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 17:58
Bei mir werden in den Beispielen immer nur 1 Dim. Arrays verwendet. Ich habe das Array jetzt mal folgendermaßen deklariert, ist das so richtig?
tmpObj := VarArrayCreate([0,2,0,2], varVariant);

Das ganze läst sich so kompilieren. Allerdings erhalte ich zur Laufzeit die Fehlermeldung "Wrong Data Variant Layout". Scheint also doch nicht 100% richtig zu sein. Ein kleines Deklarationsbeispiel zum 2 Dim. Variant Array könnte ich brauchen.

Thanx Salomon
01001000 01100001 01101100 01101100 01101111
01010111 01100101 01101100 01110100 00100001

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

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#6

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 18:56
Delphi-Quellcode:
var vCells : Variant;

...
  vCells := VarArrayCreate([0, fData.Count, 0, 6], varVariant);
...
  vCells[0, 0] := 'Vorgang';
  vCells[0, 1] := 'Bezeichnung';
  vCells[0, 2] := 'Zeit [' + fData.TE + ']';
  vCells[0, 3] := 'Direkter Nachfolger';
  vCells[0, 4] := 'Rangwerte Nachf. [' + fData.TE + ']';
  vCells[0, 5] := 'Rangwert [' + fData.TE + ']';
  vCells[0, 6] := 'Rang';
das funktioniert bei mir einwandtfrei!
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat
Benutzerbild von Salomon
Salomon

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

Re: 2 Dimensionales OleVariant Array erstellen?

  Alt 12. Jul 2004, 20:07
Es funktioniert
Ich hab mir nochmal den VB Code angeschaut. Der ReDim tmpObj(1, 2) Befehl gibt in den Klammern die Obergrenzen für das 2 Dim. Array an! Es muss also wie folgt definiert werden:
Delphi-Quellcode:
  tmpObj := VarArrayCreate([0,1,0,2], varVariant);

  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];
Danke für die Hilfe
Salomon
01001000 01100001 01101100 01101100 01101111
01010111 01100101 01101100 01110100 00100001

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


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz