home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
modem
/
ibmxmo.bqs
/
IBMXMO.BAS
Wrap
BASIC Source File
|
1994-03-04
|
16KB
|
357 lines
50 ' THIS PROGRAM KINDA RE-WRITTEN BY CAPITAL PC USER GROUP PEOPLE.
55 ' ANY PROBLEMS PLEASE LET US KNOW. 301-949-8848 OR 703-560-0979
57 ' The help of BJ Reckman is appreciated.
58 ' You must change a lot of places if you use COM2: and your smartmodem
59 ' must be set up as line 86 so notes... CPCUG SOFTSIG
60 ' set up as follows A>BASICA IBMODEM2/C:1024
70 ' In order for the hang-up command to work,
80 ' you MUST flip switch #1 on the modem UP.
85 ' (You should have it up anyway.)
86 ' SWITCH SETTINGS ON SMARTMODEM UUDDDDDD
87 '
88 'This program probably will not work with an IN-BOARD modem ie HAYES 1200B
90 SCREEN 0,0,0,0 : LOCATE ,,1 : WIDTH 40 : KEY OFF : CLOSE
95 ON ERROR GOTO 1000
100 ' Set Variable Defaults ---------------------------------------
110 DEFINT A-Z ' All Variables Are Integers
120 ONLINE = -1 ' Start On-Line
130 EVEN = 0 ' Even Parity, 7 Bit Word Structure
140 PRINTER= 0 ' Printer Off
150 DISK = 0 ' Disk(s) Off
160 LOCAL = 0 : HOST=0 ' Echoes Off
170 BK$=CHR$(29)+CHR$(32)+CHR$(29)' Clean Backspace For Local PC
180 SOH$=CHR$(1) : EOT$=CHR$(4) : ACK$=CHR$(6)
190 XON$=CHR$(17) : XOFF$=CHR$(19) : NAK$=CHR$(21) : CAN$=CHR$(24)
200 ' Define Funtion Keys -----------------------------------------
210 KEY(1)ON:ON KEY(1)GOSUB 3100
220 KEY(2)ON:ON KEY(2)GOSUB 3200
230 KEY(3)ON:ON KEY(3)GOSUB 3300
240 KEY(4)ON:ON KEY(4)GOSUB 3400
250 KEY(5)ON:ON KEY(5)GOSUB 3500
260 KEY(6)ON:ON KEY(6)GOSUB 3600
270 KEY(7)ON:ON KEY(7)GOSUB 3700
280 KEY(8)ON:ON KEY(8)GOSUB 3800
290 KEY(9)ON:ON KEY(9)GOSUB 3900
295 KEY(10)ON:ON KEY(10)GOSUB 4000
297 DEF SEG:POKE 106,0
300 ' Define I/O Channels -----------------------------------------
310 OPEN "R",#1,"COM1:300,N,8,,RS,CS,DS" ' Modem ====> File #1
320 'OPEN "O",#2,"LPT1:" ' Printer ==> File #2
330 'PRINT #1,"ATE1QTS11=50" ' Initialize Modem
340 FOR X=1 TO 1000 : NEXT : GOSUB 25000 : GOSUB 800
400 ' Keyboard Driven Terminal Loop -------------------------------
410 WHILE ONLINE
420 X$=INKEY$:IF X$<>"" THEN LOCATE ,,1:PRINT #1,X$;:IF LOCAL THEN GOSUB 470
430 GOSUB 500
440 WEND
450 IF NOT ONLINE THEN 450 ' Off-Line Wait Loop
460 GOTO 410
470 IF POS(0)>1 AND X$=CHR$(8) THEN PRINT BK$; ELSE PRINT X$;
480 RETURN
500 ' Main Communication Loop -------------------------------------
510 WHILE NOT EOF(1)
520 X$=INKEY$ : IF X$<>"" THEN LOCATE ,,1 : PRINT #1,X$;
530 Y$=INPUT$(LOC(1),#1) : IF DISK THEN PRINT #3,Y$;
540 FOR I=1 TO LEN(Y$)
550 J=ASC(MID$(Y$,I,1)) : IF J=10 THEN 590 ELSE IF J=8 THEN 595
560 PRINT CHR$(J); : IF HOST THEN PRINT #1,CHR$(J);
570 NEXT : IF PRINTER THEN PRINT #2,Y$;
580 WEND : RETURN
590 MID$(Y$,I,1)=" " : GOTO 570
595 IF POS(0)>1 THEN PRINT BK$; : IF HOST THEN PRINT #1,CHR$(J);
597 GOTO 570
800 ' Function Key Display Menu -----------------------------------
810 CLS : PRINT TAB(15);"MENU FOR FUNCTION KEYS" : PRINT
820 PRINT TAB(10)"Key 1 . . . . . . To Toggle Modem Online/Offline
830 PRINT TAB(10)"Key 2 . . . . . . To Toggle On/Off LOCAL Echo
840 PRINT TAB(10)"Key 3 . . . . . . To Toggle On/Off HOST Echo
850 PRINT TAB(10)"Key 4 . . . . . . To Dial A Number
860 PRINT TAB(10)"Key 5 . . . . . . To Display This Menu
870 PRINT TAB(10)"Key 6 . . . . . . To Toggle Printer On/Off
880 PRINT TAB(10)"Key 7 . . . . . . To Write To Disk From Modem
890 PRINT TAB(10)"Key 8 . . . . . . To Write To Modem From Disk
900 PRINT TAB(10)"Key 9 . . . . . . To Toggle Between E,7,1 and N,8,1 words
910 PRINT TAB(10)"Key 10. . . . . . To Return To Basic Without Hanging-Up
920 PRINT
930 PRINT TAB(10)"Alt + Key 3 . . . To Change To 300 Baud
940 PRINT TAB(10)"Alt + Key 4 . . . To Continuously Dial A Number
950 PRINT TAB(10)"Alt + Key 5 . . . To Change To 450 Baud
960 PRINT TAB(10)"Alt + Key 6 . . . To Change To 600 Baud
970 PRINT TAB(10)"Alt + Key 7 . . . To Write To Disk With Xmodem Protocol
975 PRINT TAB(10)"Alt + Key 8 . . . To Write To Modem From Disk With Xmodem
980 PRINT TAB(10)"Alt + Key 10. . . To Hang-Up
985 LOCATE 25,1:PRINT "Help F-5";:IF PRINTER THEN PRINT " :Printer ON"; ELSE PRINT " :Printer OFF";:LOCATE 20,1,1
990 PRINT : RETURN
1000 ' Error Vector Table -----------------------------------------
1010 PRINT
1020 IF ERR=24 THEN PRINT "Device Timeout" : PRINT : RESUME 400
1030 IF ERR=27 THEN PRINT "Printer" : PRINT : RESUME 400
1040 IF ERR=57 THEN PRINT "Device I/O" : PRINT : RESUME 400
1050 IF ERR=52 THEN PRINT "Bad Filename" : GOTO 1150
1060 IF ERR=61 THEN PRINT "Disk Full" : GOTO 1150
1070 IF ERR=67 THEN PRINT "Directory Full" : GOTO 1150
1080 IF ERR=70 THEN PRINT "Disk Write Protected" : GOTO 1150
1090 IF ERR=71 THEN PRINT "Drive Not Ready" : GOTO 1150
1100 IF ERR=72 THEN PRINT "Disk Media Error" : GOTO 1150
1105 IF ERR=53 AND ERL=3770 THEN RESUME 3780
1110 IF ERR=53 THEN PRINT "File Not Found" : PRINT : FILES : GOTO 1150
1120 IF ERR=58 THEN PRINT "File Already Exists" : PRINT : FILES : GOTO 1150
1130 ON ERROR GOTO 0
1150 PRINT : DISK=0 : CLOSE #3 : IF NOT ONLINE THEN GOSUB 3120
1160 LOCATE ,,1 : RESUME 400
3100 ' Service Function Key #1 -------------------------------------
3110 GOSUB 5000 : KEY(1)ON : ON S GOTO 6100,7100,8100
3120 ONLINE=NOT ONLINE : IF NOT ONLINE THEN 3140
3130 PRINT #1, XON$ : PRINT "Status : ON Line" : RETURN
3140 PRINT #1, XOFF$: PRINT "Status : OFF Line" : RETURN
3200 ' Service Function Key #2 -------------------------------------
3210 GOSUB 5000 : KEY(2) ON : ON S GOTO 6200,7200,8200
3220 LOCAL=NOT LOCAL
3230 PRINT "Local Echo "; : IF LOCAL THEN PRINT "ON" ELSE PRINT "OFF"
3240 RETURN
3300 ' Service Function Key #3 -------------------------------------
3310 GOSUB 5000 : KEY(3)ON : ON S GOTO 6300,7300,8300
3320 HOST=NOT HOST
3330 PRINT "Host Echo "; : IF HOST THEN PRINT "ON" ELSE PRINT "OFF"
3340 RETURN
3400 ' Service Function Key #4 -------------------------------------
3410 GOSUB 5000 : KEY(4)ON : ON S GOTO 6400,7400,8400
3420 GOSUB 10000 : PRINT
3430 'PRINT #1,"AT M1 D "+X$
3440 RETURN
3500 ' Service Function Key #5 -------------------------------------
3510 GOSUB 5000 : KEY(5)ON : ON S GOTO 6500,7500,8500
3520 GOTO 800
3600 ' Service Function Key #6 ------------------------------------
3610 GOSUB 5000 : KEY(6)ON : ON S GOTO 6600,7600,8600
3620 PRINTER=NOT PRINTER
3630 IF PRINTER THEN LOCATE 25,11:PRINT "Printer ON " ELSE LOCATE 25,11:PRINT "Printer OFF"
3640 RETURN
3700 ' Service Function Key #7 -------------------------------------
3710 GOSUB 5000 : KEY(7)ON : ON S GOTO 22000,7700,8700
3720 DISK=NOT DISK
3730 IF NOT DISK THEN CLOSE #3 : PRINT "File Closed" : RETURN
3740 GOSUB 3120
3750 PRINT "Modem ====>> Disk" : PRINT
3760 INPUT "ENTER FILENAME : ",X$ : IF X$="" THEN 3790
3770 CLOSE #3 : OPEN "I",#3,X$ : ERROR 58
3780 CLOSE #3 : OPEN "O",#3,X$ : GOSUB 3120 : RETURN
3790 PRINT "Aborted" : PRINT : CLOSE #3 : GOSUB 3120 : DISK=0 : RETURN
3800 ' Service Function Key #8 -------------------------------------
3810 GOSUB 5000 : KEY(8)ON : ON S GOTO 30000,7800,8800
3820 PRINT "Disk ====>> Modem" : PRINT
3830 INPUT "ENTER FILENAME : ",X$ : IF X$="" THEN 3790
3835 IF XX THEN GOTO 3845 ' BJR073183
3840 OPEN "I",#3,X$ : GOTO 3850 ' BJR073183
3845 OPEN X$ AS 3 LEN=128 : FIELD #3, 128 AS Z$ ' BJR073183
3850 PRINT "Proceed With File ";X$;
3860 INPUT " (Y/N) ";Y$ : Y$=LEFT$(Y$,1)
3870 IF Y$<>"Y" AND Y$<>"y" THEN 3896
3875 IF XX THEN XX=0 : RETURN 30040
3880 WHILE NOT EOF(3)
3885 LINE INPUT #3,X$
3890 PRINT #1,X$
3892 FOR I=1 TO 1500:NEXT
3894 WEND
3896 CLOSE #3 : DISK=0 : PRINT "File Closed" : PRINT : RETURN
3900 ' Service Function Key #9 -------------------------------------
3910 GOSUB 5000 : KEY(9)ON : ON S GOTO 6900,7900,8900
3920 EVEN=NOT EVEN : IF NOT EVEN THEN 3940
3930 PRINT "Changed to Even Parity, With 7 Data Bits"
3935 'OUT &H3FB,26 : RETURN ' E-7-1 Word Structure *********
3940 RETURN
3945 ' SET TO 8 BIT NO PARITY?
3948 'OUT &H3FB,&H3
3950 RETURN
4000 ' RETURN TO BASIC WITH/WITHOUT HANGING UP
4010 RETURN
5000 ' WHAT DOES THIS DO?
5010 ' WILL THIS WORK?
5020 DEF SEG=&H40:A=PEEK(&H17)
5030 IF (A AND 8)=8 THEN S=1 : DEF SEG : RETURN 'Alternate
5040 IF (A AND 2)=2 THEN S=2 : DEF SEG : RETURN 'Left Shift
5050 IF (A AND 4)=4 THEN S=3 : DEF SEG : RETURN 'Control
5060 S=0 : DEF SEG : RETURN
6100 RETURN
6200 RETURN
6300 '-------------------------------------------------- Alt + F3 -------------
6310 PRINT "Switch to 300 Baud."
6320 ON ERROR GOTO 0
6330 R=INP(&H3FB)
6340 K=R OR 128
6350 OUT &H3FB,K
6360 OUT &H3F8,&H1
6370 OUT &H3F9,&H2
6380 OUT &H3FB,R
6390 ON ERROR GOTO 1000 : RETURN
6400 'Continuous Dialing ------------------------------- Alt + F4 -------------
6405 IF NOT EVEN THEN GOSUB 3940
6410 GOSUB 10000 : PRINT : PRINT "Continuously Dialing ";X$
6420 PRINT "Press ESC twice to abort."
6430 T=0 : PRINT : PRINT "Number of calls attempted so far : ";
6440 T=T+1 : LOCATE ,36 : PRINT T; : 'PRINT #1,"AT M1 D "+X$
6450 IF CHR$(27)=INKEY$ THEN 6497 ELSE WHILE NOT EOF(1)
6460 INPUT #1,Y$ : FOR X=1 TO 1000 : NEXT
6470 IF INSTR (Y$,"NO CARRIER") THEN 6440
6480 IF INSTR (Y$,"CONNECT") THEN 6490
6485 WEND : GOTO 6450
6490 PRINT : PRINT "Connection Established."
6495 WHILE INKEY$="" : SOUND 1000,10 : SOUND 735,8 : WEND
6497 PRINT : RETURN
6500 '------------------------------------------------- Alt + F5 ------------
6510 PRINT "Switch to 450 Baud."
6520 ON ERROR GOTO 0
6530 R=INP(&H3FB)
6540 K=R OR 128
6550 OUT &H3FB,K
6560 OUT &H3F8,&H0
6570 OUT &H3F9,&H1
6580 OUT &H3FB,R
6590 ON ERROR GOTO 1000 : RETURN
6600 '-------------------------------------------------- Alt + F6 -------------
6610 PRINT "Switch to 600 Baud."
6620 ON ERROR GOTO 0
6630 R=INP(&H3FB)
6640 K=R OR 128
6650 OUT &H3FB,K
6660 OUT &H3F8,&H1
6670 OUT &H3F9,&H1
6680 OUT &H3FB,R
6690 ON ERROR GOTO 1000 : RETURN
6900 RETURN
7000 '-------------------------------------------------- Alt + F10 ------------
7010 PRINT "Hanging-Up" : RUN
7100 RETURN
7200 RETURN
7300 RETURN
7400 RETURN
7500 RETURN
7600 RETURN
7700 RETURN
7800 RETURN
7900 RETURN
8000 RETURN
8100 RETURN
8200 RETURN
8300 RETURN
8400 RETURN
8500 RETURN
8600 RETURN
8700 RETURN
8800 RETURN
8900 RETURN
9000 RETURN
10000 ' Directory --------------------------------------------------
10010 PRINT "|------------- Directory --------------------|"
10020 PRINT ": A> 560-0979 CAPITAL PC UG BBS :" : D$(1)="560-0979"
10030 PRINT ": B> 949-8848 CPSUG SOFTSIG (IBMPC) :" : D$(2)="949-8848"
10040 PRINT ": C> 251-6293 COMM SIG CPCUG :" : D$(3)="251-6293"
10050 PRINT ": D> 978-9592 BASIC HELP CPCUG (IBMPC):" : D$(4)="978-9592"
10060 PRINT ": E> 424-5817 MONITOR CPCUG (IBMPC):" : D$(5)="424-5817"
10070 PRINT ": F> 759-5049 TOM MACK'S RBBS :" : D$(6)="759-5049"
10080 PRINT "|--------------------------------------------<"
10090 PRINT " Enter the corresponding letter"
10100 PRINT " or type in any phone number." : PRINT
10110 LINE INPUT "Number to Dial ? ";X$
10120 IF LEN(X$)=1 AND X$=>"A" AND X$<="F" THEN X$=D$(ASC(X$)-64) : RETURN
10130 IF LEN(X$)=1 AND X$=>"a" AND X$<="f" THEN X$=D$(ASC(X$)-96) : RETURN
10140 IF LEN(X$)<7 THEN LOCATE ,,1 : RETURN 400 ELSE RETURN
20000 ' Get Character -----------------------------------------
20010 Y$=""
20020 FOR A=1 TO 420
20030 IF NOT EOF(1) THEN Y$=INPUT$(LOC(1),#1) : RETURN
20040 NEXT A : Y$="" : RETURN
21000 ' Timeout -----------------------------------------------
21010 FOR B = 1 TO 10
21020 GOSUB 20000
21030 IF MID$(Y$,1,1)=SOH$ THEN RETURN
21040 IF MID$(Y$,1,1)=EOT$ THEN 22350
21050 IF MID$(Y$,1,1)=CAN$ THEN 22360
21060 IF Y$<>"" THEN GOSUB 25000 : GOTO 21000
21070 NEXT B
21080 IF Y$="" THEN PRINT #1,NAK$;
21090 GOTO 21000
22000 ' Receive With Xmodem Protocol ---------------------------
22010 PRINT "Receive File With XMODEM Protocol" : PRINT
22020 IF EVEN THEN GOSUB 3945 ' Set Word Structure To 8-N-1
22030 GOSUB 3740 ' Open File
22040 GOSUB 25000 ' Purge Buffer
22050 X$="" : SEC=1
22060 PRINT #1,NAK$;
22070 GOSUB 21000 ' Timeout
22080 GOSUB 20000 ' Get Char
22090 IF Y$="" THEN PRINT "Timeout" : GOTO 22120
22100 X$=X$+Y$
22110 IF LEN(X$)<=131 THEN 22080
22120 IF LEN(X$)= 132 THEN Z$=MID$(X$,4,128) : N=132 : GOTO 22200
22130 IF LEN(X$)= 131 THEN Z$=MID$(X$,3,128) : N=131 : GOTO 22200
22140 IF LEN(X$)> 132 THEN 22310
22150 IF X$=EOT$ THEN 22350
22160 IF X$=CAN$ THEN 22360
22170 GOTO 22300
22180 IF SEC<> VAL(MID$(X$,2,1) THEN 22330
22190 IF (SEC XOR 255) <> VAL(MID$(X$,3,1) THEN 22340
22200 FOR Q=1 TO 128 : CK=CK+ASC(MID$(Z$,Q,1)) : NEXT
22210 IF (CK AND 255) <> (ASC(MID$(X$,N,1))) THEN 22320
22220 PRINT "Received #";SEC : SEC=255 AND (SEC+1)
22230 PRINT #3,Z$;
22240 PRINT #1,ACK$;
22250 X$="" : CK=0 : GOTO 22080
22300 PRINT "Short Block in #" ;SEC : PRINT #1,NAK$; : GOTO 22250
22310 PRINT "Long Block in #" ;SEC : PRINT #1,NAK$; : GOTO 22250
22320 PRINT "Checksum Error in #";SEC : PRINT #1,NAK$; : GOTO 22250
22330 PRINT "Block # Error in #";SEC : PRINT #1,NAK$; : GOTO 22250
22340 PRINT "Complement Error in #";SEC:PRINT #1,NAK$; : GOTO 22250
22350 PRINT "File Closed." : PRINT #1,ACK$; : CLOSE #3 : GOTO 22370
22360 PRINT "Transfer Aborted at Receiver" : CLOSE #3
22370 IF EVEN THEN GOSUB 3935
22380 RETURN 400
25000 'Purge Buffer ------------------------------------------
25010 WHILE NOT EOF(1) : DUMMY$=INPUT$(LOC(1),#1) : WEND : RETURN
30000 ' Send with Xmodem Protocol -----------------------------------
30010 PRINT "Send File With XMODEM Protocol" : PRINT
30020 IF EVEN THEN GOSUB 3945 'Set To N-8-1 Word Structure ********************
30030 XX=-1 : GOSUB 3820 'Open File
30040 SEC=0 : GOSUB 25000 'Purge Buffer
30050 EOT=0 : Y$="" : X$="" : FLN!=LOF(3) : TBLK!=LOF(3)/128 'BJR073183
30055 PRINT "Total Blocks to Send =";TBLK!
30060 BLK=0 : CNT!=0 'BJR073183
30100 WHILE NOT EOF(1) 'Wait for NAK
30110 Y$=INPUT$(1,#1)
30120 IF Y$=CAN$ THEN 30510
30130 IF Y$=NAK$ THEN 30310
30140 WEND : GOTO 30100
30150 '
30200 WHILE NOT EOF (1) ' Wait for ACK
30210 Y$=INPUT$(1,#1)
30220 IF Y$=ACK$ THEN CK=0 : Y$="" : GOTO 30300 ' BJR073183
30230 IF Y$=NAK$ THEN PRINT "RESENDING BLOCK # ",BLK : GOTO 30460 'BJR073183
30240 IF Y$=CAN$ THEN 30510
30250 WEND : GOTO 30200
30260 '
30300 IF EOT THEN 30500 ' Build and Send Block
30310 CK=0 : Y$="" : BLK=BLK+1 : CNT!=CNT!+128 : GET #3,BLK : IF CNT!<=FLN! THEN 30330 'BJR073183
30320 Z$=MID$(Z$,1,128-(CNT!-FLN!))+STRING$(CNT!-FLN!,CHR$(0)) : EOT=-1 'BJR073183
30330 CK=0 : FOR I=1 TO LEN(Z$) : CK=CK+ASC(MID$(Z$,I,1)) : NEXT : CK = (CK AND 255) 'BJR073183
30340 IF CK>256 THEN CK=CK-256 : GOTO 30340 ' BJR073183
30345 ' BJR073183
30360 ' BJR073183
30365 ' BJR073183
30370 ' BJR073183
30380 ' BJR073183
30390 ' BJR073183
30400 ' BJR073183
30410 ' BJR073183
30420 ' BJR073183
30430 ' BJR073183
30440 SEC=(255 AND BLK) ' BJR073183
30450 A$=SOH$+CHR$(SEC)+CHR$(SEC XOR 255)+Z$+CHR$(CK) ' BJR073183
30460 PRINT "Send #";SEC
30470 PRINT #1,A$;
30480 GOTO 30200
30490 ' BJR073183
30500 PRINT "Transmission Ended." : PRINT #1,EOT$; : CLOSE #3
30510 IF EVEN THEN GOSUB 3935
30520 RETURN 400