Re: Data File

new topic     » goto parent     » topic index » view thread      » older message » newer message

At 07:56 PM 4/23/98 -0600, you wrote:
>---------------------- Information from the mail header -----------------------
>Sender:       Euphoria Programming for MS-DOS <EUPHORIA at
>MIAMIU.ACS.MUOHIO.EDU>
>Poster:       David P Mosley <david08 at JUNO.COM>
>Subject:      Data File
>-------------------------------------------------------------------------------
>
>Hi
>I have been trying to do a data file in euphoria for a quiz game that I
>am doing and I am a little stuck on this one.Ok here it is I have a
>file(data) like this
>How old are you?
>37
>What time of day is it.
>2:00pm
>1question 2 answer
>when I read in the file I get 1 long seq like this
>H,o,w, ,o,l,d, ,etc.
>what I need is this
>({{How old are you?},{What time of day is it.}})
>({{37},{2:00pm}})
>what I want to do is read it into a array then I can get the questions
>out when I need to and the answers also.
>Hope this makes sence

You have a file with alternating questions and answers?
Here's how to read them in from a text file:

object input, question, answer
       question = {}
       answer = {}

atom fn

fn = open("QUESTION.DAT","r")

while 1 do -- load the data
  input = gets(fn)  -- read the question
  if atom(input) then exit -- end of file
  else question = append(question,input)
  end if
  input = gets(fn) -- read the answer
  if atom(input) then exit -- eof
  else answer = append(answer,input)
  end if
end while

close(fn)

-- now you can print question[n] and matching answer[n]
-- or compare them, etc.
Spam Haiku:-------------------
Silent, former pig
One communal awareness
Myriad pink bricks
-------------------------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu