|
TerrellKl Novice
Joined: 30 Aug 2005 Posts: 49
|
Posted: Wed Jan 04, 2006 1:11 am
reading from a text file |
I made a trivia script
I have a txt file full of trivia questions and answer but i'm not sure how to extract the questions/answers
How was your day?*awesome
is the format that the trivia questions are in
is there a way to randomly select a line, set a question variable to what comes before the * and a answer variable to everything after the *?
thank you for your time
I need an opposite of concat really..
to split the line into How was your day? and awesome
Help please |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Wed Jan 04, 2006 1:59 am |
#FILE 1 trivia_text_file_name_in_your_zmud_directory.txt
#VAR A_Question %read(1,%random(1,%filesize(1))
#VAR A_Answer %copy(@A_Question,%pos("*",@A_Question)+1,%len(@A_question))
#VAR A_Question %copy(@A_Question,1,%pos("*",@A_Question)-1)
say @A_Question
say @A_Answer
Something like that should work. This solution has no memory of questions asked though. |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Jan 04, 2006 2:51 am |
You're looking for %word()
Code: |
#file 1 "yourfile.txt"
question=%word(%read(1,@line),1,"*")
answer=%word(%read(1,@line),2,"*")
|
|
|
|
|
TerrellKl Novice
Joined: 30 Aug 2005 Posts: 49
|
Posted: Wed Jan 04, 2006 5:15 am |
got it to work thx gamma
you also helped tondiening but gamma_rays way is easier for me |
|
|
|
|
|
|
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
|
|