home *** CD-ROM | disk | FTP | other *** search
- 'User's Manual Example, Page 262.
- CLS
-
- DEFINT a-z 'integer variables are smaller and faster
- $COM 1024
- OPEN "COM1: 1200,N,8,1" AS #1 LEN = 1024
- echo = 1
- WHILE (1) 'loop forever
- WHILE NOT INSTAT 'as long as no key has been pressed
- IF LOC(1) > 0 THEN
- stuff$ = INPUT$(LOC(1),#1) 'read incoming characters
- PRINT stuff$; 'no carriage returns
- 'unless sent by transmitter
- If already THEN PRINT #3, stuff$; 'save to disk file
- END IF
- WEND
- WHILE INSTAT 'while there are characters at the keyboard
- myinput$ = INKEY$ 'get them
- IF myinput$ = CHR$(20) THEN GOSUB ReadDiskFile '^T
- IF myinput$ = CHR$(18) THEN GOSUB WriteDiskFile '^R
- IF myinput$ = CHR$(3) THEN CLOSE : END '^C
- IF myinput$ = CHR$(5) THEN echo = ABS(echo-1):myinput$ = "" '^T
- PRINT #1, myinput$; 'send typed characters
- IF echo THEN PRINT myinput$; 'display them--maybe unnecessary
- WEND
- WEND 'check for more incoming characters
-
- ReadDiskFile:
- 'a subroutine to read a disk file and transmit it
- LINE INPUT "Name of the disk file: ";f$
- OPEN "r", 2, f$, 1024
- FIELD #2, 1024 AS disk$
- r& = LOC(2)
- rec = r&\1024
-
- FOR i = 1 to rec
- GET 2,i
- PRINT #1, disk$;
- NEXT i
-
- IF r& MOD 1024 <> 0 THEN
- GET 2, rec+1
- PRINT #1, LEFT$(disk$,r& MOD 1024 );
- END IF
- CLOSE 2
- myinput$ = ""
- RETURN
-
- WriteDiskFile:
- 'subroutine to write received information to disk file
- 'or stop that process
- myinput$ = ""
- IF already THEN
- already = 0
- CLOSE 3
- RETURN
- END IF
-
- already = 1
- LINE INPUT "Output file name: ";f$
- OPEN f$ FOR APPEND AS #3
- RETURN