EOF

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

EOF

Post by izidor » Sun May 02, 2010 1:57 pm

When opening a file by typing "open" everything works, but it doesn't work with "print". Can anyone tell me why, it doesn't make any sense to me? :?

Code: Select all

DO
    INPUT a$
    IF a$ = "open" THEN
        INPUT "name:", filename$
        OPEN filename$ FOR INPUT AS #1
        DO WHILE NOT EOF(1)
            INPUT #1, files$
            PRINT files$
        LOOP
        CLOSE #1

    ELSEIF a$ = "print" THEN
        INPUT "name:", filename2$
        OPEN filename2$ FOR INPUT AS #2
        DO WHILE NOT EOF(1)
            INPUT #2, files2$
            PRINT files2$
        LOOP
        CLOSE #2

    END IF
LOOP

User avatar
bongomeno
Veteran
Posts: 231
Joined: Wed Dec 10, 2008 9:08 am
Location: San Bernardino CA
Contact:

Post by bongomeno » Sun May 02, 2010 7:14 pm

what are you trying to do? are you wanting to print to the file?
Home: http://www.geekbasic.com" target="_blank
Forum: http://www.geekbasic.com/index.gbws?$page=forumsmain" target="_blank
QB64 powered web server: http://www.geekbasic.com/index.gbws?$pa ... inter=%201" target="_blank

izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor » Mon May 03, 2010 2:58 pm

No, of course no. I am using that like print command in QB :lol:

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: EOF

Post by moneo » Mon May 03, 2010 4:48 pm

izidor wrote:When opening a file by typing "open" everything works, but it doesn't work with "print". Can anyone tell me why, it doesn't make any sense to me? :?

Code: Select all

DO
    INPUT a$
    IF a$ = "open" THEN
        INPUT "name:", filename$
        OPEN filename$ FOR INPUT AS #1
        DO WHILE NOT EOF(1)
            INPUT #1, files$
            PRINT files$
        LOOP
        CLOSE #1

    ELSEIF a$ = "print" THEN
        INPUT "name:", filename2$
        OPEN filename2$ FOR INPUT AS #2
        DO WHILE NOT EOF(1)
            INPUT #2, files2$
            PRINT files2$
        LOOP
        CLOSE #2

    END IF
LOOP
I think the problem is:
OPEN filename2$ FOR INPUT AS #2
DO WHILE NOT EOF(1)

The DO WHILE should be EOF(2)

Regards.

izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor » Tue May 04, 2010 4:13 am

Yeah that was the problem, thanks, I don't know what would I do if there weren't for this forum!

Post Reply