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
icedsun
Novice


Joined: 20 Jan 2006
Posts: 45
Location: Minnesota

PostPosted: Fri Feb 03, 2006 1:10 pm   

READ help...
 
Okay, I've got a .txt file that contains information similar to this:
Code:
Straight (9) win0 loss1 tie0
Trips (3 9 5) win0 loss1 tie0
Flush (A 9 8 5 2) win1 loss0 tie0

I want to read a line of text and input parts of it into different variables. Basically, I would put everything up until the ")" in variable VarA. Then the number after "win" would go into VarB, the number after "loss" would go in VarC, and the number after "tie" would go in VarD.
Ie: VarA = "Trips (3 9 5)" , VarB = "0", VarC = "1", VarD = "0". (This would be the case on the second line up there.

I'm not sure if there's an easy way to do this. I've been messing around with the %read command and still can't quite figure out how to handle this. Would I be better off making the program that outputs this txt file to just write 4 lines for each set, and then read the variables in line by line? Or is there a way I can avoid doing that. I'm guessing %grep will be needed but I can't seem to get grep to do what I want it to :) Any suggestions of where I should be headed will be appreciated. Thanks.
_________________
"Build a man a fire and he's warm for a night. Light a man on fire and he's warm for the rest of his life." --My Mom
Reply with quote
icedsun
Novice


Joined: 20 Jan 2006
Posts: 45
Location: Minnesota

PostPosted: Fri Feb 03, 2006 2:11 pm   
 
%match(%read(5,1),"(*) %w(%d) %w(%d) %w(%d)",VarA,VarB,VarC,VarD)

Yay! Figured it out!
_________________
"Build a man a fire and he's warm for a night. Light a man on fire and he's warm for the rest of his life." --My Mom
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