Autor Beitrag
HawkLUED
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62

WinXP
Delphi 7 Enterprise, Delphi 2007
BeitragVerfasst: Mi 18.04.07 19:33 
Hi zusammen,

ich habe folgendes Problem. Ich muss aus dem Speicher ein Array auslesen. Zur Zeit habe ich folgende Informationen:

- Startadresse
- Anzahl der Arrayelemente

Meiner Meinung nach reicht dies aber nicht aus oder? Z.B. bräuchte ich doch noch den Datentypen oder?

Hat jmd. eine Ideee, wie man dieses Problem lösen könnte? Zumindest einen Lösungsansatz?

Vielen Dank im voraus!

Gruß

Hawk

_________________
Wenn Debuggen der Vorgang ist, Fehler aus einem Programm auszubauen,
dann ist Programmieren der Vorgang, Fehler in ein Programm einzubauen !
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Mi 18.04.07 20:21 
In der Tat, du musst wissen, von welchem Typ die einzelnen Elemente sind.
Lässt sich aber durch
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  a: array of TMysticType;
  GroeßeEinesElements: Integer;
begin
  GroeßeEinesElements := SizeOf(a[Low(a)]);
end;

leicht herausfinden.
Das heißt du kannst dann das x-te Element des Arrays so auslesen (nach r kopieren):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TByteArray = array[1..l] of Byte; // l ist der Wert GroeßeEinesElements
  PByteArray = ^TByteArray;
var
  p: Pointer;
  x: Integer = 4;
  r: TByteArray;
begin
  r := PByteArray(Integer(p) + (x * l))^;
  ShowMessage('Angenommen, GroeßeEinesElements wäre 4 Bytes, also ein Integer: ' + IntToStr(Integer(r)));
end;

Sollte eigentlich funktionieren.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 18.04.07 20:26 
user profile iconChryzler hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TByteArray = array[1..l] of Byte; // l ist der Wert GroeßeEinesElements
  PByteArray = ^TByteArray;
var
  p: Pointer;
  x: Integer = 4;
  r: TByteArray;
begin
  r := PByteArray(Integer(p) + (x * l))^;
  ShowMessage('Angenommen, GroeßeEinesElements wäre 4 Bytes, also ein Integer: ' + IntToStr(Integer(r)));
end;

Sollte eigentlich funktionieren.

Seit wann geht denn das? :gruebel:
Du meintest wohhl ;) :
ausblenden Delphi-Quelltext
1:
2:
const
 x: integer = 4;
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Mi 18.04.07 20:58 
An manchen Stellen und ab neueren Delphi Versionen (D5) geht das, aber frag mich jetzt bloß nich, an welchen Stellen das alles zugelassen ist ;)
Gruß
alias5000

_________________
Programmers never die, they just GOSUB without RETURN
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 18.04.07 20:59 
Ich habe D7 und bei mir funktioniert es nicht!
Vielleicht verwechelst du das mit Cpp?
Erichgue
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 86

Win XP/2000/7
TurboPacal 7.0; Delphi 2/5/7; BDS 2006/2010/XE6; C#; MSSQl 2000
BeitragVerfasst: Do 19.04.07 09:39 
Var
t1 : Integer = 0;

Geht schon (Delphi 7), muß aber global sein, keine locale Procudur-Variable

Gruß

Erich