Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Basic4ppc Wishlist
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Basic4ppc Wishlist Missing any feature?


Reading textfiles by line number...


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-06-2007, 11:50 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,322
Awards Showcase
Forum Contributer 
Total Awards: 1
Default Reading textfiles by line number...

We already have the ability to read text files (utf-8), and binary files...
Thoght binary files have positioning, its very dificult to know exactly were a datastream starts and ends, at least for me it is..

It would be of great help if we could read a specific line in a text file,
something like

FileReadLine(number)

and of course to get the number of lines a text file contains...

I know that, due to text wrapping, a file may apear to have more lines than it really has, so I'm aiming at the CHR(13) or crlf character as a end of line indicator...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #2 (permalink)  
Old 08-07-2007, 06:48 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,143
Default

This is technically impossible without first reading (number-1) lines.
Each line can be with a different length (characters and bytes) so without some kind of index (which regular text files do not include) you can't jump to a specific line.
Reply With Quote
  #3 (permalink)  
Old 08-07-2007, 08:00 AM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,322
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Asssuming a text file is not that big, say 20 lines of text, is it practical to read all lines, line-by-line, to an array?
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #4 (permalink)  
Old 08-07-2007, 08:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,143
Default

A much larger file can also be loaded into an array.
Reply With Quote
  #5 (permalink)  
Old 08-07-2007, 08:32 AM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,322
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

But won't that eat up a lot of device resources?
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #6 (permalink)  
Old 08-07-2007, 08:38 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,143
Default

Each character takes about 2 bytes.
So 100 lines of text * 50 characters = 10kb.
This is not too much memory. A single bitmap takes more than that.
Reply With Quote
  #7 (permalink)  
Old 08-07-2007, 11:48 AM
Newbie
 
Join Date: Aug 2007
Location: Baldingen, Switzerland
Posts: 5
Send a message via Yahoo to thedyg Send a message via Skype™ to thedyg
Default

I'm still happy, if there is a function to readout or set the actual filepointer position.

My idea is, to scan a file (XML or whatever) one time sequentiel, find some keywords and save this to an array with the byteposition in the file.

Then i can save this array to another indexfile and reread it on the next appl. start very quickly back in my array.

If i need datas, i just search in the array the right keyword, readout the saved fileposition and move the filepointer to this position to readout all the detailed information in a very fast and easy way.

In Visual Basic there is a function SEEK available to readout or set this position.
http://msdn2.microsoft.com/en-us/lib...yt(VS.71).aspx

Last edited by thedyg : 08-07-2007 at 11:55 AM.
Reply With Quote
  #8 (permalink)  
Old 08-07-2007, 12:30 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

There are in b4ppc all the tools you need.

Open text file as binary file.
Write a function to read a whole line starting from a specific position and reading one byte at a time and when finds CRLF (or what ever) returns a string containing the whole line.
Keep the position of the first byte. That is your index
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #9 (permalink)  
Old 08-07-2007, 03:45 PM
Newbie
 
Join Date: Aug 2007
Location: Baldingen, Switzerland
Posts: 5
Send a message via Yahoo to thedyg Send a message via Skype™ to thedyg
Default

Hi Dimitri,

you've right.

But reading text in a byte per byte case normally is many slower then reading complete strings in one step.

It is also possible to read in line by line and count the string length plus 2 bytes for crlf to a separate counter. I think, thats the right workaround at the moment for me.

Here we are in the wishlist section It is just a wish of me to implement a function like seek in VB.

B.t.w: I'm very surprised about this dev environnment. It is easy, fast and very small ( in a view to a dev Studio from Microsoft where you need DVDs to install it). Just after a quarter hour of testing, i purchased a version of b4ppc !
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading binary files jgm Questions & Help Needed 5 05-28-2008 11:09 AM
reading and editing registry Dr. Feelgood Questions & Help Needed 3 02-16-2008 08:18 AM
Problem beim Einlesen von Umlauten in Textfiles mclane German Forum 2 12-08-2007 06:18 PM
Reading MP3 ID3 tags, any ideas??? kronos79 Forum Discussion 2 11-10-2007 11:57 AM
Reading status of CTS Paul Questions & Help Needed 2 06-19-2007 09:34 AM


All times are GMT. The time now is 11:45 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0