none
End Of File - EOF another approach ? RRS feed

  • Question

  • First I need to thank Jan Turner to have posted a program to download a file in HEX ... and to have used LDFile.ReadbyteArray, from Litdev. Once more a command that I discovered. At the other side the situation here is just dramatic ...

    There are a lot of examples on how to detect the EOF, so this one is probably just another one. I thought the approach is somewhat different ??? and probably can be optimized with other commands to speed it up ??? 4000 lines take some 20 seconds ...

    I was using a GPX file (I am still in contact with the students and try to motivate them to work and plan some walks in summer). I saved the file as JTZ835  – name of the file “Egide-Small.gpx” to edit the file with a gpx-editor such as mapsource or basecamp …  with small basic the extend will probably be changed as  .sb

    The program is PLZ988 name of the File "EOF-EA.sb" and you have to uncomment some lines that have been automatically commented and you have to save the program to get the correct program directory...

    MyFILE=Program.Directory+"\egide-small.gpx" 
    Fi=Program.Directory+"\Testcopy.sb
    file.deletefile(Fi)
    Numb=Text.GetLength(LDFile.ReadbyteArray(MyFile,"true"))
    EOF=1
    while NumbFi<numb 
      File.WriteLine(Fi,EOF,File.ReadLine(MyFile,EOF)) 
      NumbFi = Text.GetLength(LDFile.ReadbyteArray(Fi,"true"))
      EOF=EOF+1
      'TextWindow.writeline (EOF)
    endwhile
      EOF=EOF-1
    TextWindow.writeline ("EOF =====> "+ EOF)
    TextWindow.writeline ("Line "+EOF+"=====> "+ File.ReadLine(MyFile,EOF))

    The output is 

    EOF =====> 394
    Line 394 =====> </gpx>
    Press any key to continue...

    To follow the program you can insert in the while loop something as 

    if Math.Remainder(EOF,100)=0 then
        textwindow.WriteLine(EOF)
    endif
    and you can adapt the counter putting in place in stead of 100 some bigger number





     



    • Edited by Eddy Abts Saturday, March 28, 2020 9:18 AM
    Saturday, March 28, 2020 8:52 AM

Answers

All replies

  • Hi Eddy Abts, LDFile.Length(fileName) will return the number of lines in the file.

    Nonki Takahashi

    Saturday, March 28, 2020 12:21 PM
    Moderator
  • Hi Eddy Abts,

    Here is a thread posted in 2009."EOF?" Is it what you need?

    Best Regards!

    Saturday, March 28, 2020 12:47 PM
  •  name of the file “Egide-Small.gpx” to edit the file with a gpx-editor such as mapsource or basecamp …  with small basic the extend will probably be changed as  .sb

    SB  will not let you save a file in the IDE  as Egide-Small.gpx  The way I do it is: save as Egide-Small. It gets the extension .sb. The click "open" click with right on the file and choose "change name".Then you can change the extension to .gpx  (and ignore the warning ;-) )


    Jan [ WhTurner ] The Netherlands


    Saturday, March 28, 2020 2:13 PM
    Answerer
  • We analyzed the marvelous program to dump a file in Hex written by Jan some days ago, making me confident with the old MSDOS-feeling. Some weeks ago we had a look to the “EOF” thread posted in 2009 with examples from litdev. So the idea was just to try “ANOTHER APPROACH” we are using to analyze “error files” ending with thousands of empty or corrupted lines. We know about the ldfileLength … but mainly the topic was to try a program with the  LDFile.ReadbyteArray we discovered in the HexDump example of Jan. 

    Normally we try to edit the GPX files in one or another editor and remove manually the empty lines. Otherwise we scan the program to find several empty lines and verify the last time stamps  as in the EOF-thread. Some of us, all friends of Mr Alzheimer, are confident with the powerfull technical HP basic and the rocky mountain basic, used in test- and labo environments, printer and plotter instructions, using mathematical algorithms but don’t have any experience with animation and window environment. Most of the time the syntax is the main problem. The classes at the university have been stopped due to the coronavirus and we hope to be able to start again in October but we are all part of the high risk groups. 

    It is obviously the exercises and walks outside that interest them, so I wonder how many will want to resume the theoretical preparation next academic year. 

    Saturday, March 28, 2020 7:16 PM