help not a programmer

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
bob

help not a programmer

Post by bob »

hello
i am trying to demonstrate a simple example of time division multiplexing with 3 equal length text files between 2 serial connected computers
it is not working
here is the code
if anyone can help
CLS
start:
INPUT "Is this computer (t)ransmitting or (r)eceiving data?:", answer$
IF answer$ = "t" THEN
GOTO transmitting
ELSEIF answer$ = "r" THEN
GOTO receiving
ELSE
GOTO start
END IF

transmitting:

CLS

FILES "*.txt"

INPUT "Enter first file name:", file1$
INPUT "Enter second file:", file2$
INPUT "Enter last file:", file3$

OPEN file1$ FOR INPUT AS #1
OPEN file2$ FOR INPUT AS #2
OPEN file3$ FOR INPUT AS #3

OPEN "COM1:9600,N,8,1,ASC,CD0,CS0,DS0,RS" FOR OUTPUT AS #36
ON ERROR GOTO errhandle
PRINT "COM1 opened"

DO WHILE NOT EOF(3)

c$ = INPUT$(1, #1)
d$ = INPUT$(1, #2)
e$ = INPUT$(1, #3)
PRINT #36, c$; d$; e$;

LOOP

CLOSE #1, #2, #3, #36

END

receiving:

CLS

OPEN "1test.txt" FOR OUTPUT AS #5
OPEN "2test.txt" FOR OUTPUT AS #6
OPEN "3test.txt" FOR OUTPUT AS #7

OPEN "COM1:9600,N,8,1,ASC,CD0,CS0,DS0,RS" FOR INPUT AS #36
ON ERROR GOTO errhandle
PRINT "COM1 opened"

DO WHILE NOT EOF(36)

f$ = INPUT$(1, #36)
PRINT #5, f$;
g$ = INPUT$(1, #36)
PRINT #6, g$;
h$ = INPUT$(1, #36)
PRINT #7, h$;

LOOP

CLOSE #36, #5, #6, #7

END

errhandle:

SELECT CASE ERR
CASE 68: PRINT "COM1 is unavailable on this computer.": END
CASE ELSE: END
END SELECT
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

I've never read up on networking, but I'm sure this is the wrong way to open a COM port..

Code: Select all

OPEN "COM1:9600,N,8,1,ASC,CD0,CS0,DS0,RS" FOR INPUT AS #36 
Thats either your prob, maybe you could check back with were ever you learned how to network and find the correct code.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
bob

Post by bob »

in fact that is the way to open the com port

i have isolated the problem to the do while not eof(37) loop
take away the loop and a can recieve 1 character to each new file
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Dude do you mean: loop while not eof(3)? Cause you said eof(37) and there's no eof(37) in your code....just a thought. :roll:
"But...It was so beutifully done"
Post Reply