Article View: alt.lang.basic
Article #666Re: HELP!
From: Timm Korte
Date: Mon, 02 Dec 1996 00:00
Date: Mon, 02 Dec 1996 00:00
143 lines
4536 bytes
4536 bytes
Ross Hedvicek <naafetee@cyberstreet.net> wrote in article
<329f48b5.747169@news.cyberstreet.com>...
> I have a BIG problem, I have to make a chat program that will display
> the last
> *ten* quotes said by somebody, and erase the ones before that. It also
> gives
> the user the ability to input a line of his own. I know how to do this
> but my
> program keeps screwing up every time I run it. The first time I run
> it, it
> displays the contents of CHAT.ATX but then along the way if the user
> inputs a
> line of his own, the whole CHAT.ATX file is erased, how??? can anybody
> figure
> this out?? HELP ME!!!!!!!!!!!!!
>
> Ross Hedvicek Jr.
>
> The messed up code:
>
>
> start:
> CLS
> COLOR 7
> LOCATE 6, 5: PRINT "C - Chat"
> LOCATE 9, 5: PRINT "Q - Quit"
> LOCATE 11, 4: PRINT "Your Choice?"
> DO
> do$ = INKEY$
> LOOP WHILE do$ = ""
> IF do$ = "C" OR do$ = "c" THEN GOTO startchat
> IF do$ = "Q" OR do$ = "q" THEN END
> GOTO start
> '
> '
> '
> startchat:
> OPEN "CHAT.ATX" FOR INPUT AS #1
> CLS : COLOR 4
---- I think, this is messed up:
> FOR x = 1 TO EOF(1)
INPUT #1, name$, saywhat$
> COLOR 7: PRINT name$; " babbled this:"
> COLOR 4: PRINT saywhat$
> IF EOF(1) THEN EXIT FOR
> NEXT x
------------- try this insted (didn't test it) ---------
DO
COLOR 7: PRINT name$; "..."
COLOR 4: PRINT saywhat$
LOOP UNTIL EOF(1)
---------------------------------------------------------------
> CLOSE #1
> COLOR 7
> PRINT
> PRINT "Add anything? [Y/N]"
> startq:
> DO
> IN$ = INKEY$
> LOOP UNTIL NOT IN$ = ""
> IF IN$ = "Y" OR IN$ = "y" THEN GOTO addchat
> IF IN$ = "N" OR IN$ = "n" THEN GOTO start
> GOTO startq
> '
> '
> '
> addchat:
> PRINT "What do you want to add? (Max. length 70 characters)"
> INPUT ; "", add$
> add2chat$ = LEFT$(add$, 70)
> COLOR 4: PRINT : PRINT "Are you sure you want to say:": PRINT
> add2chat$
> PRINT : PRINT "[Y/N]"
> startdo:
> DO
> yn$ = INKEY$
> LOOP WHILE yn$ = ""
> IF yn$ = "Y" OR yn$ = "y" THEN GOTO add2chaty
> IF yn$ = "N" OR yn$ = "n" THEN GOTO startchat
> GOTO startdo
> '
> '
> '
> add2chaty:
> RESET
> OPEN "chat.atx" FOR INPUT AS #1
> lines# = 0
> DO
> LINE INPUT #1, line$
> lines# = lines# + 1
> LOOP UNTIL EOF(1)
> CLOSE #1
> OPEN "CHAT.ATX" FOR INPUT AS #1
> OPEN "CHAT.1" FOR OUTPUT AS #2
> left# = lines# - 9
> FOR x = 1 TO left#
> LINE INPUT #1, skip$
> NEXT x
> FOR x = 1 TO EOF(1)
> LINE INPUT #1, line$
> WRITE #2, line$
> NEXT x
> WRITE #2, yourname$, add2chat$
> CLOSE #1, #2
> '
> '
> OPEN "CHAT.1" FOR INPUT AS #1
> OPEN "CHAT.ATX" FOR OUTPUT AS #2
> FOR x = 1 TO 10
> LINE INPUT #1, line$
> WRITE #2, line$
> IF EOF(1) THEN EXIT FOR
> NEXT x
> CLOSE #2, #1
> KILL "CHAT.1"
> '
> GOTO start
>
>
I didn't check the rest of your prog, but i think the marked section is
your problem.
Why?
Your first statement there is:
FOR x = 1 TO EOF(1)
^^^^^^^^^^^^^^^^
When the compiler gets to this, he checks for EOF(1), which
is 0
(you are at the beginning at your file)
That gives:
FOR x = 1 TO 0
since there is nothing to count up from 1 to 0, the compiler skips the
whole
For - Next Loop - and doesn't print anything...
Just tyr the DO - LOOP loop that i wrote down... should work :)
So Long
bye
VoYaGe (Timm)
--- bigbird@psln.com ----
Technical Details
Message-ID:
<01bbe02d$800ff460$70259bce@xena>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<329f48b5.747169@news.cyberstreet.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c949,f791aa850657c9e7 X-Google-Attributes: gid10c949,public X-Google-Thread: f8e35,f791aa850657c9e7 X-Google-Attributes: gidf8e35,public X-Google-Thread: 137a74,f791aa850657c9e7 X-Google-Attributes: gid137a74,public X-Google-Thread: f78f1,f791aa850657c9e7 X-Google-Attributes: gidf78f1,public X-Google-Thread: f5300,f791aa850657c9e7 X-Google-Attributes: gidf5300,public X-Google-Thread: 10ab99,f791aa850657c9e7 X-Google-Attributes: gid10ab99,public X-Google-Thread: 112458,f791aa850657c9e7 X-Google-Attributes: gid112458,public X-Google-Thread: 100d42,f791aa850657c9e7 X-Google-Attributes: gid100d42,public From: "Timm Korte" <bigbird@psln.com> Subject: Re: HELP! Date: 1996/12/02 Message-ID: <01bbe02d$800ff460$70259bce@xena> X-Deja-AN: 201839566 references: <329f48b5.747169@news.cyberstreet.com> organization: West Coast Online's News Server - Not responsible for content newsgroups: alt.lang.basic,alt.lang.gfa-basic,comp.lang.basic.misc,fido.ger.basic,fj.lang.basic,microsoft.public.basic.dos,microsoft.public.basic.other,relcom.com.lang.basic