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
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Mon Mar 03, 2003 12:44 pm   

help with using files in zmud
 
Im trying to figure out a way that I can import information into a database from an
external text file.. the info is seperated by a blank line

the help files are a bit vague on how to set something like this up
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Mar 03, 2003 1:21 pm   
 
You are a bit vague too, so the best info you can get until more details are provided is to use %read.

Kjata
Reply with quote
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Mon Mar 03, 2003 1:43 pm   
 
quote:

You are a bit vague too, so the best info you can get until more details are provided is to use %read.

Kjata



ya I just realized how vague that was

ok what I am trying to do is read in a txt file that has records stored
kinda like:

mob: Apollo
room: Residence
area: Olympus
Object 'a silver bow' is of type weapon.
Description: A silver bow.
Keywords 'bow silver'
Weight 15 lbs, Value 10300 silver, level is 47, Material is oldstyle.
Extra flags: invis magic anti-evil
Item is wielded as a weapon.
Weapon type is exotic.
Damage is 3d14 (average 22).
Weapons flags: two-handed
Object modifies damage roll by 1.
Object modifies hit roll by 1.

the records of the eq are seperated by a blank line

but what i need to know is how can I adapt my db script so that when I read in 1 line at a time it will update info from the txt file...or write a new entry

so I guess what Im asking is how do I use %read/#read to read in lines from the txt file
stop at a blank line and transfer the info into a database
Reply with quote
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Mon Mar 03, 2003 4:47 pm   
 
quote:

this might not be a solution, but i thought i would suggest it anyway. It depends on two assumptions: 1) this text file is in the same format as the output from the mud used by: 2) your working db script

if this is the case then you could do this

#file 1 "items.txt"
#loop {1, %filesize(1)} {#show %read(1,%i)}
#close 1

and let your db script fire on the #show output

to append output to the file, use the #log command (you can use #show to insert blank lines if necessary, i think) something like this should work:

#tr {^mob~:} {#log "items.txt"}
#cond {^$} {#show;#log}

--------

moon.icebound.net:9000



ok thas what I wanted to do...and yes it works...just have to play with it a bit

thanks
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Mon Mar 03, 2003 4:51 pm   
 
hehe, whoops. after adding my 2nd edit to that post, i got frustrated and deleted it, not noticing you had already replied! well, i'm glad it was helpful anyway, even though the original involved several logic gaps from me, namely:
1) it didn't appear you actually wanted to append to the file, but rather add a new entry to the database
2) the mob:, room:, and area: fields didn't seem to be normal mud output

anyway, good luck

--------

moon.icebound.net:9000
Reply with quote
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Mon Mar 03, 2003 5:39 pm   
 
ok new problem (sigh)

here is the part of the code

#FILE 1 "ident.txt"
#LOOP {1, %filesize( 1)} {
#VARIABLE item ""
#T+ ident2
#SHOW %read( 1, %i)
#T- ident2
}
#CLOSE 1

Ive run it and it displays the records in the file no prob..prob comes when
the db script fires
it adds empty records for each time it loops through the file
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Mar 03, 2003 8:16 pm   
 
We don't know what your db script is, so you are going to need to check what is going wrong. Seems like the @item variable is not being filled correctly for some reason.

Kjata
Reply with quote
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Tue Mar 04, 2003 3:25 am   
 
quote:

We don't know what your db script is, so you are going to need to check what is going wrong. Seems like the @item variable is not being filled correctly for some reason.

Kjata



well I still have several problems.....

if I use this or slight variations of this :

#file 1 "items.txt"
#loop {1, %filesize(1)} {#show %read(1,%i)}
#close 1

all it does is either run through the entire file and display it on the screen
or it gives me 1 line at a time, or if I use file 6 instead of file 1, I get partial records with lines missing from them.

2. my db script fires on $... and using the above it doesnt fire at all, but triggers I wrote to capture room:, mob:, and area: do work.

so in the end I end up with 3000-4000 blank entries in a database

nothing I try seems to catch a blank line which seperates the records in the data file

so Im totally lost
Reply with quote
kosh
Beginner


Joined: 24 Oct 2002
Posts: 14
Location: Canada

PostPosted: Tue Mar 04, 2003 4:01 am   
 
actually I figured it out

thanx for the help and pointers
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