Entwickler-Ecke

Delphi Language (Object-Pascal) / CLX - Namen im Record


Niko S. - Fr 17.07.09 10:16
Titel: Namen im Record
Ich bin grad auf ein Problem gestoßen.
Unzwar wollte ich von einem anderen Programm die Struktur nach Delphi übernehmen um das Dateiformat kompatibel zu machen.
Allerdings benutzt dieses Format "Type" in einem Record und das geht anscheinend in Delphi nicht.
Weiß jemand was ich da machen kann, außer eine andere Srache wählen? ;x


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Fr 17.07.2009 um 11:05


jfheins - Fr 17.07.09 10:25

Zeig mal die Orginal-Deklaration ;)


Niko S. - Fr 17.07.09 10:33

Original Code:

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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
Type TileRec
    Ground As Long
    Mask As Long
    Anim As Long
    Mask2 As Long
    M2Anim As Long
    Fringe As Long
    FAnim As Long
    Fringe2 As Long
    F2Anim As Long
    Type As Byte
    Data1 As Long
    Data2 As Long
    Data3 As Long
    String1 As String
    String2 As String
    String3 As String
    Light As Long
    GroundSet As Byte
    MaskSet As Byte
    AnimSet As Byte
    Mask2Set As Byte
    M2AnimSet As Byte
    FringeSet As Byte
    FAnimSet As Byte
    Fringe2Set As Byte
    F2AnimSet As Byte
End Type

Type MapRec
    Name As String * 20
    Revision As Integer
    Moral As Byte
    Up As Integer
    Down As Integer
    Left As Integer
    Right As Integer
    music As String
    BootMap As Integer
    BootX As Byte
    BootY As Byte
    Shop As Integer
    Indoors As Byte
    Tile() As TileRec
    NPC(1 To 15) As Integer
    SpawnX(1 To 15) As Byte
    SpawnY(1 To 15) As Byte
    Owner As String
    Scrolling As Byte
    Weather As Integer
End Type


Und das ist mein Versuch in Delphi

Delphi-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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
  TTile = record
    Ground : LongInt;
    Mask : LongInt;
    Anim : LongInt;
    Mask2 : LongInt;
    M2Anim : LongInt;
    Fringe : LongInt;
    FAnim : LongInt;
    Fringe2 : LongInt;
    F2Anim : LongInt;
    Type : Byte;   // Type geht nicht..
    Data1 : LongInt;
    Data2 : LongInt;
    Data3 : LongInt;
    String1 : String;
    String2 : String;
    String3 : String;
    Light : LongInt;
    GroundSet : Byte;
    MaskSet : Byte;
    AnimSet : Byte;
    Mask2Set : Byte;
    M2AnimSet : Byte;
    FringeSet : Byte;
    FAnimSet : Byte;
    Fringe2Set : Byte;
    F2AnimSet : Byte;
  end;

  TMap = record
    Name : String[20];
    Revision : Integer;
    Moral : Byte;
    Up : Integer;
    Down : Integer;
    Left : Integer;
    Right : Integer;
    music : String;
    BootMap : Integer;
    BootX : Byte;
    BootY : Byte;
    Shop : Integer;
    Indoors : Byte;
    Tile : array of array of TTile;
    NPC : array[1..15of Integer;
    SpawnX : array[1..15of Byte;
    SpawnY : array[1..15of Byte;
    Owner : String;
    Scrolling : Byte;
    Weather : Integer;
  end;


Krischa - Fr 17.07.09 10:34

Type ist von Delphi reserviert und darf nicht als "Variablenname" verwendet werden.


Reinhard Kern - Fr 17.07.09 14:38

user profile iconNiko S. hat folgendes geschrieben Zum zitierten Posting springen:
Und das ist mein Versuch in Delphi

Hallo,

das Wort ist reserviert, aber Namen sind Schall und Rauch, wenn du stattdessen Type1 schreibst (oder was immer dir geeignet erscheint), wird alles funktionieren wie gewünscht.

Wahrscheinlich muss es aber heissen "packed record", damit keine Lücken zwischen den Elementen vorgesehen werden.

Gruss Reinhard

Moderiert von user profile iconNarses: Zitat gekürzt.


oki - Fr 17.07.09 16:18

Nenne das Feld einfach Typ. Auf deine Daten hat das keinen Einfluß, da es ja nur ein Bezeichner ist. Alle anderen Varianten wie Type_ usw. sind natürlich auch möglich. Im Rahmen deines Quellcodes greifst du auf dieses Feld dann natürlich mittels Typ (Type_) zu wo in der anderen Sprache der Bezeichner Type verwendet wird.

Gruß oki


Niko S. - Fr 17.07.09 16:25

hm okay dann wäre das schonmal "gelöst", dennoch sind die daten irgendwie nicht ganz richtig die ich auslese aber das steht ja im anderen thread ;x


Xentar - Sa 18.07.09 18:58

Kurze Frage:


Quelltext
1:
    Tile() As TileRec                    

wurde übersetzt mit

Delphi-Quelltext
1:
    Tile : array of array of TTile;                    

Ist das nicht ein array of zuviel?


Niko S. - Sa 18.07.09 19:01

Nein das ist ein 2 Dimensionales array...
Also im Server wird das mit Map(index).Tile(x, y) angesprochen...