Article View: alt.lang.basic
Article #667Re: HELP!
From: Deekoo L.
Date: Mon, 02 Dec 1996 00:00
Date: Mon, 02 Dec 1996 00:00
96 lines
3975 bytes
3975 bytes
In article <329f48b5.747169@news.cyberstreet.com>, naafetee@cyberstreet.net (Ross Hedvicek) wrote: > 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!!!!!!!!!!!!! -------------- Offending code: > 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 Try renaming the "line$", "lines#", and "left#" variables. LINE and LEFT are both reserved words - they do specific things in Basic. (Line is used in the LINE INPUT statement, and LEFT is found in LEFT$().). Every version of Basic I've used hiccups to some degree when one tries to use reserved words in variablenames... (The worst instance I ran into was QuickBasic - I named an array Exits$, and Quickbasic refused to quit until I renamed the array.) I was inspired (And bored), so I made a somewhat simpler chat core in APBasic: OPEN "I",1,"CHAT.ATX" DIM lin$(10) FOR x%=1 TO 10 LINE INPUT #1,lin$(x%) PRINT lin$(x%) NEXT x% PRINT "Do you want to say something? (y/N)" WHILE INSTAT=0 WEND ink$=UCASE$(INKEY$) IF ink$="Y" THEN INPUT "What's your name? ",name$ INPUT "Speak! ",speak$ CLOSE 1 OPEN "O",1,"CHAT.ATX" FOR x%= 2 TO 10 PRINT #1,lin$(x%) NEXT x% PRINT #1,names$+": "+speak$ END IF -- -------------------------------------++------------------------------ demi monde :: aka :: monde kontrolle || please suspend your disbelief monde@sirius.com ::::::::::::::::::::|| :: at the door... ::::::::::: the compound eye BBS: 415.333.5665 ::|| :: violators will be violated -------------------------------------++------------------------------ ::::::::::: defenestration: http://www.sirius.com/~monde :::::::::::: ---------------------------------------------------------------------
Technical Details
Message-ID:
<deekoo-ya023380000212960334170001@news.sirius.com>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: f78f1,f791aa850657c9e7 X-Google-Attributes: gidf78f1,public X-Google-Thread: 10ab99,f791aa850657c9e7 X-Google-Attributes: gid10ab99,public X-Google-Thread: 100d42,f791aa850657c9e7 X-Google-Attributes: gid100d42,public X-Google-Thread: 112458,f791aa850657c9e7 X-Google-Attributes: gid112458,public X-Google-Thread: f5300,f791aa850657c9e7 X-Google-Attributes: gidf5300,public X-Google-Thread: 137a74,f791aa850657c9e7 X-Google-Attributes: gid137a74,public From: deekoo@sfnet.com (Deekoo L.) Subject: Re: HELP! Date: 1996/12/02 Message-ID: <deekoo-ya023380000212960334170001@news.sirius.com> X-Deja-AN: 201856028 references: <329f48b5.747169@news.cyberstreet.com> content-type: text/plain; charset=ISO-8859-1 organization: The Compound Eye BBS: 415.333.5665 mime-version: 1.0 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