Re: Help

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

EU>Hello,

EU>I am very very new to Euphoria and I am trying to make a simple program that
EU>opens a file and inputs it line by line and prints it to the screen line by
EU>line. I can open files and read and write to them but looping until eof I ha
EU>trouble with. I don't think there is an eof but I tried some things and I
EU>can't get it to work. So if you can post this simple program for me that wou
EU>be great. Also say I want someone to type in a filename and they type in
EU>c:\windows\temp.dat is there a function or do I have to make my own that
EU>converts that to c:\\windows\\temp.dat??

EU>Thanks for any help,
EU>Albert

object line     -- For the line input
integer f       -- For the file number
f = open(filename,"r")  -- Open the file
if f = -1 then -- Couldn't open
        puts(1,"Couldn't open " & filename)     -- Display error message
        abort(1)                                -- End program
end if
line = gets(f)          -- Get first line
while sequence(line) do -- While not eof (gets will return -1 at eof)
        puts(1,line)    -- Display it
        line = gets(f)  -- Get next line
end while
close(f)                -- Close the file

Just replace filename with the name of the file, and this will display
the file on the screeen.

Jeffrey Fielding
JJProg at cyberbury.net

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

Search



Quick Links

User menu

Not signed in.

Misc Menu