|
Bel Newbie
Joined: 20 Dec 2001 Posts: 5
|
Posted: Thu Dec 20, 2001 11:48 pm
Variable values from txt file? |
Is there anyway at all that i could fill a variable from a .txt file, or anything else similar? The number of values in the variable could be pretty high, and its easier to edit a txt file.
|
|
|
|
Troubadour GURU
Joined: 14 Oct 2000 Posts: 556 Location: USA
|
Posted: Fri Dec 21, 2001 12:25 am |
Yep, take a look at the %read function in the help files.
For example this script would read each line in a text file and add it to a string list.
#FILE 1 MyData.txt
#LOOP 1, %filesize(1) {#ADDITEM list %read(1, %i)}
#CLOSE 1
Troubadour |
|
|
|
PrestoPimp Apprentice
Joined: 18 Sep 2001 Posts: 175 Location: USA
|
Posted: Sat Dec 22, 2001 6:03 am |
I have this for the loading of the charname file..
#TR {*Alas ... you have entered the*} {#FILE 1 Charnames.txt
#LOOP 1, %filesize(1) {#ADDITEM namelist %read(1, %i)}
#CLOSE 1}
But it isnt loading the entire txt file into the variable.. just one name.. any ideas?
For tomarrow is another day, and other days come but 6 times a week. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Dec 23, 2001 1:15 am |
It might be the space after the comma. Actually, you could get the same result without including the 1.
#LOOP 1,%filesize(1) {#ADDITEM list %read(1, %i)}
or
#LOOP %filesize(1) {#ADDITEM list %read(1, %i)}
LightBulb |
|
|
|
|
|