×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

qb I.m. OPEN PROBLEM

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

RE: qb I.m. OPEN PROBLEM

>>it stops the program and says cannot execute or something

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

(OP)
Thanks, also do you know how i can check in the new user section to see if the name is already been taken. I can just go in and re creat the users account and every thing.

RE: qb I.m. OPEN PROBLEM

How to use your READ command:

You currently have it to read only 1 data item.
see following code:


CODE

REM Example code which READs first data, does something
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 Example code which READs 1 data item, does something
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

(OP)
yes i know about the loop this is what i had. It tells the people if they are on or off.



   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

(OP)
After so far into the messenger it stops and says input past end of file... But there is something in that part of the file. IS there a way i can fix that??? or just make it skip the problem and keep running.?.?...

RE: qb I.m. OPEN PROBLEM

At what point are you getting the input past end of file?

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

(OP)
yes i noticed that but i have no idea how to fix, this problem. Is there a statement that does that for me??

RE: qb I.m. OPEN PROBLEM

you should use ON ERROR then opening.

RE: qb I.m. OPEN PROBLEM

(OP)
ok ive tried thew on error statement and i think im using it wrong, i dont know.




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

(OP)
ok well now i would like to make the send recieve to where i can send as many times as i want, and recieve at the same time.


so is there a way i can make qbasic run two loops at the same time???? any help is apreciated...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close