qb I.m. OPEN PROBLEM
qb I.m. OPEN PROBLEM
(OP)
Ok so ive made this q basic instant messenger for my school, hah im only a junior, lol. and if you copy it and paste it onto a word pad and save it as a .bas file you can run it. its pretty simple but after a few messages have been sent, it stops the program and says cannot execute or something can i get some help on this part. oh and to talk between two qbasic windows open it up twice and login as two different people.
DECLARE SUB tu ()
DECLARE SUB online ()
DECLARE SUB im (name$)
DECLARE SUB nu ()
DECLARE SUB login (name$)
DO
CLS
RESTORE names
LOCATE 1, 36
PRINT "QBIM"
PRINT
LOCATE 3, 10
PRINT "x = exit h = help"
PRINT
PRINT
LOCATE 6, 16
PRINT "1. login"
LOCATE 7, 16
PRINT "2. People on"
LOCATE 8, 16
PRINT "3. New profile"
LOCATE 9, 16
PRINT
PRINT
LOCATE 10, 16
INPUT " Please type in the number of what you want to do"; d$
IF d$ = "3" THEN
CLS
CALL nu
ELSEIF d$ = "1" THEN
CALL login(name$)
ELSEIF d$ = "2" THEN
PRINT
READ on$
DO
OPEN on$ + ".txt" FOR INPUT AS #1
INPUT #1, name$
INPUT #1, no$
INPUT #1, no$
INPUT #1, o
CLOSE #1
IF o = 1 THEN
COLOR 18, 0
PRINT name$; " On ";
COLOR 7, 0
ELSEIF o = 0 THEN
PRINT name$; " off ";
END IF
READ on$
LOOP UNTIL on$ = "xxx"
DO
LOOP WHILE INKEY$ = ""
ELSEIF d$ = "x" THEN
END
ELSE
PRINT " Type in a valid character"
PRINT
PRINT " Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
END IF
LOOP WHILE 1 = 1
names:
DATA Dustin
DATA Korey
DATA Tucker
DATA Tyler
DATA Kayhil
DATA xxx
SUB im (name$)
OPEN name$ + ".txt" FOR INPUT AS #1
INPUT #1, name$
INPUT #1, pass$
INPUT #1, t$
INPUT #1, o
CLOSE #1
CLS
DO
LOCATE 1, 36
PRINT name$; " QBIM"
LOCATE 12, 5
PRINT "1. Talk "
PRINT
LOCATE 14, 5
PRINT "2. Logout"
PRINT
INPUT " Type in the character of your selection"; s$
IF s$ = "1" THEN
CLS
PRINT " The name must be exactly as show in main menu."
PRINT
INPUT " The name of the person you wish to talk to"; talk$
CLS
REM **************** reply/// send message *********************
DO
INPUT "Reply"; t2$
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t2$
WRITE #1, 1
CLOSE #1
REM **************** Recieve message **************************
check:
OPEN talk$ + ".txt" FOR INPUT AS #1
INPUT #1, name1$
INPUT #1, no$
INPUT #1, t1$
INPUT #1, o
CLOSE #1
tc1$ = t1$
IF tp$ = tc1$ THEN
GOTO check
ELSE
PRINT name1$; ": "; t1$
PRINT
tp$ = t1$
END IF
LOOP WHILE INKEY$ <> "q"
ELSEIF s$ = "2" THEN
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, 0
CLOSE #1
GOTO logout
END IF
LOOP WHILE 1 = 1
logout:
END SUB
SUB login (name$)
INPUT " Your user name"; un$
login2$ = un$ + ".txt"
OPEN login2$ FOR INPUT AS #1
INPUT #1, name$
INPUT #1, pass$
CLOSE #1
IF un$ = name$ THEN
PRINT
PRINT " Welcome "; name$
PRINT
pass:
INPUT " Password"; p$
IF p$ = pass$ THEN
PRINT " You are now logged on"
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, 1
CLOSE #1
PRINT
PRINT " Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
ELSE
GOTO pass
END IF
END IF
CALL im(name$)
END SUB
SUB nu
INPUT " Your name that you wish to use"; name$
PRINT
redo:
INPUT " Your password that you wish to use"; pass$
PRINT
INPUT " Confirm your password"; passc$
IF pass$ = passc$ THEN
user$ = name$ + ".txt"
OPEN user$ FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, o
CLOSE #1
ELSE
GOTO redo
END IF
PRINT
PRINT "Thank you for registering"
PRINT
PRINT "Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
END SUB
DECLARE SUB tu ()
DECLARE SUB online ()
DECLARE SUB im (name$)
DECLARE SUB nu ()
DECLARE SUB login (name$)
DO
CLS
RESTORE names
LOCATE 1, 36
PRINT "QBIM"
LOCATE 3, 10
PRINT "x = exit h = help"
LOCATE 6, 16
PRINT "1. login"
LOCATE 7, 16
PRINT "2. People on"
LOCATE 8, 16
PRINT "3. New profile"
LOCATE 9, 16
LOCATE 10, 16
INPUT " Please type in the number of what you want to do"; d$
IF d$ = "3" THEN
CLS
CALL nu
ELSEIF d$ = "1" THEN
CALL login(name$)
ELSEIF d$ = "2" THEN
READ on$
DO
OPEN on$ + ".txt" FOR INPUT AS #1
INPUT #1, name$
INPUT #1, no$
INPUT #1, no$
INPUT #1, o
CLOSE #1
IF o = 1 THEN
COLOR 18, 0
PRINT name$; " On ";
COLOR 7, 0
ELSEIF o = 0 THEN
PRINT name$; " off ";
END IF
READ on$
LOOP UNTIL on$ = "xxx"
DO
LOOP WHILE INKEY$ = ""
ELSEIF d$ = "x" THEN
END
ELSE
PRINT " Type in a valid character"
PRINT " Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
END IF
LOOP WHILE 1 = 1
names:
DATA Dustin
DATA Korey
DATA Tucker
DATA Tyler
DATA Kayhil
DATA xxx
SUB im (name$)
OPEN name$ + ".txt" FOR INPUT AS #1
INPUT #1, name$
INPUT #1, pass$
INPUT #1, t$
INPUT #1, o
CLOSE #1
CLS
DO
LOCATE 1, 36
PRINT name$; " QBIM"
LOCATE 12, 5
PRINT "1. Talk "
LOCATE 14, 5
PRINT "2. Logout"
INPUT " Type in the character of your selection"; s$
IF s$ = "1" THEN
CLS
PRINT " The name must be exactly as show in main menu."
INPUT " The name of the person you wish to talk to"; talk$
CLS
REM **************** reply/// send message *********************
DO
INPUT "Reply"; t2$
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t2$
WRITE #1, 1
CLOSE #1
REM **************** Recieve message **************************
check:
OPEN talk$ + ".txt" FOR INPUT AS #1
INPUT #1, name1$
INPUT #1, no$
INPUT #1, t1$
INPUT #1, o
CLOSE #1
tc1$ = t1$
IF tp$ = tc1$ THEN
GOTO check
ELSE
PRINT name1$; ": "; t1$
tp$ = t1$
END IF
LOOP WHILE INKEY$ <> "q"
ELSEIF s$ = "2" THEN
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, 0
CLOSE #1
GOTO logout
END IF
LOOP WHILE 1 = 1
logout:
END SUB
SUB login (name$)
INPUT " Your user name"; un$
login2$ = un$ + ".txt"
OPEN login2$ FOR INPUT AS #1
INPUT #1, name$
INPUT #1, pass$
CLOSE #1
IF un$ = name$ THEN
PRINT " Welcome "; name$
pass:
INPUT " Password"; p$
IF p$ = pass$ THEN
PRINT " You are now logged on"
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, 1
CLOSE #1
PRINT " Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
ELSE
GOTO pass
END IF
END IF
CALL im(name$)
END SUB
SUB nu
INPUT " Your name that you wish to use"; name$
redo:
INPUT " Your password that you wish to use"; pass$
INPUT " Confirm your password"; passc$
IF pass$ = passc$ THEN
user$ = name$ + ".txt"
OPEN user$ FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t$
WRITE #1, o
CLOSE #1
ELSE
GOTO redo
END IF
PRINT "Thank you for registering"
PRINT "Hit any key to continue"
DO
LOOP WHILE INKEY$ = ""
END SUB
RE: qb I.m. OPEN PROBLEM
write exact error message,
also if it breaks - does it?
tell us on what line.
So far it just works for me unless I enter comma (,)
if so it says "redo from start"
so if you retype it without comma it works on...
If you need the comma you can input your reply lime in quotes like
"yes, now what?"
or you can change Input for Line input
in
INPUT "Reply"; t2$
RE: qb I.m. OPEN PROBLEM
RE: qb I.m. OPEN PROBLEM
You currently have it to read only 1 data item.
see following code:
CODE
REM with it (in this case it just prints to screen), and
REM then ends (because there is no cycling of the data
REM items.
CLS
READ LoggedON$
PRINT
PRINT "Returned data: ";
PRINT LoggedON$
SLEEP 4
END
TestNames:
DATA Dustin
DATA Korey
DATA Tucker
DATA Tyler
DATA Kayhil
DATA xxx
You have to cycle through each data item. So
it would look something like the following:
CODE
REM with the data, then READs the next item (cycling),
REM and does something with that data...and continues
REM until it reaches an EndOfData marker.
REM
CLS
REM Get the first LoggedOn person
READ LoggedON$
REM Do the following continiously until the 'end' marker
DO
PRINT
PRINT "Returned data: ";
PRINT LoggedON$
SLEEP 2
REM next line READs the next item
READ LoggedON$
LOOP UNTIL LCASE$(LoggedON$) = "xxx"
END
TestNames:
DATA Dustin
DATA Korey
DATA Tucker
DATA Tyler
DATA Kayhil
DATA xxx
Hope this Helps.
--MiggyD
--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
RE: qb I.m. OPEN PROBLEM
PRINT
READ on$
DO
OPEN on$ + ".txt" FOR INPUT AS #1
INPUT #1, name$
INPUT #1, no$
INPUT #1, no$
INPUT #1, o
CLOSE #1
IF o = 1 THEN
COLOR 18, 0
PRINT name$; " On ";
COLOR 7, 0
ELSEIF o = 0 THEN
PRINT name$; " off ";
END IF
READ on$
LOOP UNTIL on$ = "xxx"
RE: qb I.m. OPEN PROBLEM
RE: qb I.m. OPEN PROBLEM
One place where I see a problem is in your receive loop. You are constantly opening the sender's file and reading data until you actually receive a message. This tight loop has no error checking to ensure reading is not occuring at the same time the sender's file is being written.
RE: qb I.m. OPEN PROBLEM
RE: qb I.m. OPEN PROBLEM
RE: qb I.m. OPEN PROBLEM
REM **************** reply/// send message *********************
DO
INPUT "Reply"; t2$
OPEN name$ + ".txt" FOR OUTPUT AS #1
WRITE #1, name$
WRITE #1, pass$
WRITE #1, t2$
WRITE #1, 1
CLOSE #1
REM **************** Recieve message**************************
check:
REM this is where i placed th on error statement and i want it to just restart this loop again...
ON ERROR GOTO check
OPEN talk$ + ".txt" FOR INPUT AS #1
INPUT #1, name1$
INPUT #1, no$
INPUT #1, t1$
INPUT #1, o
CLOSE #1
tc1$ = t1$
IF tp$ = tc1$ THEN
GOTO check
ELSE
PRINT name1$; ": "; t1$
PRINT
tp$ = t1$
END IF
LOOP WHILE INKEY$ <> "q"
RE: qb I.m. OPEN PROBLEM
so is there a way i can make qbasic run two loops at the same time???? any help is apreciated...