Delphi read file at specific address

Viewed 1373

This question is very basic because I am at a very basic level. I have to read the contents of a file with a *.pam extension. It's not common, that's a file generated by a specific program and it has a fixed size of xx KB. There are some numbers and values inside it.

I need to read this file and so I am going to use TStreamReader. Of course I need to know the structure of the file but I don't. By the way I have the picture above that is a part of a table with useful info:

enter image description here

The meaning is the following: once you've opened the file, go to a specific address and get the data. For example, in 0x30 I can find the data about 'Move 1 Current PP'. My question is: how do I jump to a given address?

procedure TForm1.Button1Click(Sender: TObject);
var sw: TStreamReader;
begin

 Memo1.Clear;    
 sw := TStreamReader.Create('C:\aaa\myfile.pam', TEncoding.UTF8);
 try

  sw.Position := 0;

 finally
  sw.Free;
 end;

I have seen in the documentation that there is something like Seek and Position but it seems that I cannot use them. In general I would use

while not(sw.EndOfStream) do
 begin
  //read...
 end;

This starts from the beginning and it reads the data in seqence. How can I jump to a specific address and read the content? I guess that I can pass the hex address to a function like Seek, so I can go to a specific point. Then I can just retrieve the data.

1 Answers
Related