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
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Sun Feb 16, 2003 9:58 pm   

reading from a file
 
quote:
READ

Syntax: #REA filename

#REA n [rec] _noexpand
#REA n [rec] [arguments]

Open the file given by filename and read it line by line, executing each line. This allows you to store commands in a script file and then execute this script. Typically the KILLALL command will be used to clear memory before reading the file.
The second form of this command reads data from the nth file (opened with the FILE command). If n is 1-5, then the file is a text file and rec is the line number to read. If rec is zero or omitted, the next sequential line is read. If n is 6-10, then the file is a structured file, and the record indicated by rec is read. If rec is zero or omitted, the next record is read.

When reading from a file, argument references such as %1 are normally expanded using the arguments given in the #READ command. If the third parameter is _noexpand, then the line from the file is executed without replacing arguments.

READ examples

#REA mud.txt

Read the file mud.txt line by line and execute each line as if you had typed it manually.

#FILE 1 mudlist.txt
#READ 1 10

read the 10th line from the file mudlist.txt


What i'm unclear about, is how to operate on the read data. I want to read a text file, and put all of its contents into a text variable. Never tried anything with this command before, and experimentation/helpfiles aren't yeilding any results :(

--------

moon.icebound.net:9000
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 17, 2003 12:13 am   
 
Check out the %read() function. It basically does the same as #READ, except that it shunts the output into a variable or into an expression instead of to the MUD.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Mon Feb 17, 2003 4:38 am   
 
hmm, the %read function doesn't appear to be working right. (see post in beta forum). What other ways are there to go about getting the information from a file? How is the #read command supposed to be used?

--------

moon.icebound.net:9000
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 17, 2003 4:57 am   
 
quote:

hmm, the %read function doesn't appear to be working right. (see post in beta forum). What other ways are there to go about getting the information from a file? How is the #read command supposed to be used?

--------

moon.icebound.net:9000



#READ is there to basically load up scripts into the settings file (hence the reference to #KILLALL, which destroys the currently-loaded settings file stuff) OR to send things to the mud--password keys like how Simutronics players used to do, responses to various prompts, etc. It all goes straight to its destination, so there's no way to intercept it and edit it on the fly. This is what %read() is for, but if it's broke then you're most likely out of luck.

li'l shmoe of Dragon's Gate MUD
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