Help with BlockRead 
Author Message
 Help with BlockRead

Nevermind, I figured it out, Thanks though.

Dave



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with BlockRead

Hi, I'm trying to open an un-typed file and read a record from the file.  I tried this but it didn't
work.  Can someone please tell me what's wrong?  I think it is something wrong with how I am using
the BlockRead command, but I'm not sure. TIA.

program GAFEditor;

type
  _GAFHeader = record
    IDVersion: longint; {Always 0x00010100}
    Entries: longint; {Number of items in this file}
    Unknown1: longint; {Always 0}
  end;

var
  GAFHeader: _GAFHeader;
  GAFFile: file;

procedure OpenFile;
var
        filename: string[79];
begin
 filename:='C:\' + 'nocomp' + '.gaf';
  assign(GAFFile, filename);
  reset(GAFFile);
  blockread(GAFFile, GAFHeader, sizeof(GAFHeader));
  close(GAFFile);
end;

begin
        OpenFile;
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with BlockRead


Quote:

>Hi, I'm trying to open an un-typed file and read a record from the file.  I tried this but it didn't
>work.  Can someone please tell me what's wrong?  I think it is something wrong with how I am using
>the BlockRead command, but I'm not sure. TIA.

>procedure OpenFile;
>var
>    filename: string[79];
>begin
> filename:='C:\' + 'nocomp' + '.gaf';
>  assign(GAFFile, filename);
>  reset(GAFFile);

Always use 1 as the second parameter for reset and rewrite when using
untyped files. The default is 128.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with BlockRead

Hi

You use reset(GAFFile,1).

Borland Turbo Pascal Help ....
"procedure Reset(var F [: File; Recsize: Word ] );

[cut here]

RecSize is an optional expression of type  Word, which can be specified only
if F is an untyped file. If  F is an untyped file, RecSize specifies the
record size to be  used in data transfers. If RecSize is omitted, a default
record size of 128 bytes is assumed."

    ZeziK



Wed, 18 Jun 1902 08:00:00 GMT  
 Help with BlockRead

I had that problem when I was writting blockread-program before...
Afterward, I tried to use "reset(~~~~~~~,1);", then I fixed the problem!
                            -albert cheung

Quote:

> Hi, I'm trying to open an un-typed file and read a record from the file.  I tried this but it didn't
> work.  Can someone please tell me what's wrong?  I think it is something wrong with how I am using
> the BlockRead command, but I'm not sure. TIA.

> program GAFEditor;

> type
>   _GAFHeader = record
>     IDVersion: longint; {Always 0x00010100}
>     Entries: longint; {Number of items in this file}
>     Unknown1: longint; {Always 0}
>   end;

> var
>   GAFHeader: _GAFHeader;
>   GAFFile: file;

> procedure OpenFile;
> var
>         filename: string[79];
> begin
>  filename:='C:\' + 'nocomp' + '.gaf';
>   assign(GAFFile, filename);
>   reset(GAFFile);
>   blockread(GAFFile, GAFHeader, sizeof(GAFHeader));
>   close(GAFFile);
> end;

> begin
>         OpenFile;
> end.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help with BlockRead

2. Q : Help with fpk and blockread

3. help need with BlockRead

4. Urgent help needed with GFx mode and BlockRead/BlockWrite

5. error 200 on blockread (w/ patched tpl files)

6. Blockread/Blockwrite question.

7. Blockread/Blockwrite question

8. BLOCKREAD&BLOCKWRITE?

9. Correct use of BlockRead or alternative loading approach

10. BlockRead

11. blockread and JAVA

12. Blockread/write, how fast?

 

 
Powered by phpBB® Forum Software