Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Bel
Newbie


Joined: 20 Dec 2001
Posts: 5

PostPosted: 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.
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: 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
Reply with quote
PrestoPimp
Apprentice


Joined: 18 Sep 2001
Posts: 175
Location: USA

PostPosted: 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.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net