From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f3ad228831281c35 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-08 07:39:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc04.POSTED!not-for-mail From: Mark Biggar User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: getting words from file References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%8oaa.11967$F1.92@sccrnsc04> NNTP-Posting-Host: 12.235.88.213 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc04 1047137979 12.235.88.213 (Sat, 08 Mar 2003 15:39:39 GMT) NNTP-Posting-Date: Sat, 08 Mar 2003 15:39:39 GMT Organization: AT&T Broadband Date: Sat, 08 Mar 2003 15:39:39 GMT Xref: archiver1.google.com comp.lang.ada:35066 Date: 2003-03-08T15:39:39+00:00 List-Id: cookie wrote: > Does anyone know how I would store a word in a specific variable after > a space occurs inside a textfile? (say there was a line in the > textfile like this: one two three four five... I'd want it to get > these words and store it in an already defined var like varOne varTwo > and so on. > > This is the idea I was playing with to get the actual word (scans > through the characters until it hits a space and tries to merge all of > those characters into a word): http://www.guff.org/ada.txt ..or am I > way off? First you probably want an array of words not singlton variables. There are two other main considerations needed for this problem. The first is that as the words in the file are variable length, besides the actual characters of each word you will also need to store its length (or equivalent) somewhere. The second is related to the first: how are you going to handle a word that is larger then you expect? The last time I had to solve a similar problem I didn't store the words in the variables at all. I read the whole file into one big string and then kept an array of records that recorded the start and end position of each word into that large string. I then used slicing to extract the actual characters as needed. -- Mark Biggar mark.a.biggar@attbi.com