Page 1 of 1

help not a programmer

Posted: Tue Mar 22, 2005 8:10 am
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

Posted: Tue Mar 22, 2005 4:48 pm
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:

Posted: Wed Mar 23, 2005 5:52 pm
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

Posted: Thu Mar 24, 2005 4:22 pm
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: