Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
handle bin files Posted by dibost on 2 Aug 2006 at 1:55 AM
Hello
I have a bin file (contains hex values) that i can open it with some other programs. I want to open the file with pascal, read specific address and show the data of specific address to screen. If someone can help?
Report
Re: handle bin files Posted by zibadian on 2 Aug 2006 at 1:59 AM
: Hello
: I have a bin file (contains hex values) that i can open it with some other programs. I want to open the file with pascal, read specific address and show the data of specific address to screen. If someone can help?
:
Open the file as an untyped file, then Seek() to that address. You can then use BlockRead() to get a data block. Finally close the file.
Procedures to use:
- Assign()
- Reset() { make sure to set the record size to what you need }
- BlockRead()
- Close()
Types to use
- File
Report
Re: handle bin files Posted by dibost on 2 Aug 2006 at 2:16 AM
: : Hello
: : I have a bin file (contains hex values) that i can open it with some other programs. I want to open the file with pascal, read specific address and show the data of specific address to screen. If someone can help?
: :
: Open the file as an untyped file, then Seek() to that address. You can then use BlockRead() to get a data block. Finally close the file.
: Procedures to use:
: - Assign()
: - Reset() { make sure to set the record size to what you need }
: - BlockRead()
: - Close()
: Types to use
: - File
:
Thanks for the help. Here is my code :

Procedure SERIALNUMBER;
var
NumFile : File;
ASSIGN(NumFile,'1772.bin');
RESET(NumFile);
BlockREad(0,10); (the address must be in decimal or hexadecimal or what)
CLOSE(NumFile);

Report
Re: handle bin files Posted by zibadian on 2 Aug 2006 at 2:38 AM
: : : Hello
: : : I have a bin file (contains hex values) that i can open it with some other programs. I want to open the file with pascal, read specific address and show the data of specific address to screen. If someone can help?
: : :
: : Open the file as an untyped file, then Seek() to that address. You can then use BlockRead() to get a data block. Finally close the file.
: : Procedures to use:
: : - Assign()
: : - Reset() { make sure to set the record size to what you need }
: : - BlockRead()
: : - Close()
: : Types to use
: : - File
: :
: Thanks for the help. Here is my code :
:
: Procedure SERIALNUMBER;
: var
: NumFile : File;
: ASSIGN(NumFile,'1772.bin');
: RESET(NumFile);
: BlockREad(0,10); (the address must be in decimal or hexadecimal or what)
: CLOSE(NumFile);
:
:
All integers may be specified as you wish. In other words you can use both:
  BlockRead(0, 10);

and
  BlockRead($0, $A);


Report
Re: handle bin files Posted by dibost on 2 Aug 2006 at 3:12 AM

Thanks again for the help. Is it possible to give me an example ? I have done it years ago with *.dat files and now i don't remember anything.

Report
Re: handle bin files Posted by zibadian on 2 Aug 2006 at 3:14 AM
:
: Thanks again for the help. Is it possible to give me an example ? I have done it years ago with *.dat files and now i don't remember anything.
:
:
The help files have lots of examples. Perhaps that's a great place to start.
Report
Re: handle bin files Posted by dibost on 2 Aug 2006 at 3:20 AM
I'm sorry. I just want help.
Report
Re: handle bin files Posted by zibadian on 2 Aug 2006 at 3:33 AM
: I'm sorry. I just want help.
:
Here is a simple example:
var
  f: File;
  a: array[0..9] of byte;
begin
  Assign(f, 'somefile.bin');  
  Reset(f, 1);
  Seek(f, 10); { Seek to 11th byte in the file }
  BlockRead(f, a, SizeOf(a)); { Fill a with the contents }
  Close(f);
end;

Report
Re: handle bin files Posted by dibost on 2 Aug 2006 at 3:43 AM
: : I'm sorry. I just want help.
: :
: Here is a simple example:
:
: var
:   f: File;
:   a: array[0..9] of byte;
: begin
:   Assign(f, 'somefile.bin');  
:   Reset(f, 1);
:   Seek(f, 10); { Seek to 11th byte in the file }
:   BlockRead(f, a, SizeOf(a)); { Fill a with the contents }
:   Close(f);
: end;
: 

:


Thank you.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.