Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

(No subject)Date: Mon, 15 Oct 2001 16:17:22 -0400

 [1/3] from: pwoodward::cncdsl::com at: 15-Oct-2001 13:22


Hi - you might try the following snippet for reading values on a line in a file... linefile: read/lines %lines.txt foreach line linefile [ print line ] Replace "print line" with with whatever you want to use, line should have the value you want to use for whatever. - Porter ----- Original Message ----- From: "mechtn" <[mechtn--tkweb--net]> To: <[rebol-list--rebol--com]> Sent: Monday, October 15, 2001 1:54 PM Subject: [REBOL]
> Can anyone tell me how I would make this program read each line from
test.txt and make them a variable. For instance if test.txt had the following values on each line.
> o40_1955 > o40_1996 > o40_1997 > o40_1998 > > How could I make the read/lines put that into a variable. Like just keep
reading and making new variables till it hits the end of the file or 30 variables whichever comes first. Thanks guys for all your help!

 [2/3] from: jelinem1::nationwide::com at: 15-Oct-2001 15:24

Re: Converting lines of a file to variables


Read/lines won't do this AFAIK. You will have to loop through the lines of the file, one way or another. Here's one way: block-o-lines: read/lines %test.txt foreach line block-o-lines [ this-word: to-word line set this-word none print rejoin ["Word: '" this-word " set to NONE"] ] - Michael Jelinek mechtn <[mechtn--tkweb--net]> Sent by: [rebol-bounce--rebol--com] 10/15/01 12:54 PM Please respond to rebol-list T To: <[rebol-list--rebol--com]> cc: bcc: Subject: [REBOL] Can anyone tell me how I would make this program read each line from test.txt and make them a variable. For instance if test.txt had the following values on each line. o40_1955 o40_1996 o40_1997 o40_1998 How could I make the read/lines put that into a variable. Like just keep reading and making new variables till it hits the end of the file or 30 variables whichever comes first. Thanks guys for all your help! rebol [ Title: "Read lines from txt file" Author: "Koie Smith" Date: 15-Oct-2001 File: %koie1.r Purpose: { Read lines from a txt file and set them as variables. } ] print read/lines %/c/rebol/test.txt halt

 [3/3] from: greggirwin::mindspring::com at: 15-Oct-2001 14:04

Re: (No subject)Date: Mon, 15 Oct 2001 15:09:23 -0600


<< Can anyone tell me how I would make this program read each line from test.txt and make them a variable. For instance if test.txt had the following values on each line. >> The easiest way is just to put them in a block: data: read/lines %/c/rebol/test.txt Now data will be a block of items where each item is a line from the file. Will that work for you? --Gregg