Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 23.07.03 18:11 
Hallo,
habe folgenden code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
type PAC_POINT = record
    x: Integer;
    y: Integer;
end;

// direction-types
type PAC_DIR = (PAC_DIRNONE = 0, PAC_DIRLEFT = 1, PAC_DIRUP = 2, PAC_DIRRIGHT = 3, PAC_DIRDOWN = 4);
const PAC_DIRS: array[0..5of PAC_POINT = ( (00), (-10),  (0,-1),  (10),  (01)  );

wie kann man das richtig definieren
so gehts aufjedenfall nicht :crying:

_________________
MFG
Michael Springwald, "kann kein englisch...."
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 23.07.03 18:30 
*schaut verwirrt auf den Code* ..Hi.. :)

Versuch mal das:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type
  PAC_POINT = Array[0..1of Integer; 
  PAC_DIR = (PAC_DIRNONE = 0, PAC_DIRLEFT = 1, PAC_DIRUP = 2, PAC_DIRRIGHT = 3, PAC_DIRDOWN = 4); 
end;

const
  PAC_DIRS: array[0..5of PAC_POINT = ( (00), (-10),  (0,-1),  (10),  (01)  );


Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 23.07.03 18:33 
Hallo!

Da du nicht genau geschrieben hast was genau du mit dem Code erreichen willst kann ich nur raten:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
type 
  PAC_POINT = record 
      x: Integer; 
      y: Integer; 
    end

  PAC_DIR = (PAC_DIRNONE, PAC_DIRLEFT, PAC_DIRUP, PAC_DIRRIGHT, PAC_DIRDOWN);  

const 
  PAC_DIRS: array[0..5of PAC_POINT = 
      ( 
        (x:  0; y:  0), 
        (x: -1; y:  0),
        (x:  0; y: -1),
        (x:  1; y:  0),
        (x:  0; y:  1)
      );
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 23.07.03 18:35 
Hallo

Onlinehilfe, record-konstanten im index eingeben

ausblenden Quelltext
1:
const PAC_DIRS: array[0..5] of Pac_POINT = ( (X:0; Y:0),(X:0; Y:0),(X:0; Y:0),(X:0; Y:0),(X:0; Y:0),(X:0; Y:0)) ;					


ein array 0..5 hat im übrigen 6 Elemente, nicht 5

edit: mist zu langsam

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
kurzer
Hält's aus hier
Beiträge: 11

Debian Linux Woody r3.0 Kernel 2.4.18k7; WinXP Home
MinGW C++
BeitragVerfasst: Mi 23.07.03 19:07 
Zitat:
ein array 0..5 hat im übrigen 6 Elemente, nicht 5

Du vergisst das '\0' Element!

[NEU]
Ach quark! Das is ja nur bei C / C++ so. Richtig wäre hier 0..4, da 5 Elemente erstellt werden sollen.


Zuletzt bearbeitet von kurzer am Mi 23.07.03 19:45, insgesamt 1-mal bearbeitet
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 23.07.03 19:16 
@Keldorn
kurzer hat recht wir starten den array von 0 und nicht von eins ansonsten hättes du recht wenn wir in von 1 starten würden:)

_________________
MFG
Michael Springwald, "kann kein englisch...."
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 24.07.03 09:49 
@mimi: Hat die Konstantendefinition denn jetzt geklappt?

Gruß
Tino
kurzer
Hält's aus hier
Beiträge: 11

Debian Linux Woody r3.0 Kernel 2.4.18k7; WinXP Home
MinGW C++
BeitragVerfasst: Do 24.07.03 10:29 
Ok! Wie es aussieht bedarf es jetzt mehr Erklärung!
Punkt 1: mimi und ich arbeiten am selben Projekt
Punkt 2: Es geht hier um die Nutzung einer DLL, die ich geschrieben hab, die auch super funktioniert.
Punkt 3: Das Problem ist, ich hab die DLL in C++ geschrieben und nun müssen spezielle Header nach Pascal übersetzt werden.

Header PAC_EXPORTS.H:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
#ifndef PAC_EXPORTS
#define PAC_EXPORTS

#include "pac_types.h" // pac-types

// constructors
PAC_BasicAI PAC_CreateBasicAI (PAC_POINT Position, PAC_ISFREEATPOINTXY ifapxy, bool Enabled = false);
PAC_BasicAI PAC_CreateBasicAI (int x, int y, PAC_ISFREEATPOINTXY ifapxy, bool Enabled = false);

// destructor
void PAC_DestroyBasicAI (PAC_BasicAI AI);

// Let's GO!
void PAC_MoveBasicAI (PAC_BasicAI AI, int Steps);

// to change/get some data
void PAC_SetPosition (PAC_BasicAI AI, int x, int y);
void PAC_SetPosition (PAC_BasicAI AI, PAC_POINT Position);
PAC_POINT PAC_GetPosition (PAC_BasicAI AI);

void PAC_SetEnabled (PAC_BasicAI AI, bool Enabled);
bool PAC_GetEnabled (PAC_BasicAI AI);

void PAC_SetIsFreeFunc (PAC_BasicAI AI, PAC_ISFREEATPOINTXY ifapxy);

#endif // PAC_EXPORTS


Header: PAC_TYPES.H
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
#ifndef PAC_TYPES
#define PAC_TYPES

// PAC_POINT-type
typedef struct
{
    int x;
    int y;
} PAC_POINT;

// direction-types
typedef enum { PAC_DIRNONE = 0, PAC_DIRLEFT, PAC_DIRUP, PAC_DIRRIGHT, PAC_DIRDOWN } PAC_DIR;
const PAC_POINT PAC_DIRS[5] = { { 0, 0 }, {-1, 0 }, { 0,-1 }, { 1, 0 }, { 0, 1 } };

// tool-tip missing *g*
typedef bool (*PAC_ISFREEATPOINTXY)(int, int);

// PAC_BasicAI-Type
typedef void* PAC_BasicAI;

#endif // PAC_TYPES


Jeder Üersetzungsversuch wurde zwar von Delphi kompiliert, jedoch kommt beim Start eines Testprogramms die Fehlermeldung, dass die Anwendung nicht richtig initialisiert werden kann, was mir sagt, dass die Funktionen aus der DLL nicht mit den richtigen Parametern aufgerufen werden.
Wenn jemand mitmachen will, diesen code zu übersetzen, kann er das gerne machen und hier Lösungen posten!
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 24.07.03 18:26 
Zitat:

@mimi: Hat die Konstantendefinition denn jetzt geklappt?

ja schon, aber das was jetzt kurzer geschriebn hat ist unser neues problem :( :(
kennt wer lösungen

_________________
MFG
Michael Springwald, "kann kein englisch...."