473,385 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

reading in a file

i have a file - which on each line has some data i need to fill into a
box - now although reading in the data is simple enough and putting it
in the correct box will be no problem, as i can just read a lilne then
put into the corresponding box...it just seems like a task i should be
able to complete in a few lines...rather than quite a few commands.

for example what i do at the moment is:

read a line
place into first text box
read a line
place into second text box
etc...

is there an smaller version of this? I am kind of feeling there should
be something like:

while there are more lines:
read a line
place into corresponding text box.

any ideas on what i should do?
Thanks in advance!

Sep 29 '06 #1
3 1781
Hi lizii,

"lizii" <cr*****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>i have a file - which on each line has some data i need to fill into a
box - now although reading in the data is simple enough and putting it
in the correct box will be no problem, as i can just read a lilne then
put into the corresponding box...it just seems like a task i should be
able to complete in a few lines...rather than quite a few commands.

for example what i do at the moment is:

read a line
place into first text box
read a line
place into second text box
etc...

is there an smaller version of this? I am kind of feeling there should
be something like:

while there are more lines:
read a line
place into corresponding text box.
Can you specify an algorithm for "corresponding text box"? If you can you
have your solution.

If you e.g. access your text boxes by a resource ID with good old Win32 you
might want to create an array or vector of IDs where you move forward
whenever you have read a line:

int controlID[] = { ID_TEXT_1, ID_TEXT_2, ID_TEXT_3 };
int i = 0;

for(int i = 0; i < 3; ++i)
{
// read your line
SetDlgItemText(hwnd, controlID[i], <your read line as char array>);
}

As you can see above you somehow have to ensure that the number of text
boxes and the number of read lines matches.

--
SvenC
any ideas on what i should do?
Thanks in advance!

Sep 29 '06 #2
Hi SvenC,
Can you specify an algorithm for "corresponding text box"? If you can you
have your solution.
is exactly what i am sticking at - you are saying something about
ResourceID - that sounds like a perfect solution :)

i was thinking for each textbox - add a tag and somehow using unique
tags (eg TEXT_1) i could use that to refer to which textbox i want -
then for each line i read in add to corresponding textbox. If thats
possible that would solve my problem and make far less lines of code!

I know that only i will be changing the order of the text file and for
any textboxes which end up being more than one line i would add markers
like [start], [end]. Just that knowing that the third line (or that
block) i am reading in would be corresponding to the third textbox.

Will my idea about tags work?

thanks again - get step by step closer to figuring this bit out :)

SvenC wrote:
Hi lizii,

"lizii" <cr*****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
i have a file - which on each line has some data i need to fill into a
box - now although reading in the data is simple enough and putting it
in the correct box will be no problem, as i can just read a lilne then
put into the corresponding box...it just seems like a task i should be
able to complete in a few lines...rather than quite a few commands.

for example what i do at the moment is:

read a line
place into first text box
read a line
place into second text box
etc...

is there an smaller version of this? I am kind of feeling there should
be something like:

while there are more lines:
read a line
place into corresponding text box.

Can you specify an algorithm for "corresponding text box"? If you can you
have your solution.

If you e.g. access your text boxes by a resource ID with good old Win32 you
might want to create an array or vector of IDs where you move forward
whenever you have read a line:

int controlID[] = { ID_TEXT_1, ID_TEXT_2, ID_TEXT_3 };
int i = 0;

for(int i = 0; i < 3; ++i)
{
// read your line
SetDlgItemText(hwnd, controlID[i], <your read line as char array>);
}

As you can see above you somehow have to ensure that the number of text
boxes and the number of read lines matches.

--
SvenC
any ideas on what i should do?
Thanks in advance!
Sep 29 '06 #3
Hi lizii,

"lizii" <cr*****@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi SvenC,
>Can you specify an algorithm for "corresponding text box"? If you can you
have your solution.

is exactly what i am sticking at - you are saying something about
ResourceID - that sounds like a perfect solution :)

i was thinking for each textbox - add a tag and somehow using unique
tags (eg TEXT_1) i could use that to refer to which textbox i want -
then for each line i read in add to corresponding textbox. If thats
possible that would solve my problem and make far less lines of code!
Tags sound like you use .Net controls? So you can enumerate the Controls
collection of the form your text boxes live in and use the Tags field to
find specific text boxes.
The more controls your form has the longer the search for your control with
a given tag might take. If that starts to get a performance problem, you
might consider to iterate the controls collection ones and store the
relevant text boxes in a Dictionary with your tag as key.

--
SvenC
I know that only i will be changing the order of the text file and for
any textboxes which end up being more than one line i would add markers
like [start], [end]. Just that knowing that the third line (or that
block) i am reading in would be corresponding to the third textbox.

Will my idea about tags work?

thanks again - get step by step closer to figuring this bit out :)

SvenC wrote:
>Hi lizii,

"lizii" <cr*****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googleg roups.com...
>i have a file - which on each line has some data i need to fill into a
box - now although reading in the data is simple enough and putting it
in the correct box will be no problem, as i can just read a lilne then
put into the corresponding box...it just seems like a task i should be
able to complete in a few lines...rather than quite a few commands.

for example what i do at the moment is:

read a line
place into first text box
read a line
place into second text box
etc...

is there an smaller version of this? I am kind of feeling there should
be something like:

while there are more lines:
read a line
place into corresponding text box.

Can you specify an algorithm for "corresponding text box"? If you can you
have your solution.

If you e.g. access your text boxes by a resource ID with good old Win32
you
might want to create an array or vector of IDs where you move forward
whenever you have read a line:

int controlID[] = { ID_TEXT_1, ID_TEXT_2, ID_TEXT_3 };
int i = 0;

for(int i = 0; i < 3; ++i)
{
// read your line
SetDlgItemText(hwnd, controlID[i], <your read line as char array>);
}

As you can see above you somehow have to ensure that the number of text
boxes and the number of read lines matches.

--
SvenC
any ideas on what i should do?
Thanks in advance!

Sep 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.