I've been trying to get this right for about 3 hours straight now, and i just can't figure out how to get this code to work...I know what needs to be happening, but i can't find the right command.
I need to write 3 or more player's input numbers into a file, and at the same time, write the program's randomly generated number into a second file. After theyre written, i need them to be read back into the program and printed on the screen.
I have the code doing everything EXCEPT appending the numbers to the same line. Theyre appending like this:
1
2
3
They need to be doing this:
1 2 3
Anyways, here's the program (might need to change the location of the answer files...oh, and the answer files need to be deleted every time the program is run, or it will keep "appending" the numbers (any help on how to clear it after theyre inputed would be cool too lol))
Code: Select all
RANDOMIZE TIMER
Win = 0:Lost = 0
REM ------------------------------------------------------------------
OPEN "C:\mydocu~1\Answer1.txt" FOR APPEND AS #1
OPEN "C:\mydocu~1\Answer2.txt" FOR APPEND AS #2
Top:
LOCATE 3,4:COLOR 14:PRINT "WON = ";Win
LOCATE 4,4:COLOR 14:PRINT "LOST = ";Lost
LOCATE 6,9:COLOR 9:PRINT "123 Number 456 Game 789"
LOCATE 7,5:COLOR 3:PRINT "Guess A Number Between 1 and 10"
LOCATE 8,5:COLOR 3:PRINT "Guess Right 3 Times and YOU WIN"
IF Win = 3 THEN GOTO Win2
IF Lost = 3 THEN GOTO Lost2
Answer = INT(RND * 10) + 1
LOCATE 12,4:COLOR 9:INPUT Guess%
WRITE #1, Guess%
WRITE #2, Answer
IF Guess% = Answer THEN GOTO Win1
IF Guess% <> Answer THEN GOTO Lost1
REM ------------------------------------------------------------------
Win1:
LOCATE 10,4:COLOR 14:PRINT "YES! The Number Is "; Answer; "!!!"
Win = Win + 1
SLEEP 3:GOTO Top
REM ------------------------------------------------------------------
Lost1:
LOCATE 10,4:COLOR 4:PRINT "NO! The Number Was "; Answer; "!!!"
Lost = Lost + 1
SLEEP 3:GOTO Top
REM ------------------------------------------------------------------
Win2:
CLS:Win = 0:Lost = 0
LOCATE 3,4:COLOR 3:PRINT "YOU ARE THE CHAMPION!!!"
SLEEP 3
LOCATE 5,4:COLOR 7:PRINT "Play Again? Y/N"
LOCATE 6,4:INPUT pa$
IF UCASE$(pa$) = "Y" THEN GOTO top ELSE END
REM ------------------------------------------------------------------
Lost2:
CLOSE #1:CLOSE #2
CLS:Win = 0:Lost = 0
LOCATE 3,4:COLOR 3:PRINT "YOU LOST TOO MANY TIMES..."
SLEEP 3
LOCATE 5,4:COLOR 7:PRINT "Your INPUT Answers Were..."
OPEN "C:\mydocu~1\Answer1.txt" FOR INPUT AS #1
LOCATE 6,4:COLOR 4
LINE INPUT #1, A1$
PRINT A1$
CLOSE #1
LOCATE 8,4:COLOR 7:PRINT "The Right Answers Were..."
OPEN "C:\mydocu~1\Answer2.txt" FOR INPUT AS #2
LOCATE 9,4:COLOR 14
LINE INPUT #2, A2$
PRINT A2$
CLOSE #2
LOCATE 11,4:COLOR 7:PRINT "Play Again? Y/N"
LOCATE 12,4:INPUT pa$
IF UCASE$(pa$) = "Y" THEN GOTO top ELSE END