hello
I use visual basic 6.0.
I want to read file twice.
First i read file then i don't know how to move the file pointer to the start point.
i don't want to close file and reopen.
example)
Open InputFileName For Input As #1
While Not EOF(1)
Line Input #1, line
...
Wend
'move file pointer to the start point
'i don't know this
While Not EOF(1)
Line Input #1, line
...
Wend
Close #1
thanks for reading
5 8954
out of curiosity, why do you need to read the file twice?
Cyberdaemon
out of curiosity, why do you need to read the file twice?
Cyberdaemon
I'm developing a verifying program.
for example ) test.txt, 1, 1, 1, "F", 5, 5, 6, "TT" ...
test.txt : file name to verify
1 : line number of the file
1 : start offset of line
1 : end offset of line
"F" : compare data
5 : line number of the file
5 : start offset of line
6 : end offset of line
"TT" : compare data
First i open test.txt file
and search line
and if "Mid (line, start offset, end offset) = compare data " is ture, then print true
and repeat
It's line number is not sorted
It's the reason i read file repeatedly
You have any other good idea?
Tom Lee.
Pretty sure this is what you're looking for.
As for other ideas, there are probably plenty of things you could do. For one thing, even though the operating system does caching to avoid having to physically read the disk repeatedly, still file IO is fairly "expensive" . One way to get around this would be to load each line of the file into an array. You can either do this as you go through doing your comparison, or load it up at the start, all in one go, then just use the array instead of the file.
On the other hand, if you're talking about a small file and speed is not a major concern, you could just close the file and reopen it to start reading again from the beginning. But the Seek will be better than that approach.
You da man Killer42!
(Your suggestion worked for me too, and your high IQ is appreciated.)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: deepak |
last post by:
hi folks
I have a pointer to a file. If i increment the pointer, where will it point.
I could not find the problem in the FAQs.
Thanks in advance
Deepak garg
|
by: Don Pasquale |
last post by:
The following function intends to delete "numberoflines" lines from a text
file, named "s" (string pointer) and pointed to by file pointer "fp", starting
from line "line".
Now, the function works an inteded, but I think that this is purely
coincidential.
I'm using a temp file to copy the contents of the text file, and then, copy
the last lines that i want to keep, on top of those i want to delete.I fwrite
an EOF character after the...
|
by: Kevin Zhou |
last post by:
I have a file that contains 22 lines, each line has two float separated
by a space.
I want to store those float data into a two-dimensional array which size
I want the program to determine at run time
so i wrote the following function to count the number of lines in the
file to determine the row size for my storage array
int countline(FILE *fp)
{
int count;
|
by: Arif |
last post by:
Following are my text file(IndxItms.txt) contents:
---------------------------------------------------
0000 0
0002 52
0020 260
0045 312
0051 364
0087 416
|
by: ritesh |
last post by:
Hi,
I'm facing a problem in which I need to edit an already created file,
and the editing needs to be done at the start of the file rather then
appending to the file.
OS - Linux,Solaris
For e.g.
I have a file test.txt created and I have the path to this file in a
| |
by: guptashiitd |
last post by:
i want to move the pointer to some lines forward or backward in the fstream file from which i am reading the input
|
by: prasenjit2007 |
last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:-
<html>
<body>
<table>
<tr>
<td>To:</td>
<td><input type="text" name="to" size="50"
value="pras_sandilya@rediffmail.com"></td>
</tr>
|
by: karthigeyantp |
last post by:
hi,
i have a problem in resetting and unable to move the pointer in the text file using seekg()function in c++. what to do ??
|
by: leejwen |
last post by:
Hello, I used below MFC code to read a file, but I need do that several times, how can I move the pointer to the beginning of file once again. Thank you!
CFile f;
CArchive ar(&f, CArchive::load);
...
while(ar.ReadString(ptr))
{
...
}
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |