Hilfe bei Umsetzung von Delphi/Pascal zu Pure

Für allgemeine Fragen zur Programmierung mit PureBasic.
Joshua314
Beiträge: 115
Registriert: 06.04.2005 22:44

Hilfe bei Umsetzung von Delphi/Pascal zu Pure

Beitrag von Joshua314 »

Hallo Zusammen,

ich habe da noch ein Problem. Anbei 2 Fetzen Code.
Einmal in Delphi/Pascal und einmal meine nicht funktionierende Interpretation in Pure.

Mein Problem ist die Umsetzung der Übergabe der Liste bzw Structure
Genau genommen hier

TSucheTelefonnummer = procedure( Nummer : PChar; var EintragListe : PDLLEintrag; var EintragAnzahl : LongInt ); stdcall;

liegt mein Problem

Die Nummer:Pchar und EintragAnzahl kommen sauber rein raus .
Nur das Ergebnis Bekomme ich nicht.

Gruß Thomas

Code: Alles auswählen

nit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DdeMan;

type
  TitelArray            = Array[1..5] of Byte;

  PDLLEintrag           = ^TDLLEintrag;
  TDLLEintrag           = Packed Record
    Markiert          : Boolean;

    Titel             : TitelArray;

    Adel              : Byte;
    NameVorsatz       : Byte;
    NameZusatz        : Byte;

    Geschlecht        : Byte;
    Vorname           : String[30];
    Anrede            : String[10];
    Name              : String[120];
    Zusatz            : String[120];
    Ortsteil          : String[40];
    Strasse           : String[46];
    Hausnummer        : String[10];
    HausnummerZusatz  : String[20];
    Land              : String[3];
    PLZ               : String[5];
    Ort               : String[70];
    Vorwahl           : String[10];
    TelZusatz         : String[15];
    Telefon           : String[20];
  end;
  
  PDLLArray             = ^TDLLArray;
  TDLLArray             = Array[1..1] of TDLLEintrag;


  TUseVersion = procedure(V : Byte); stdcall;
  TSucheTelefonnummer = procedure( Nummer : PChar; var EintragListe : PDLLEintrag;
                                   var EintragAnzahl : LongInt ); stdcall;


  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    ListBox1: TListBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure Button1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
  private
    { Private-Deklarationen }
    DllHdl : THandle;
  public
    { Public-Deklarationen }
  end;


var
 Form1 : TForm1;

 DllHdl : THandle;
 FuncPtr : TFarProc;
 PSucheTelefonnummer : TSucheTelefonnummer;
 PUseVersion : TUseVersion;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
 EList : PDLLEintrag;
 ETemp : PDLLArray;
 ECount : LongInt;
 co : LongInt;
begin
  PSucheTelefonnummer( PChar( Edit1.Text ), EList, ECount );
  ETemp := PDLLArray( EList );

  for co := 1 to ECount do begin
   ListBox1.Items.Add( ETemp^[co].Name + #32 + ETemp^[co].Vorname + #32 +
                       ETemp^[co].Vorwahl + '-' + ETemp^[co].Telefon );
  end;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
  PUseVersion( 2 );
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  PUseVersion( 1 );
end;

initialization
  DllHdl := 0;
  FuncPtr := Nil;

  DllHdl := LoadLibrary( 'rufid.dll' );
  if DllHdl = 0 then
   Halt;

  FuncPtr := GetProcAddress( DllHdl, 'SucheTelefonnummer' );
  if FuncPtr = nil then
    Halt
  else
   @PSucheTelefonnummer := FuncPtr;

  FuncPtr := GetProcAddress( DllHdl, 'UseVersion' );
  if FuncPtr = nil then
    Halt
  else
   @PUseVersion := FuncPtr;

end.

und hier mein dagegen in Pure

Code: Alles auswählen

;************************************* Vars
EnableExplicit
Global *SucheTelefonnummer,*UseVersion





; DLLPath:= DllPath + 'rufid.dll';
; 
; DllHdl := LoadLibrary(PChar (DLLPath));
; 
; If DllHdl > 0 then
;   begin
;     FuncPtr := GetProcAddress( DllHdl, 'SucheTelefonnummer' );
;     If FuncPtr <> nil then @PSucheTelefonnummer := FuncPtr;
; 
;     FuncPtr := GetProcAddress( DllHdl, 'UseVersion' );
;     If FuncPtr <> nil then @PUseVersion := FuncPtr;
; 
;   End; 

; TDLLEintrag           = Packed Record
;     Markiert          : Boolean;
; 
;     Titel             : TitelArray;
; 
;     Adel              : Byte;
;     NameVorsatz       : Byte;
;     NameZusatz        : Byte;
; 
;     Geschlecht        : Byte;
;     Vorname           : String[30];
;     Anrede            : String[10];
;     Name              : String[120];
;     Zusatz            : String[120];
;     Ortsteil          : String[40];
;     Strasse           : String[46];
;     Hausnummer        : String[10];
;     HausnummerZusatz  : String[20];
;     Land              : String[3];
;     PLZ               : String[5];
;     Ort               : String[70];
;     Vorwahl           : String[10];
;     TelZusatz         : String[15];
;     Telefon           : String[20];
;   End;
; 
Structure TDLLEintrag
  Markiert.c
  Titel.c[5]
  Adel.c
  NameVorsatz.c
  NameZusatz.c
  Geschlecht.c
  Vorname.s{30}
  Anrede.s{10}
  Name.s{120}
  Zusatz.s{120}
  Ortsteil.s{40}
  Strasse.s{46}
  Hausnummer.s{10}
  HausnummerZusatz.s{20}
  Land.s{3}
  PLZ.s{5}
  Ort.s{70}
  Vorwahl.s{10}
  Telzusatz.s{15}
  Telefon.s{20}
EndStructure

Global Res.TDLLEintrag
       ;AddElement(res())
Global *Start = @Res
Global Count.l
Global *Count = @Count
Global Such.s = "090819628"
Global *Such = @Such

If OpenLibrary(0,"C:\Program Files\klickIdent Frühjahr 2009\rufid.dll")
  *SucheTelefonnummer = GetFunction(0,"SucheTelefonnummer")  
  *UseVersion = GetFunction(0,"UseVersion")
  Debug *SucheTelefonnummer
  Debug *UseVersion

  Debug *start
  
  CallFunctionFast(*UseVersion,1)
  CallFunctionFast(*SucheTelefonnummer,*Such,*Start,*Count)
  Debug *start
  
  If ExamineLibraryFunctions(0)
    While NextLibraryFunction()
      Debug LibraryFunctionName()
    Wend
  EndIf 
EndIf

Repeat  
ForEver