Re: Liberty Basic

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

>Hi
>The problem I think is that in basic it is easy to get an array set up
>in euphoria it is not.What I want to do is this
>my data file looks like this

>How old are you?
>37
>What time of day is it?
>2pm

>In basic I would do this like

>open "l1.dat" for input as #1
>for t=1 to 2
>input #1,a$ 'read in data
>a1$(t)=a$ ' put in to array
>input #1,q$
>q1$(t)=q$
>next t
>close #1

Euphoria translation:


object junk

integer fn
sequence question, answer

question = {}
answer = {}

fn = open("l1.dat", "r")   -- Open as read only
for t = 1 to 2 do
    junk = gets(fn)        -- Read in data
    if sequence(junk) then -- Data ok?
        question = question & {junk[1..length(junk)-1]}   -- Put into
array
    end if
    junk = gets(fn)        -- Read in data
    if sequence(junk) then -- Data ok?
        answer = answer & {junk[1..length(junk)-1]}   -- Be sure to strip
\n
    end if
end for
close(fn)


Oh, and this snippit doens't reverse the q and a strings (It puts the
questions into question unlike the BASIC version which puts the question
into a$... ;)

It may look a little more complex, but that's due to checking for EOF and
such, but I didn't check to see if the file exists. I think that the
Euphoria version is easier to understand, too. Just have to be familiar
with it.

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu