Author |
Message |
Coen Donde #1 / 9
|
 Reading binary files in PASCAL ??
Does anyone outthere know how to read binary-files with Pascal ??? Thanks in advance, COEN DONDERS
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Mike Copelan #2 / 9
|
 Reading binary files in PASCAL ??
Quote: > Does anyone outthere know how to read binary-files with PASCAL ???
Sure, but you'll have to be more specific about what type of file(s) you're trying to read. There are 2 ways to read "binary" files in TP/BP: typed file i/o (Reset, Seek/Read) and untyped (Reset, BlockRead). The data brought into the program by each type is very different, and each requires very different processing. If you can describe the information in the "binary" file in Pascal terms, then most likely you can define a record type and a file of that type - which is typed file i/o. If it's just a bunch of bytes/characters with no pattern (such as a .ZIP file), then it's probably best handled with untyped file i/o. As I said, the two types of "binary" file i/o are completely different, and you'll have to explain what the data on the file is, before we can give you more help.
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
ASS-War #3 / 9
|
 Reading binary files in PASCAL ??
Quote: > Does anyone outthere know how to read binary-files with PASCAL ??? > Thanks in advance, > COEN DONDERS
Yep, I know how to. Var F : File Of Byte ; B : Byte ; Begin Assign (F, 'FileName') ; Reset (F) ; While Not Eof (F) Do Begin Read (F, B) ; ... End ; Close (F) End ; You can allso use BlockRead. ASS-Ware
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Dmitri Poujliv #4 / 9
|
 Reading binary files in PASCAL ??
Quote:
>Does anyone outthere know how to read binary-files with PASCAL ??? >Thanks in advance, >COEN DONDERS
Typed files ot BlockRead/Write on untyped ones Cheers Dmitri -------------------------------------------------------------- Shit happens, but why it always happens to us? --------------------------------------------------------------
http://www.dma.be/p/bewoner/dmitri
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Ludo De Mey #5 / 9
|
 Reading binary files in PASCAL ??
Quote:
>>Does anyone outthere know how to read binary-files with PASCAL ??? >>Thanks in advance, >>COEN DONDERS >Typed files ot BlockRead/Write on untyped ones >Cheers > Dmitri >-------------------------------------------------------------- > Shit happens, but why it always happens to us? >--------------------------------------------------------------
> http://www.dma.be/p/bewoner/dmitri
What kind of binary files do you mean ? It all depends on the information of the file !! Ludo De Meyer
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Leonid Igolni #6 / 9
|
 Reading binary files in PASCAL ??
Quote:
> Does anyone outthere know how to read binary-files with PASCAL ??? > Thanks in advance, > COEN DONDERS
Just write : Var f : file of byte/word; b : byte/word; i : longint; begin . . . assign(f,'...'); reset(f); for i := 1 to filesize(f) do read(f,b); close(f); end. Leonid Igolnik. Bar Rav Hai David st. 44 / 5 Haifa 35591 Israel
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
PETER GRITS #7 / 9
|
 Reading binary files in PASCAL ??
: Does anyone outthere know how to read binary-files with PASCAL ??? : : Thanks in advance, : : COEN DONDERS : Something like: ---------------------------- TYPE tHeader = RECORD width : INTEGER; height : INTEGER; palentries : INTEGER; END; tPalEntry = RECORD r, g, b : BYTE; END; tPic = ARRAY [0..2047] OF POINTER; VAR f : FILE; h : tHeader; p : ARRAY [0..255] OF tPalEntry; d : tPic; i, j : INTEGER; BEGIN Assign (f, Filename); Reset (f, 1); BlockRead (f, h, Sizeof (tHeader)); IF h.palentries > 256 THEN Error ('Can''t handle large pals'); { I assume that Error will call exit (or halt ?) } BlockRead (f, p, h.palentries * Sizeof (tPalEntry)); IF h.height > 2048 THEN Error ('That's to big!'); FOR i := 0 TO h.height-1 DO BEGIN GetMem (d [i], h.width); BlockRead (f, d [i]^, h.width); END; Close (f); END; -- CU Peter -------------------------------------------------------------------
There was a point to this story, but it has temporarily escaped the chronicler's mind. Douglas Adams, "So Long, and Thanks for all the Fish"
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Ludo De Mey #8 / 9
|
 Reading binary files in PASCAL ??
Quote:
>>Does anyone outthere know how to read binary-files with PASCAL ??? >>Thanks in advance, >>COEN DONDERS >Typed files ot BlockRead/Write on untyped ones >Cheers > Dmitri >-------------------------------------------------------------- > Shit happens, but why it always happens to us? >--------------------------------------------------------------
> http://www.dma.be/p/bewoner/dmitri
What kind of binary files do you mean ? It all depends on the information of the file !! Ludo De Meyer
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Runar Skare #9 / 9
|
 Reading binary files in PASCAL ??
Quote:
> > >Does anyone outthere know how to read binary-files with PASCAL ??? > >Typed files ot BlockRead/Write on untyped ones > What kind of binary files do you mean ? > It all depends on the information of the file !!
Search for the help on Blockread or Blockwrite. There should be a good example program there somewhere (at least if you're using TP7/BP7
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
|