Readout actual fileposition

Discussion in 'Questions (Windows Mobile)' started by thedyg, Aug 6, 2007.

  1. thedyg

    thedyg Member Licensed User

    Hello all,

    is it possible to findout the actual fileposition ? I readout many datas with fileread. If i find a special string i need to refind this position later. So it is necessary to know the actual position.

    Any idea ?

    Thanks
    Thedy
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I think that you probably need to use the binary file to be able to do this.
    With the binary file you can use the position function.

    Regards,
    RandomCoder.
     
  3. Cableguy

    Cableguy Expert Licensed User

    I understand thedyg problem...

    It would be nice to be able to have a Readline(number) function....

    I'll add it to the wishlist...
     
  4. thedyg

    thedyg Member Licensed User

    Ok, thanks for all effort !

    Now, i reprogrammed the routine. I like to like to use a GPX file (XML file with geographical waypoints) as database with about 2000 waypoints inside. For faster find all waypoints i write a separate index file where i can find the startoffset of each waypoint in the GPX file.

    I wrote a loop reading in 30KB segments (with the FileGet command), analize it and write the founded startpoints with Binaryfile.dll directly to the new file. To find 2000 waypoints in a 14 MB XML file i need about 1 Minute on my iPaq. The old routine with FileGet needs for the same thing more then a quarter hour !!!

    When i start my appli the next time, i just have to readin the indexfile in a Array (will go some milliseconds) and my application is ready again. Now, i can use my programm also for 5000 or 10000 waypoints without any speedlost. Only the first startup for index building will go a little bit longer.
     
  5. hung

    hung Member Licensed User

    Use filegetbyte

    Not kind understand your problem but I have experience in handling same big data file problem when using other development language. Using index file is a good solution but it require the development language with random access capability.

    Here is the hints that may help.

    1. In the index file, you record the data position in terms of bytes for each GPS point, e.g. myhomegps starts at 1353203 byte

    2. As show in the help sample, use the following code to retrieve result from the big data file.

    FileOpen (c,"data.dat",cRandom)
    b = FileGetByte (c, 1353203) 'returns the 1353203 byte in the file.
    FileClose (c)

    Cheers!
     
  6. hung

    hung Member Licensed User

    And when the index file is huge it becomes problem in PPC since PPC has limited memory, then to save memory for other processs you should keep the index file as small as possible.
     
  7. thedyg

    thedyg Member Licensed User

    Hello Hung,

    thanks for your respond.

    as example to save the file position for 2000 Waypoint with an Int32 array, i need 8 KB of memory. This is a very small size i think and can be handled very easy. With the binaryfile.dll i can read or write the whole array from/to a file with one command.

    I like the appl. BeeLineGPS very well for geocaching, but this apply read in the whole GPX database. If i have 2000 waypoints, the appli need about 20 MB of system memory. With 2500 Waypoints the appli crashes during startup. This is the reason why i write my own Geocacher Application with extrem memorysave code as we have learned with older computers. Remember that a Commodore 64 works with 64kb overall RAM. Now we use 64KB to store 1 string in a text variable :)
     
  8. hung

    hung Member Licensed User

    Yeh, I remember those days and the 6502. Luckily we are still very very very very young at this moment.

    Cheers!:sign0188:
     
Loading...