Loading ...
Sorry, an error occurred while loading the content.
 

AW: [libertybasic] reading large files

Expand Messages
  • pendl2megabit
    Hi, read the whole file into a string variable and use instr() to locate the word.open myFile$ for input as #file theContents$ = input$(#file,
    Message 1 of 7 , Nov 2, 2005
      Hi,
      read the whole file into a string variable and use instr() to locate the
      word.

      open myFile$ for input as #file
      theContents$ = input$(#file, lof(#file))
      close #file

      --
      Stefan Pendl


      > -----Ursprüngliche Nachricht-----
      > Von: libertybasic@yahoogroups.com
      >
      > Is there a way in LB to take a text file consisting of about 175,000
      > words and make it into some format so that a work could be quickly
      > found? It could be broken up into smaller files.
      >
      > Thanks in advance :P






      ___________________________________________________________
      Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
    • Storm Dragon
      If the file is really large, wouldn t a single string run out of room? To avoid this, if it is the case, couldn t you use an array of strings for the file?
      Message 2 of 7 , Nov 2, 2005
        If the file is really large, wouldn't a single string run out of room? To
        avoid this, if it is the case, couldn't you use an array of strings for the
        file?
        Example:
        dim fileStream$(99)
        i = 0
        open fileName$ for input as #1
        do
        input #a, wordStream(i)
        if len(wordStream(i)) > 10000 then
        i = i + 1
        end if
        loop until i >= 99
        close #1

        'Then use a for loop to search for the word.
        From: "pendl2megabit" <pendl2megabit@...>
        To: <libertybasic@yahoogroups.com>
        Sent: Wednesday, November 02, 2005 4:38 PM
        Subject: AW: [libertybasic] reading large files


        > Hi,
        > read the whole file into a string variable and use instr() to locate the
        > word.
        >
        > open myFile$ for input as #file
        > theContents$ = input$(#file, lof(#file))
        > close #file
        >
        > --
        > Stefan Pendl
        >
        >
        >> -----Ursprüngliche Nachricht-----
        >> Von: libertybasic@yahoogroups.com
        >>
        >> Is there a way in LB to take a text file consisting of about 175,000
        >> words and make it into some format so that a work could be quickly
        >> found? It could be broken up into smaller files.
        >>
        >> Thanks in advance :P
        >
        >
        >
        >
        >
        >
        > ___________________________________________________________
        > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
        > anmelden: http://mail.yahoo.de
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
      • JanetTerra
        There was a time when a string could hold a maximum of 255 (or maybe 256, I always get confused with counting the 0 or not) characters. Now the maximum number
        Message 3 of 7 , Nov 2, 2005
          There was a time when a string could hold a maximum of 255 (or maybe
          256, I always get confused with counting the 0 or not) characters.
          Now the maximum number of characters for a string tops 2 million.
          Someone actually tested this about a year ago. I don't remember the
          exact figure. I do remember it exceeded 2 million. You will be
          surprised at how quickly searching a very long string (Word List)
          with INSTR works. If you'd like example code, Liberty BASIC
          Newsletters has an article that searches a string for a word, then
          makes all possible anagrams of that word, only keeping the anagrammed
          words that were actually found in the Word List. In this way, name
          is a valid anagram of mean, but anme is not and would be rejected.
          The link to that article is
          [url]http://babek.info/libertybasicfiles/lbnews/nl124/wordgames.htm
          [/url]. You'll need to download the file archive if you want to run
          the code. The word list is included in the file archive as well.
          Janet


          --- In libertybasic@yahoogroups.com, "Storm Dragon"
          <storm_dragon@c...> wrote:
          >
          > If the file is really large, wouldn't a single string run out of
          room? To
          > avoid this, if it is the case, couldn't you use an array of strings
          for the
          > file?
          > Example:
          > dim fileStream$(99)
          > i = 0
          > open fileName$ for input as #1
          > do
          > input #a, wordStream(i)
          > if len(wordStream(i)) > 10000 then
          > i = i + 1
          > end if
          > loop until i >= 99
          > close #1
          >
          > 'Then use a for loop to search for the word.
          > From: "pendl2megabit" <pendl2megabit@y...>
          > To: <libertybasic@yahoogroups.com>
          > Sent: Wednesday, November 02, 2005 4:38 PM
          > Subject: AW: [libertybasic] reading large files
          >
          >
          > > Hi,
          > > read the whole file into a string variable and use instr() to
          locate the
          > > word.
          > >
          > > open myFile$ for input as #file
          > > theContents$ = input$(#file, lof(#file))
          > > close #file
          > >
          > > --
          > > Stefan Pendl
          > >
          > >
          > >> -----Ursprüngliche Nachricht-----
          > >> Von: libertybasic@yahoogroups.com
          > >>
          > >> Is there a way in LB to take a text file consisting of about
          175,000
          > >> words and make it into some format so that a work could be
          quickly
          > >> found? It could be broken up into smaller files.
          > >>
          > >> Thanks in advance :P
          > >
          > >
          > >
          > >
          > >
          > >
          > > ___________________________________________________________
          > > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos -
          Hier
          > > anmelden: http://mail.yahoo.de
          > >
          > >
          > >
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          >
        • pendl2megabit
          Here is some code to check the maximum string length. The result might be related to the Windows version you run this on.---code start on error goto
          Message 4 of 7 , Nov 3, 2005
            Here is some code to check the maximum string length.
            The result might be related to the Windows version you run this on.

            '---code start
            on error goto [errorhandler]

            increment = 10

            print "Incrementing by "; increment

            while 1
            string$ = space$(2 ^ exponent)
            exponent = exponent + increment
            wend

            [errorhandler]
            select case
            case increment > 1
            exponent = exponent - increment
            increment = increment / 10

            print "Incrementing by "; increment
            resume
            case else
            exponent = exponent - increment
            print
            print "A string can hold up to 2 ^ "; exponent; " = "; 2 ^
            exponent; " characters!"
            print
            input "Hit ENTER to EXIT ... "; cr
            end select
            end
            '---code end

            ---
            Stefan Pendl


            > -----Ursprüngliche Nachricht-----
            > Von: libertybasic@yahoogroups.com
            >
            > There was a time when a string could hold a maximum of 255 (or maybe
            > 256, I always get confused with counting the 0 or not) characters.
            > Now the maximum number of characters for a string tops 2 million.
            > Someone actually tested this about a year ago. I don't remember the
            > exact figure. I do remember it exceeded 2 million. You will be
            > surprised at how quickly searching a very long string (Word List)
            > with INSTR works. If you'd like example code, Liberty BASIC
            > Newsletters has an article that searches a string for a word, then
            > makes all possible anagrams of that word, only keeping the anagrammed
            > words that were actually found in the Word List. In this way, name
            > is a valid anagram of mean, but anme is not and would be rejected.
            > The link to that article is
            > http://babek.info/libertybasicfiles/lbnews/nl124/wordgames.htm
            > . You'll need to download the file archive if you want to run
            > the code. The word list is included in the file archive as well.
            > Janet






            ___________________________________________________________
            Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
          • Allan
            You are a very bright young lady. but to answer your question. 0 is an even whole number, and believe it or not all number systems require it to be a valid
            Message 5 of 7 , Nov 3, 2005
              You are a very bright young lady. but to answer your question.
              0 is an even whole number, and believe it or not all number systems require it to be a valid number.
              ooooO
              ( ) Allan
              \ (
              (__)
              Better to be thought a fool,
              than open my mouth and remove all doubt

              ----- Original Message -----
              From: JanetTerra
              To: libertybasic@yahoogroups.com
              Sent: Thursday, November 03, 2005 8:26 AM
              Subject: [libertybasic] Re: reading large files



              There was a time when a string could hold a maximum of 255 (or maybe
              256, I always get confused with counting the 0 or not) characters.


              [Non-text portions of this message have been removed]
            • p s
              Thank you all who replied! The method below works very very well. In fact, it could find a word at the end of the file in a matter of seconds!!! Also, the
              Message 6 of 7 , Nov 4, 2005
                Thank you all who replied!

                The method below works very very well. In fact, it
                could find a word at the end of the file in a matter
                of seconds!!!

                Also, the string size did not matter. I figured out
                that my computer can support strings up to something
                like 16 million characters in length.

                Again, thanks much!

                --- pendl2megabit <pendl2megabit@...> wrote:

                > Hi,
                > read the whole file into a string variable and use
                > instr() to locate the
                > word.
                >
                > open myFile$ for input as #file
                > theContents$ = input$(#file, lof(#file))
                > close #file
                >
                > --
                > Stefan Pendl
                >
                >
                > > -----Ursprüngliche Nachricht-----
                > > Von: libertybasic@yahoogroups.com
                > >
                > > Is there a way in LB to take a text file
                > consisting of about 175,000
                > > words and make it into some format so that a work
                > could be quickly
                > > found? It could be broken up into smaller files.
                > >
                > > Thanks in advance :P
                >
                >
                >
                >
                >
                >
                >
                ___________________________________________________________
                >
                > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher
                > kostenlos - Hier anmelden: http://mail.yahoo.de
                >




                __________________________________
                Yahoo! FareChase: Search multiple travel sites in one click.
                http://farechase.yahoo.com
              Your message has been successfully submitted and would be delivered to recipients shortly.