Announcement

Collapse
No announcement yet.

Reading a File Into a Variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading a File Into a Variable

    After an absence from PBCC for a few years, I am wanting to get back at it. I have a small project that I want to undertake which involves a flat ASCII file, which sometimes contains CR, CR/LF or just huge, long lines. The file sizes can range from about 200Kb up to over 2Mb.

    To get useful information out of the data, I really need to clean it up. I was hoping to bring the complete file into a single large variable and from there, remove/parse/amend the data.

    In the past, I have used Sequential files a little, but by no means would I say I was an expert. For this project, I think I want to use a Random file, reading in all the data (2Mb worth) in one pass in to a single variable. From there, I would use MID$, among others to cleanse the data.

    So.. My question. Could I get some guidance on reading the file into one large variable – not picky if it is a Sequential or Random file, I just need to get the data in. From there. I will parse out most of the information and write back out a Sequential file.

    Thanks,

    John

  • #2
    you could use something like this

    OPEN "Filename" FOR BINARY ACCESS READ LOCK SHARED AS #1
    GET$ #1, LOF(1), WholeFile$ 'read entire string
    CLOSE #1

    Comment


    • #3
      Easy

      Ralph,

      Yep.. You got it right off the bat. I had no idea it could be so simple!

      Thanks very much for your assistance.

      John

      Comment

      Working...
      X