?
Solved

Pointers in Delphi 32

Posted on 1998-01-02
2
Medium Priority
?
935 Views
Last Modified: 2008-02-26
My problem is, I have to increment a pointer.
    In old 16 bit code, I does it by use
   p := ptr(seg(p^),ofs(p^) + n);
    but this is not longer possible in delphi 32. So how can I do the
same stuff in 32bit?
    Here is some dummy code to make my problem more understandable...
    Type
   Rec = record
      size: integer;
      data: array[0..0] of byte;
   end;
   prec = ^rec;
   procedure readmorerecs;
   var
  p : pointer;
  numberofrec: integer;
   begin
  filestream := tfilestream.create('somefile',fmopenread);
  getmem(p,filestream.size);
  filestream.read(numberofrec,sizeof(integer));
  filestream.read(p^,filestream.size);
  interpretrec(p,numberofrec);
  filestream.free;
   end;
   procedure interpretrecs(var p; numberofrec: integer);
   var
  myrec: prec;
   begin
  myrec := @p;
  while numberofrec > 0 do
  with myrec^ do
  begin
   dosomething with myrec
   // not possible in 32 bit
   myrec := Ptr(Seg(myrec^),Ofs(myrec^)+Size);
   dec(numberofrec);
  end;
   end; *)

--
info@cpfreiburg.de
0
Comment
Question by:karlhfreiburg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
hustch earned 200 total points
ID: 1355110
In Delphi 32, you don't use the segment any more, the 32-bit pointer is an offset.
You can add Size to your pointer directly. If the Compiler won't let you do it with a pointer of type prec, you can typecast it to type PChar (myrec := prec(PChar(myrec)+size);)
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1355111
Maybe Size here is meant to be SizeOf(Rec)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question