home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / dialer.fr_ / dialer.bin
Text File  |  1993-04-28  |  6KB  |  207 lines

  1. VERSION 2.00
  2. Begin Form DIALER 
  3.    Caption         =   "MSComm Phone Dialer"
  4.    ClientHeight    =   2205
  5.    ClientLeft      =   2865
  6.    ClientTop       =   1500
  7.    ClientWidth     =   3270
  8.    Height          =   2610
  9.    Left            =   2805
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   2205
  12.    ScaleWidth      =   3270
  13.    Top             =   1155
  14.    Width           =   3390
  15.    Begin CommandButton CancelButton 
  16.       Caption         =   "Cancel"
  17.       Enabled         =   0   'False
  18.       Height          =   348
  19.       Left            =   1200
  20.       TabIndex        =   4
  21.       Top             =   1728
  22.       Width           =   852
  23.    End
  24.    Begin CommandButton QuitButton 
  25.       Cancel          =   -1  'True
  26.       Caption         =   "Quit"
  27.       Height          =   348
  28.       Left            =   2160
  29.       TabIndex        =   2
  30.       Top             =   1728
  31.       Width           =   852
  32.    End
  33.    Begin MSComm Comm1 
  34.       Interval        =   1000
  35.       Left            =   0
  36.       Top             =   0
  37.    End
  38.    Begin CommandButton DialButton 
  39.       Caption         =   "Dial"
  40.       Default         =   -1  'True
  41.       Height          =   348
  42.       Left            =   240
  43.       TabIndex        =   1
  44.       Top             =   1728
  45.       Width           =   852
  46.    End
  47.    Begin ListBox List1 
  48.       Height          =   1005
  49.       Left            =   240
  50.       TabIndex        =   0
  51.       Top             =   240
  52.       Width           =   2775
  53.    End
  54.    Begin Label Status 
  55.       BorderStyle     =   1  'Fixed Single
  56.       Caption         =   "Select a party to call"
  57.       Height          =   252
  58.       Left            =   240
  59.       TabIndex        =   3
  60.       Top             =   1296
  61.       Width           =   2772
  62.    End
  63. End
  64. '--------------------------------------------------------
  65. '-- DIALER.FRM
  66. '   Copyright (c) 1993 Crescent Software, Inc.
  67. '   by Carl Franklin
  68. '
  69. '   Demonstrates how to dial phone numbers with a modem.
  70. '
  71. '   In order for this program to work, your telephone and
  72. '   modem must be connected to the same phone line.
  73. '--------------------------------------------------------
  74. Option Explicit
  75. DefInt A-Z
  76.  
  77. '-- Phone numbers are stored here
  78. Dim PhoneNumbers$()
  79.  
  80. '-- This flag is set when cancel is pressed
  81. Dim CancelFlag
  82.  
  83. Sub CancelButton_Click ()
  84.     
  85.     '-- CancelFlag tells the Dial routine to exit
  86.     CancelFlag = True
  87.  
  88.     CancelButton.Enabled = False
  89.  
  90. End Sub
  91.  
  92. Sub Dial (Number$)
  93.     Dim DialString$, FromModem$, dummy
  94.  
  95.     '--- AT is the Hayes compatible ATTENTION command an is required to send commands to the modem.
  96.     '--- DT means "Dial Tone" - The Dial command, using touch tones as opposed to pulse (DP = Dial Pulse)
  97.     '--- PhoneNumbers$(Index) is the phone number of the person you're dialing
  98.     '--- A semicolon tells the modem to return to command mode after dialing (important)
  99.     '--- A Carriage return, Chr$(13), is required when sending commands to the modem.
  100.     DialString$ = "ATDT" + Number$ + ";" + Chr$(13)
  101.  
  102.     '-- Comm port settings
  103.     Comm1.Settings = "300,N,8,1"
  104.     
  105.     '-- Open the comm port
  106.     On Error Resume Next
  107.     Comm1.PortOpen = True
  108.     If Err Then
  109.        MsgBox "COM1: not available. Change the CommPort property to another port."
  110.        Exit Sub
  111.     End If
  112.     
  113.     '-- Flush the input buffer
  114.     Comm1.InBufferCount = 0
  115.     
  116.     '-- Dial the number
  117.     Comm1.Output = DialString$
  118.     
  119.     '-- Wait for "OK" to come back from the modem
  120.     Do
  121.        dummy = DoEvents()
  122.        '-- If there is data in the buffer, then read it.
  123.        If Comm1.InBufferCount Then
  124.           FromModem$ = FromModem$ + Comm1.Input
  125.           '-- Check for "OK"
  126.           If InStr(FromModem$, "OK") Then
  127.              '-- Notify the user to pick up the phone
  128.              Beep
  129.              MsgBox "Please pick up the phone and either press Enter, or click OK"
  130.              Exit Do
  131.           End If
  132.        End If
  133.         
  134.        '-- Was Cancel pressed?
  135.        If CancelFlag Then
  136.           CancelFlag = False
  137.           Exit Do
  138.        End If
  139.     Loop
  140.     
  141.     '-- Disconnect the modem
  142.     Comm1.Output = "ATH" + Chr$(13)
  143.     
  144.     '-- Close the port
  145.     Comm1.PortOpen = False
  146.     
  147. End Sub
  148.  
  149. Sub DialButton_Click ()
  150.     Dim Number$, Temp$
  151.     
  152.     DialButton.Enabled = False
  153.     QuitButton.Enabled = False
  154.     CancelButton.Enabled = True
  155.     
  156.     '-- Get the number to dial
  157.     Number$ = PhoneNumbers$(List1.ListIndex)
  158.  
  159.     Temp$ = Status
  160.     Status = "Dialing - " + Number$
  161.     
  162.     '-- Dial the selected phone number
  163.     Dial Number$
  164.  
  165.     DialButton.Enabled = True
  166.     QuitButton.Enabled = True
  167.     CancelButton.Enabled = False
  168.  
  169.     Status = Temp$
  170.  
  171. End Sub
  172.  
  173. Sub Form_Load ()
  174.     
  175.     '-- Setting InputLen to 0 tells MSComm to read the entire
  176.     '   contents of the input buffer when the Input property
  177.     '   is used.
  178.     Comm1.InputLen = 0
  179.     
  180.     Dialer.Show
  181.  
  182.     '-- Load the list box with names
  183.     List1.AddItem "Information"
  184.     List1.AddItem "800 Information"
  185.  
  186.     '-- Phone numbers
  187.     ReDim PhoneNumbers$(0 To List1.ListCount - 1)
  188.     PhoneNumbers$(0) = "1-555-1212"
  189.     PhoneNumbers$(1) = "1-800-555-1212"
  190.  
  191.     '-- Select the first name as default
  192.     List1.ListIndex = 0
  193.     
  194. End Sub
  195.  
  196. Sub List1_DblClick ()
  197.     
  198.     '-- Invoke the Dial button
  199.     DialButton_Click
  200.  
  201. End Sub
  202.  
  203. Sub QuitButton_Click ()
  204.     End
  205. End Sub
  206.  
  207.