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
sda
Wanderer


Joined: 18 Apr 2001
Posts: 55
Location: United Kingdom

PostPosted: Tue Jul 09, 2002 12:01 am   

Reading text data from file into variable
 
Howdy folks, I don't often post here but I now have a small issue...

Using 6.x, I can't work out how to read a list of names (one per line) from a text file into a string list/variable. I can't work out the form of the #READ command, and could you say,.... loop until EOF?

Thanks,
Steve :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jul 09, 2002 3:00 am   
 
Int that case you want to use the %read function.

Protcode follows:
#FILE 1 "textfile.txt"
#LOOP 1,%filesize(1) {#ADDITEM ListVariable {%read(1,0)}}
Reply with quote
sda
Wanderer


Joined: 18 Apr 2001
Posts: 55
Location: United Kingdom

PostPosted: Wed Jul 10, 2002 12:22 am   
 
Thankyou very much!
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Wed Jul 10, 2002 8:39 pm   
 
Or... if you want to do it all at one go:

#FILE 1 "textfile.txt"
#VAR ListVariable %grep(1, "%*")
#CLOSE 1


 - Charbal
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