home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / QBNWS204.ZIP / DIAL.ZIP / DIAL.BAS
BASIC Source File  |  1991-10-20  |  6KB  |  193 lines

  1. ' DIAL    BAS : Dial a phone number on the screen
  2. ' author .....: Dick Dennison [74270,3636] 1:272/34 914-374-3903 *hst 24 hrs
  3. ' supports ...: COM1 - COM4
  4. ' syntax .....: DIAL portnum%
  5. ' includes ...: None
  6. ' notes ......: Move the cursor with the arrow keys to the phone number
  7. '             : Press the ']' key and move the right arrow key across
  8. '             : the number and press Enter
  9. '             : Uses Basic's OPEN COMx commands
  10. ' cost .......: Free = Credit where credit due
  11. '             : Do not use as is for commercial use - may not be resold
  12. '             : May not be rebundled without prior written consent
  13. ' dated ......: 10/19/91
  14. ' credits ....: Thanks to Mike Welch for CLIPMSG, and Pete Petrakis for his        
  15. '             : notes on Com Port swapping.
  16.  
  17. DECLARE SUB Hangup (Port%)
  18. DECLARE SUB Getnum (row%, Col%, markit%, Port%)
  19. DECLARE SUB Setup (Port%)
  20.  
  21. COLOR 0, 7
  22. LOCATE 25, 1
  23. PRINT "     Move the cursor to the beginning of the phone number and press Space  ";
  24. LOCATE 10, 1
  25. IF VAL(COMMAND$) < 1 OR VAL(COMMAND$) > 4 THEN      'Get the portnum%
  26.      PRINT "Port number must be on command line"
  27.      END
  28. ELSE Port% = VAL(COMMAND$)
  29. END IF
  30.                    
  31.                     'Setup some special key functions
  32. CR$ = CHR$(13)
  33. Nul$ = CHR$(0)
  34. ArrowLt$ = Nul$ + CHR$(75)
  35. ArrowRt$ = Nul$ + CHR$(77)
  36. ArrowUp$ = Nul$ + CHR$(72)
  37. ArrowDn$ = Nul$ + CHR$(80)
  38. EndKey$ = Nul$ + CHR$(79)
  39. Esc$ = CHR$(27)
  40. Home$ = Nul$ + CHR$(71)
  41. SpaceBar$ = CHR$(32)
  42.                    'Save vectors at bios Addresses for Com1-Com2
  43.   OldPort1H = PEEK(&H400)
  44.   OldPort1L = PEEK(&H401)
  45.   OldPort2H = PEEK(&H402)
  46.   OldPort2L = PEEK(&H403)
  47.  
  48. 'Move cursor around
  49. '==================================================================
  50. DO                         'This section lets the user move
  51.  In$ = INKEY$             'move the cursor around on the screen
  52.  SELECT CASE In$          'to the beginning of the phone number
  53.   CASE CR$
  54.     IF markit% THEN       'A CR signals the end of the highlight
  55.      row% = CSRLIN
  56.      Col% = POS(0) - count%
  57.      EXIT DO
  58.     END IF
  59.   CASE Esc$                'END
  60.     END
  61.   CASE Home$               'Goto the beginning of the line
  62.      LOCATE , 1
  63.   CASE EndKey$             'Goto the end of the line
  64.      LOCATE , 80
  65.   CASE ArrowUp$            'UpArrow
  66.      x% = CSRLIN
  67.      IF x% > 1 THEN LOCATE x% - 1
  68.   CASE ArrowDn$            'DownArrow
  69.      x% = CSRLIN
  70.      IF x% < 25 THEN LOCATE x% + 1
  71.   CASE ArrowLt$                                 'LeftArrow
  72.      IF POS(0) > 1 THEN LOCATE , POS(0) - 1
  73.      IF markit% THEN count% = count% - 1       'If markit% then ' ' was pressed
  74.   CASE ArrowRt$                             'RightArrow
  75.      
  76.      IF markit% THEN
  77.           count% = count% + 1               'If markit% then ' ' was pressed
  78.           row% = CSRLIN: Col% = POS(0)
  79.           a% = SCREEN(row%, Col%)
  80.           PRINT CHR$(a%);
  81.      ELSE
  82.           IF POS(0) < 80 THEN LOCATE , POS(0) + 1
  83.      END IF
  84.   CASE SpaceBar$
  85.      IF markit% THEN
  86.           count% = count% + 1               'If markit% then ' ' was pressed
  87.           row% = CSRLIN: Col% = POS(0)
  88.           a% = SCREEN(row%, Col%)
  89.           PRINT CHR$(a%);
  90.      ELSE
  91.           BEEP
  92.           markit% = -1                      'Flag set for marking number
  93.      END IF
  94.  END SELECT
  95.  LOCATE , , 1                   'Keep cursor flashing
  96. LOOP
  97. '======================================================================
  98.  
  99.          'Get the phone number off the screen
  100. Getnum row%, Col%, count%, Port%
  101.  
  102.          'Restore old vectors
  103. CLOSE 1
  104.   DEF SEG = 0
  105.      POKE &H400, OldPort1H
  106.      POKE &H401, OldPort1L
  107.      POKE &H402, OldPort2H
  108.      POKE &H403, OldPort2L
  109.   DEF SEG
  110. END
  111.  
  112. SUB Getnum (row%, Col%, markit%, Port%)
  113. IF row% < 1 THEN row% = 1: IF Col% < 1 THEN Col% = 1
  114. LOCATE row%, Col%
  115. FOR x% = 0 TO markit%           'Read the phone number off the screen
  116.      a% = SCREEN(row%, Col% + x%)
  117.      Dialstr$ = Dialstr$ + CHR$(a%)
  118. NEXT x%
  119. LOCATE 23, 25
  120. PRINT "Dialing : "; Dialstr$;
  121. LOCATE 25, 1
  122. PRINT "             Pickup handset and then press space or ESC phone rings      ";
  123. COLOR 7, 0
  124.  
  125. Setup Port%
  126. PRINT #1, "ATM1DT" + Dialstr$     'Dial the numbar
  127.  
  128. DO
  129.      b$ = INKEY$
  130.      IF b$ = " " THEN
  131.           Hangup Port%
  132.           EXIT DO
  133.      END IF
  134.      IF b$ = CHR$(27) THEN
  135.           Hangup Port%
  136.           EXIT DO
  137.      END IF
  138. LOOP
  139.  
  140. END SUB
  141.  
  142. SUB Hangup (Port%)
  143.  
  144. PRINT "...Disconnecting 1";
  145. SELECT CASE Port%                'Drop DTR
  146.     CASE 1
  147.         OUT &H3FC, (INP(&H3FC) AND 252)   'com1
  148.     CASE 2
  149.         OUT &H2FC, (INP(&H2FC) AND 252)   'com2
  150.     CASE 3
  151.         OUT &H3FC, (INP(&H3FC) AND 252)   'com3
  152.     CASE 4
  153.         OUT &H2FC, (INP(&H2FC) AND 252)   'com4
  154. END SELECT
  155.      PRINT "...2...";
  156.      PRINT #1, "+++";   'Switch to modem command mode
  157.      SLEEP 1
  158.      PRINT #1, "ATH"    'Send hangup command
  159.      PRINT "...CLICK";
  160.  
  161. END SUB
  162.  
  163. SUB Setup (Port%)
  164. 'Sets up the comport by swapping the address fo com4 with com2 and
  165. 'com3 with com1 if necessary
  166. DEF SEG = 0
  167.  POKE &H400, &HF8
  168.  POKE &H401, 3
  169.  POKE &H402, &HF8
  170.  POKE &H403, 2
  171.  
  172. SELECT CASE Port%
  173.      CASE 1
  174.         Start$ = "COM1:2400,N,8,1,DS0"
  175.      CASE 2
  176.         Start$ = "COM2:2400,N,8,1,DS0"
  177.      CASE 3
  178.         POKE &H400, &HE8   'For com1 to com3
  179.         POKE &H401, &H3
  180.         Start$ = "COM1:2400,N,8,1,DS0"
  181.      CASE 4
  182.         POKE &H402, &HE8   'For com2 to com4
  183.         POKE &H403, &H2
  184.         Start$ = "COM2:2400,N,8,1,DS0"
  185. END SELECT
  186. DEF SEG
  187.  
  188.  
  189. OPEN Start$ FOR RANDOM AS 1
  190.  
  191. END SUB
  192.  
  193.