如何重写修正值 [英] How To Rewrite The Corrected Value

查看:62
本文介绍了如何重写修正值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展开 | 选择 | Wrap | 行号

推荐答案

此子目录用于演示向/从文件读取和写入数据的方法在二进制模式下。如上所述,它实际上并没有实现任何有用的东西。它只是将整个文件读入一个数组,然后立即将数组直接写回文件。唯一可见的结果将是文件上新的最新更新日期/时间。


我刚刚测试过它(第一次),它 似乎成功地重新编写了文件。


你需要做的是在标有第2部分的点上对阵列进行校正,以便写回文件的数据包括更正。换句话说,整个过程将是将文件读入数组,更正数组,然后将其写回文件。


您可以通过多种方式执行此操作,包括:
  • 将数据更正代码插入到第2部分的ReWrite_Open_File例程中。
  • 将数据更正代码放在单独的Sub中,并在标记的点上调用它第2部分。
  • (首选选项)将演示的文件读写技术合并到您自己的代码中。正如您所看到的,实际的文件访问非常简单。
This sub was written to demonstrate methods of reading and writing the data to/from the file in binary mode. As written, it doesn''t actually achieve anything useful. It simply reads the entire file into an array, then immediately writes the array straight straight back to the file. The only visible result of this will be a new last-updated date/time on the file.

I''ve just tested it (for the first time), and it does appear to successfully re-write the file in place.

What you need to do is perform your correction to the array at the point labelled PART 2, so that the data written back to the file includes the corrections. In other words, the overall process would be to read the file into the array, correct the array, then write it back to the file.

You can do this in a number of ways, including:
  • Insert your data-correction code into the ReWrite_Open_File routine at "PART 2".
  • Place your data-correction code in a separate Sub and call it at the point labelled "PART 2".
  • (The preferred option) Incorporate the demonstrated file reading and writing techniques into your own code. As you can see, the actual file access is very simple.


Killer42我实际上无法理解你在说什么。但我能理解修正也转换成数组whwn它将数据写回到文件中。你能给我一些例子,这样我就能理解并继续解决这个问题
Killer42 i actualy cant understand what you are saying.But i can understand that the correction also translate into array whwn it write back data in to the file.Can u give me some examples so that i can understand and proceed with this problem


我不知道我是否真的可以更简单地解释一下。整个过程是这样的...
I don''t know whether I can really explain it much more simply. The overall process is this...
  1. 你打开文件。
  2. 你从文件中读取数据(到一个字节数组,在这种情况下)。
  3. 您将数据写回文件(来自字节数组)。
  4. 您关闭文件。

介于两个步骤之间在此过程中,您需要对数组中保存的数据进行更正。否则,你只是将已经存在的相同信息放回文件中。


我可以在例程中发布的唯一有意义的更改是调用某些例程你的,在标有第2部分的点上对阵列进行校正。如果你仍然无法让它工作,试着玩一会儿。毕竟,包括你对阵列的校正,你实际上只有那五个简单的块。坚持在一起。逻辑上只有很多方法可以做到。

Somewhere between steps 3 and 4 in this process, you need to make your corrections to the data held in the array. Otherwise, you are just putting back in the file the same information which was already there.

The only meaningful change I could make in the routine as posted would be a call to some routine of yours which does the correction to the array, at the point labelled "PART 2". If you still can''t get it to work, try playing around with it for a while. After all, including your correction to the array, you''ve really only got those five simple "blocks" to stick together. There are only so many ways you can logically do it.


这篇关于如何重写修正值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆