各位大哥帮我解答一下

fantongwang 2007-02-08 12:01:53
Delphi里面的BlockWrite(无类型文件,Byte数组,从数组的哪个元素开始写入,第2个参数是一个Integer型的变量)
我想问的是,第4个参数到底是什么哦,有什么用,还有就是第2个参数,就是Byte数组参数在声明他的时候是应该写成array[1..128] of byte还是array[0..128] of byte呢,因为一个数据块是128字节的数据,我认为写成array[0..128] of byte那不是就多出一个字节的数据了吗,但是我在某本书上又看见了这样的写法,所以麻烦大哥们帮我解答一下上面的两个问题,HOHO
...全文
124 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihuasoft 2007-02-08
  • 打赏
  • 举报
回复
用[0..127]不就是128个元素了吗?

第三个参数并不是“从数组的哪个元素开始写入”,比如你用数组做Buffer,该参数为2,那么就是从Low(数组) 开始,把内存中连续2倍的数组长度的内容写入。

关于第四个参数,是一个可选参数,Delphi帮助里有介绍,我英文不好,你自己译一下吧:

procedure BlockWrite(var f: File; var Buf; Count: Integer [; var AmtTransferred: Integer]);

Description

F is an untyped file variable, Buf is any variable, Count is an expression of type Integer, and AmtTransferred is an optional variable of type Integer.

BlockWrite writes Count or fewer records to the file F from memory, starting at the first byte occupied by Buf. The actual number of complete records written (less than or equal to Count) is returned in AmtTransferred.

The entire block transferred occupies at most Count * RecSize bytes. RecSize is the record size specified when the file was opened (or 128 if the record size was unspecified).

If the entire block is transferred, AmtTransferred is equal to Count on return.

If AmtTransferred is less than Count, the disk became full before the transfer was complete. In this case, if the file's record size is greater than 1, AmtTransferred returns the number of complete records written.

BlockWrite advances the current file position by AmtTransferred records.

If AmtTransferred isn't specified, an I/O error occurs if the number written isn't equal to Count. If the $I+ compiler directive is in effect, errors raise an EInOutError exception.

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧