home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / update / crescent / mwupd / mwmodem.frm next >
Text File  |  1994-10-17  |  21KB  |  738 lines

  1. VERSION 2.00
  2. Begin Form MWModem 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Modem Database"
  5.    ClientHeight    =   2616
  6.    ClientLeft      =   648
  7.    ClientTop       =   2268
  8.    ClientWidth     =   6720
  9.    Height          =   3264
  10.    Icon            =   MWMODEM.FRX:0000
  11.    Left            =   600
  12.    LinkTopic       =   "Form2"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   2616
  15.    ScaleWidth      =   6720
  16.    Top             =   1668
  17.    Width           =   6816
  18.    Begin TextBox TbPort 
  19.       Height          =   285
  20.       Left            =   1680
  21.       TabIndex        =   7
  22.       Text            =   "2"
  23.       Top             =   2040
  24.       Width           =   495
  25.    End
  26.    Begin CommandButton BtnOkExit 
  27.       Cancel          =   -1  'True
  28.       Caption         =   "Cancel"
  29.       Height          =   372
  30.       Index           =   1
  31.       Left            =   5520
  32.       TabIndex        =   5
  33.       Top             =   2040
  34.       Width           =   972
  35.    End
  36.    Begin CommandButton BtnOkExit 
  37.       Caption         =   "OK"
  38.       Default         =   -1  'True
  39.       Height          =   375
  40.       Index           =   0
  41.       Left            =   4680
  42.       TabIndex        =   4
  43.       Top             =   2040
  44.       Width           =   735
  45.    End
  46.    Begin ListBox List2 
  47.       Height          =   1560
  48.       Left            =   2160
  49.       TabIndex        =   1
  50.       Top             =   360
  51.       Width           =   4332
  52.    End
  53.    Begin ListBox List1 
  54.       Height          =   1560
  55.       Left            =   240
  56.       Sorted          =   -1  'True
  57.       TabIndex        =   0
  58.       Top             =   360
  59.       Width           =   1812
  60.    End
  61.    Begin Label Label1 
  62.       Alignment       =   1  'Right Justify
  63.       Caption         =   "Comm Port:"
  64.       Height          =   255
  65.       Index           =   2
  66.       Left            =   240
  67.       TabIndex        =   6
  68.       Top             =   2050
  69.       Width           =   1335
  70.    End
  71.    Begin Label Label1 
  72.       Caption         =   "Model:"
  73.       Height          =   252
  74.       Index           =   1
  75.       Left            =   2160
  76.       TabIndex        =   3
  77.       Top             =   120
  78.       Width           =   852
  79.    End
  80.    Begin Label Label1 
  81.       Caption         =   "Make:"
  82.       Height          =   252
  83.       Index           =   0
  84.       Left            =   240
  85.       TabIndex        =   2
  86.       Top             =   120
  87.       Width           =   852
  88.    End
  89.    Begin Menu MenuUtil 
  90.       Caption         =   "&Utilities"
  91.       Begin Menu MUtil 
  92.          Caption         =   "&Edit Settings"
  93.          Index           =   1
  94.       End
  95.       Begin Menu MUtil 
  96.          Caption         =   "&Add Modem"
  97.          Index           =   2
  98.       End
  99.       Begin Menu MUtil 
  100.          Caption         =   "&Delete Modem"
  101.          Index           =   3
  102.       End
  103.       Begin Menu MUtil 
  104.          Caption         =   "-"
  105.          Index           =   4
  106.       End
  107.       Begin Menu MUtil 
  108.          Caption         =   "&Pack Database"
  109.          Index           =   5
  110.       End
  111.    End
  112. End
  113. Option Explicit
  114.  
  115. '-- ModemWare Copyright (c) 1992 - 1994 Crescent Software.
  116. '   Written by Carl Franklin with help from and thanks to Bill Conley.
  117.  
  118. '001 10/17/94 - Fixed bug that caused Modem Number to be set to 1 when
  119. '               adding a new modem to a databse that had deleted modems.
  120.  
  121. Dim DataFileNum As Integer
  122. Dim CurModemNumber&
  123.  
  124. Sub BtnOkExit_Click (Index As Integer)
  125.     
  126. Dim PortNum As Integer, Timeout As Integer, ErrFlag As Integer, C As Integer
  127. Dim Result As Integer, ModemIndex As Integer, Dummy As Integer
  128. Dim OldCap$, T$, SetStr$, InitString$, Temp$, NextCmd$, ConfigFile$, AppName$
  129. Dim OldSettings$, Rec&, HighestBaud&
  130.  
  131.     OldCap$ = Caption
  132.     
  133.     If Index Then
  134.     MW_CancelFlag = True
  135.     Tag = ""
  136.     GoTo MWModemExit:
  137.     Else
  138.     InitModemWare
  139.     
  140.     '-- Find the Modem Number of the selected modem
  141.     T$ = List2.List(List2.ListIndex)
  142.     For Rec& = 1 To MW_NumRecords&
  143.         If MW_ModemInfo(Rec&).ModemName$ = T$ Then
  144.         Exit For
  145.         End If
  146.     Next
  147.  
  148.     '-- Try to configure the modem.
  149.     On Error Resume Next
  150.     If Trim$(T$) = "Null Modem" Then GoTo MWSaveModemData
  151.     
  152.     '-- Get InitString
  153.     InitString$ = ZTrim$(MW_ModemInfo(Rec&).InitString)
  154.  
  155.     '-- Get the port number
  156.     PortNum = Val(TbPort.Text)
  157.     If PortNum = 0 Then
  158.         MsgBox "No Port Specified"
  159.         Exit Sub
  160.     End If
  161.  
  162.     '-- Get the Settings
  163.     HighestBaud& = MW_ModemInfo(Rec&).HighestBaud
  164.     OldSettings$ = MW_Global_Comm1.Settings
  165.     If HighestBaud& >= 2400 Then
  166.         SetStr$ = "2400,N,8,1"
  167.     Else
  168.         SetStr$ = "300,N,8,1"
  169.     End If
  170.     
  171.     MW_Global_Comm1.CommPort = PortNum
  172.     MW_Global_Comm1.Settings = SetStr$
  173.     
  174.     On Error Resume Next
  175.     MW_Global_Comm1.PortOpen = True
  176.     If Err Then
  177.         MsgBox "COM" & LTrim$(Str$(PortNum)) & " is not available"
  178.         Exit Sub
  179.     End If
  180.  
  181.     '-- Set an initial Timeout value
  182.     Timeout = 30
  183.  
  184.     Caption = "Configuring your modem, please wait..."
  185.     ErrFlag = False
  186.  
  187.     Screen.MousePointer = 11
  188.  
  189.     Temp$ = RemoveCaret$(ZTrim$(InitString$))
  190.  
  191.     Do
  192.  
  193.         C = InStr(Temp$, MW_CR$)
  194.         If C Then
  195.         NextCmd$ = ZTrim$(Left$(Temp$, C))
  196.         If Len(Temp$) > C Then
  197.             Temp$ = Mid$(Temp$, C + 1)
  198.         End If
  199.         Else
  200.         Exit Do
  201.         End If
  202.  
  203. MWTryAgain:
  204.         
  205.         Call SendModemCmd(MW_Global_Comm1, NextCmd$, 1, Timeout, Result)
  206.         Select Case Result
  207.         Case MW_RESULT_OK
  208.             '-- Exit the loop
  209.             Exit Do
  210.         Case MW_RESULT_ERROR, MW_RESULT_TIMEOUT
  211.             If ErrFlag = False Then
  212.             Caption = "An Error occurred, trying again.."
  213.             Timeout = Timeout + 10
  214.             ErrFlag = True
  215.             GoTo MWTryAgain:
  216.             Else
  217.             Caption = OldCap$
  218.             Screen.MousePointer = 0
  219.             MsgBox "Error: You may have picked the wrong modem."
  220.             If MW_Global_Comm1.PortOpen Then MW_Global_Comm1.PortOpen = False
  221.             Exit Sub
  222.             End If
  223.         Case Else
  224.             Caption = OldCap$
  225.             Screen.MousePointer = 0
  226.             MsgBox MWErrorMsg$()
  227.             If MW_Global_Comm1.PortOpen Then MW_Global_Comm1.PortOpen = False
  228.             Exit Sub
  229.         End Select
  230.         
  231.         '-- Pause before trying again
  232.         MWPause 3
  233.     
  234.     Loop
  235.  
  236. MWSaveModemData:
  237.     '-- Save info in config file.
  238.     Caption = "Saving Information..."
  239.     
  240.     '-- Get the configuration INI filename
  241.     ConfigFile$ = GetConfigFileName$()
  242.     AppName$ = "Modem_" & MW_Global_Comm1.Tag
  243.     
  244.     '-- Get the Modem's Index in the MWCurModem array
  245.     ModemIndex = GetModemIndex(MW_Global_Comm1)
  246.     If ModemIndex = 0 Then
  247.         Stop
  248.     End If
  249.  
  250.     '-- Save Modem Number
  251.     Temp$ = LTrim$(Str$(MW_ModemInfo(Rec&).ModemNumber))
  252.     Dummy = MWPutConfigString(AppName$, "ModemNumber", Temp$, ConfigFile$)
  253.     MW_CurModem(ModemIndex).ModemNumber = MW_ModemInfo(Rec&).ModemNumber
  254.  
  255.     '-- Save Modem Name
  256.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).ModemName)
  257.     If Len(Temp$) = 0 Then Temp$ = "Generic 2400 Baud Modem"
  258.     Dummy = MWPutConfigString(AppName$, "ModemName", Temp$, ConfigFile$)
  259.     MW_CurModem(ModemIndex).ModemName = MW_ModemInfo(Rec&).ModemName
  260.  
  261.     '-- Save Highest Baud rate
  262.     Temp$ = LTrim$(Str$(MW_ModemInfo(Rec&).HighestBaud))
  263.     If Len(Temp$) = 0 Then Temp$ = "2400"
  264.     Dummy = MWPutConfigString(AppName$, "HighestBaud", Temp$, ConfigFile$)
  265.     MW_CurModem(ModemIndex).HighestBaud = MW_ModemInfo(Rec&).HighestBaud
  266.  
  267.     '-- Save Init String
  268.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).InitString)
  269.     If Len(Temp$) = 0 Then Temp$ = "AT^M"
  270.     Dummy = MWPutConfigString(AppName$, "InitString", Temp$, ConfigFile$)
  271.     MW_CurModem(ModemIndex).InitString = MW_ModemInfo(Rec&).InitString
  272.     
  273.     '-- Save Connect String
  274.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Connect)
  275.     If Len(Temp$) = 0 Then Temp$ = "CONNECT"
  276.     Dummy = MWPutConfigString(AppName$, "Connect", Temp$, ConfigFile$)
  277.     MW_CurModem(ModemIndex).Connect = MW_ModemInfo(Rec&).Connect
  278.  
  279.     '-- Save Attention String
  280.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Attention)
  281.     If Len(Temp$) = 0 Then Temp$ = "AT"
  282.     Dummy = MWPutConfigString(AppName$, "Attention", Temp$, ConfigFile$)
  283.     MW_CurModem(ModemIndex).Attention = MW_ModemInfo(Rec&).Attention
  284.     
  285.     '-- Save Hangup String
  286.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Hangup)
  287.     If Len(Temp$) = 0 Then Temp$ = "ATH^M"
  288.     Dummy = MWPutConfigString(AppName$, "Hangup", Temp$, ConfigFile$)
  289.     MW_CurModem(ModemIndex).Hangup = MW_ModemInfo(Rec&).Hangup
  290.  
  291.     '-- Save Reset String
  292.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Reset)
  293.     If Len(Temp$) = 0 Then Temp$ = "ATZ^M"
  294.     Dummy = MWPutConfigString(AppName$, "Reset", Temp$, ConfigFile$)
  295.     MW_CurModem(ModemIndex).Reset = MW_ModemInfo(Rec&).Reset
  296.     
  297.     '-- Save Answer String
  298.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Answer)
  299.     If Len(Temp$) = 0 Then Temp$ = "ATA^M"
  300.     Dummy = MWPutConfigString(AppName$, "Answer", Temp$, ConfigFile$)
  301.     MW_CurModem(ModemIndex).Answer = MW_ModemInfo(Rec&).Answer
  302.  
  303.     '-- Save Dial String
  304.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Dial)
  305.     If Len(Temp$) = 0 Then Temp$ = "ATDT"
  306.     Dummy = MWPutConfigString(AppName$, "Dial", Temp$, ConfigFile$)
  307.     MW_CurModem(ModemIndex).Dial = MW_ModemInfo(Rec&).Dial
  308.  
  309.     '-- Save Busy String
  310.     Temp$ = ZTrim$(MW_ModemInfo(Rec&).Busy)
  311.     If Len(Temp$) = 0 Then Temp$ = "BUSY"
  312.     Dummy = MWPutConfigString(AppName$, "Busy", Temp$, ConfigFile$)
  313.     MW_CurModem(ModemIndex).Busy = MW_ModemInfo(Rec&).Busy
  314.  
  315.     '-- Set the Tag to the port/modem spcecified
  316.     T$ = "COM" & LTrim$(Str$(PortNum)) & ": " & MW_ModemInfo(Rec&).ModemName
  317.     Tag = T$
  318.     
  319.     End If
  320.     
  321. MWModemExit:
  322.  
  323.     If MW_Global_Comm1.PortOpen Then
  324.     MW_Global_Comm1.PortOpen = False
  325.     End If
  326.  
  327.     Caption = OldCap$
  328.     Screen.MousePointer = 0
  329.     
  330.     Close DataFileNum
  331.     
  332.     Hide
  333.     
  334. End Sub
  335.  
  336. Sub Form_Activate ()
  337.  
  338.     TbPort.Text = Str$(MW_Global_Comm1.CommPort)
  339.     BtnOkExit(0).SetFocus
  340.     List1.SetFocus
  341.  
  342. End Sub
  343.  
  344. Sub Form_Load ()
  345.     
  346.     CenterForm Me
  347.     
  348.     Screen.MousePointer = 11
  349.  
  350.     LoadModemData
  351.  
  352.     Screen.MousePointer = 0
  353.     
  354. End Sub
  355.  
  356. Sub List1_Click ()
  357.     
  358. Dim L As Integer, LoPoint As Integer, HiPoint As Integer, LastPoint As Integer
  359. Dim List2Index As Integer
  360. Dim Criteria$, ModemBrand$, Counter&, Match&, CurRecord&, NewRec&
  361.  
  362.     Criteria$ = UCase$(List1.List(List1.ListIndex))
  363.  
  364.     '-- Find the first
  365.     CurRecord& = UBound(MW_LinkRecords)
  366.     L = CurRecord& \ 2
  367.     LoPoint = 1: HiPoint = CurRecord&
  368.     Do
  369.     LastPoint = L
  370.     ModemBrand$ = UCase$(Trim$(MW_LinkRecords(L).VendorName))
  371.     Select Case ModemBrand$
  372.         Case Is > Criteria$
  373.         HiPoint = L
  374.         L = LoPoint + ((L - LoPoint) \ 2)
  375.         If L = LastPoint And LastPoint > LoPoint Then L = L - 1
  376.         Case Is < Criteria$
  377.         LoPoint = L
  378.         L = L + ((HiPoint - L) \ 2)
  379.         If L = LastPoint And LastPoint < HiPoint Then L = L + 1
  380.         Case Else
  381.         Exit Do
  382.     End Select
  383.     Loop Until L = LoPoint Or L = HiPoint
  384.     CurRecord& = MW_LinkRecords(L).Record
  385.  
  386.     '-- Clear the list box
  387.     List2.Clear
  388.     
  389.     '-- Save record info and put the first modem into List2
  390.     Do
  391.     ModemBrand$ = UCase$(Trim$(MW_ModemInfo(CurRecord&).VendorName))
  392.     If ModemBrand$ = Criteria$ Then
  393.         If MW_ModemInfo(CurRecord&).DeletedFlag = 0 Then
  394.         List2.AddItem MW_ModemInfo(CurRecord&).ModemName
  395.         If MW_ModemInfo(CurRecord&).ModemNumber = CurModemNumber& Then
  396.             List2Index = List2.NewIndex
  397.         End If
  398.         End If
  399.         If MW_ModemInfo(CurRecord&).LinkRecord Then
  400.         CurRecord& = MW_ModemInfo(CurRecord&).LinkRecord
  401.         Else
  402.         CurRecord& = CurRecord& + 1
  403.         If CurRecord& > MW_NumRecords& Then Exit Do
  404.         End If
  405.     Else
  406.         Exit Do
  407.     End If
  408.     Loop
  409.     
  410.     List2.ListIndex = List2Index
  411.  
  412. End Sub
  413.  
  414. Sub List2_DblClick ()
  415.  
  416.     BtnOkExit(0) = True
  417.  
  418. End Sub
  419.  
  420. Sub LoadModemData ()
  421.     
  422. Dim Dummy As Integer, I As Integer, Linked As Integer, BrandNo As Integer, List1Index As Integer
  423. Dim ConfigFile$, AppName$, Temp$, ModemBrand$, LastBrand$
  424. Dim SrchRec&, Rec&
  425.  
  426.     If DataFileNum Then
  427.     Close DataFileNum
  428.     DataFileNum = 0
  429.     End If
  430.  
  431.     List1.Clear
  432.     List2.Clear
  433.  
  434.     '-- Get the configuration INI filename
  435.     ConfigFile$ = GetConfigFileName$()
  436.     
  437.     '-- All Modem Settings are listed under "[Modem_<Tag property>]" in the INI file.
  438.     AppName$ = "Modem_" & MW_Global_Comm1.Tag
  439.     
  440.     '-- Get Modem Number
  441.     Temp$ = Space$(10)
  442.     Dummy = MWGetConfigString(AppName$, "ModemNumber", "", Temp$, 10, ConfigFile$)
  443.     CurModemNumber& = Val(Temp$)
  444.     
  445.     '-- Open MODEMS.DAT
  446.     DataFile$ = App.Path
  447.     If Right$(DataFile$, 1) = "\" Then
  448.     DataFile$ = DataFile$ & "MODEMS.DAT"
  449.     Else
  450.     DataFile$ = DataFile$ & "\MODEMS.DAT"
  451.     End If
  452.     On Error Resume Next
  453.     DataFileNum = FreeFile
  454.     Open DataFile$ For Binary As DataFileNum
  455.     If Err Then
  456.     MsgBox "Can not find MODEMS.DAT. Please copy it to where your .EXE file is."
  457.     Unload MWModem
  458.     Exit Sub
  459.     End If
  460.     
  461.     '-- Read the total number of records
  462.     Get #DataFileNum, , MW_NumRecords&
  463.     
  464.     '-- Grow the array and read the data
  465.     ReDim MW_ModemInfo(1 To MW_NumRecords&) As MW_ModemInfoType
  466.     LastBrand$ = ""
  467.     NumBrands = 0
  468.     Rec& = 1
  469.     For I = 1 To MW_NumRecords&
  470.     Get #DataFileNum, , MW_ModemInfo(Rec&)
  471.     If Not MW_ModemInfo(Rec&).DeletedFlag Then
  472.         ModemBrand$ = Trim$(MW_ModemInfo(Rec&).VendorName)
  473.         BrandNo = SearchModemList(ModemBrand$)
  474.         If ModemBrand$ <> LastBrand$ And BrandNo = 0 Then
  475.         LastBrand$ = ModemBrand$
  476.         List1.AddItem ModemBrand$
  477.         List1.ItemData(List1.NewIndex) = Rec&
  478.         BrandNo = List1.NewIndex
  479.         End If
  480.         If CurModemNumber& = MW_ModemInfo(Rec&).ModemNumber Then
  481.         Temp$ = Trim$(MW_ModemInfo(Rec&).VendorName)
  482.         End If
  483.         Rec& = Rec& + 1
  484.     End If
  485.     Next
  486.     For I = Rec& To MW_NumRecords&
  487.     MW_ModemInfo(I).DeletedFlag = True
  488.     Next
  489.     Close DataFileNum
  490.  
  491.     NumBrands = List1.ListCount
  492.     ReDim MW_LinkRecords(1 To NumBrands)
  493.     For Rec& = 1 To NumBrands
  494.     MW_LinkRecords(Rec&).VendorName = List1.List(Rec& - 1)
  495.     MW_LinkRecords(Rec&).Record = List1.ItemData(Rec& - 1)
  496.     If Temp$ = Trim$(MW_LinkRecords(Rec&).VendorName) Then
  497.         List1Index = Rec& - 1
  498.     End If
  499.     Next
  500.  
  501.     '-- Set current List2 index (model)
  502.     If CurModemNumber& Then
  503.     List1.ListIndex = List1Index
  504.     Else
  505.     List1.ListIndex = 0
  506.     List2.ListIndex = 0
  507.     End If
  508.  
  509.     List1.TopIndex = List1.ListIndex
  510.     List2.TopIndex = List2.ListIndex
  511.  
  512. End Sub
  513.  
  514. Sub MUtil_Click (Index As Integer)
  515.  
  516. Dim Tr As Integer, BackupFileNum As Integer, TotalDeleted As Integer, Found As Integer
  517. Dim T$, Temp$, BackupFile$, Rec&, MRec&, I&
  518.  
  519.     Select Case Index
  520.     Case 1  '-- Edit Settings
  521.     
  522.         '-- Find the Modem Number of the selected modem
  523.         T$ = List2.List(List2.ListIndex)
  524.         For Rec& = 1 To MW_NumRecords&
  525.         If MW_ModemInfo(Rec&).ModemName = T$ Then
  526.             Exit For
  527.         End If
  528.         Next
  529.         If Rec& = MW_NumRecords& + 1 Then
  530.         Beep
  531.         MsgBox "Invalid Modem in database"
  532.         Exit Sub
  533.         End If
  534.     
  535.         MWModStr.ModemNumber.Caption = " " & Trim$(Str$(MW_ModemInfo(Rec&).ModemNumber))
  536.         MWModStr.HighestBaud.Text = " " & Trim$(Str$(MW_ModemInfo(Rec&).HighestBaud))
  537.     
  538.         Temp$ = MW_ModemInfo(Rec&).VendorName
  539.         MWModStr.Vendor.Text = " " & Trim$(Temp$)
  540.     
  541.         Temp$ = MW_ModemInfo(Rec&).ModemName
  542.         MWModStr.Model.Text = " " & Trim$(Temp$)
  543.     
  544.         Temp$ = MW_ModemInfo(Rec&).InitString
  545.         MWModStr.Init.Text = ZTrim$(Temp$)
  546.     
  547.         Temp$ = MW_ModemInfo(Rec&).Connect
  548.         MWModStr.Connect.Text = ZTrim$(Temp$)
  549.  
  550.         Temp$ = MW_ModemInfo(Rec&).Answer
  551.         MWModStr.Answer.Text = ZTrim$(Temp$)
  552.  
  553.         Temp$ = MW_ModemInfo(Rec&).Busy
  554.         MWModStr.Busy.Text = ZTrim$(Temp$)
  555.  
  556.         Temp$ = MW_ModemInfo(Rec&).Dial
  557.         MWModStr.Dial.Text = ZTrim$(Temp$)
  558.  
  559.         Temp$ = MW_ModemInfo(Rec&).Attention
  560.         MWModStr.Attention.Text = ZTrim$(Temp$)
  561.  
  562.         Temp$ = MW_ModemInfo(Rec&).Hangup
  563.         MWModStr.Hangup.Text = ZTrim$(Temp$)
  564.  
  565.         Temp$ = MW_ModemInfo(Rec&).Reset
  566.         MWModStr.ResetStr.Text = ZTrim$(Temp$)
  567.     
  568.         CurRec& = Rec&
  569.         MWModStr.Show 1
  570.     
  571.     Case 2  '-- Add Modem
  572.      
  573.         '-- Find the Modem Number of the selected modem
  574.         MRec& = MW_NumRecords& + 1
  575.         Rec& = MRec&
  576.         ReDim Preserve MW_ModemInfo(1 To Rec&) As MW_ModemInfoType
  577.         Do
  578.         MRec& = MRec& - 1
  579.         MW_ModemInfo(Rec&).ModemNumber = MW_ModemInfo(MRec&).ModemNumber + 1
  580.         Loop While MW_ModemInfo(MRec&).DeletedFlag
  581.         MW_ModemInfo(Rec&).HighestBaud = 57600
  582.         MW_ModemInfo(Rec&).VendorName = ""
  583.         MW_ModemInfo(Rec&).ModemName = ""
  584.         MW_ModemInfo(Rec&).InitString = "AT^M"
  585.  
  586.         MWModStr.ModemNumber.Caption = " " & Trim$(Str$(MW_ModemInfo(Rec&).ModemNumber))
  587.         MWModStr.HighestBaud.Text = " " & Trim$(Str$(MW_ModemInfo(Rec&).HighestBaud))
  588.     
  589.         Temp$ = MW_ModemInfo(Rec&).ModemName
  590.         MWModStr.Model.Text = " " & Trim$(Temp$)
  591.     
  592.         Temp$ = MW_ModemInfo(Rec&).InitString
  593.         MWModStr.Init.Text = ZTrim$(Temp$)
  594.     
  595.         CurRec& = -Rec&
  596.         MWModStr.Show 1
  597.     
  598.         If MWModStr.Tag = " " Then
  599.         '-- Add 1 to NumRecords
  600.         MW_NumRecords& = MW_NumRecords& + 1
  601.         '-- Reload the modem database
  602.         LoadModemData
  603.         End If
  604.     
  605.     Case 3  '-- Delete Modem
  606.     
  607.         '-- Find the Modem Number of the selected modem
  608.         T$ = List2.List(List2.ListIndex)
  609.         For Rec& = 1 To MW_NumRecords&
  610.         If MW_ModemInfo(Rec&).ModemName = T$ Then
  611.             Exit For
  612.         End If
  613.         Next
  614.         If Rec& = MW_NumRecords& + 1 Then Stop
  615.         
  616.         '-- Delete the item from the array.
  617.         MW_ModemInfo(Rec&).DeletedFlag = True
  618.         
  619.         '-- Mark the record in the file for deletion.
  620.         DataFile$ = App.Path & "\MODEMS.DAT"
  621.         On Error Resume Next
  622.         DataFileNum = FreeFile
  623.         Open DataFile$ For Binary As DataFileNum
  624.         Tr = True
  625.         Put #DataFileNum, 5 + (Rec& * LenModemType) - LenModemType, Tr
  626.         Close DataFileNum
  627.         
  628.         '-- Delete items from the listboxes
  629.         List2.RemoveItem List2.ListIndex
  630.         If List2.ListCount = 0 Then
  631.         List1.RemoveItem List1.ListIndex
  632.         End If
  633.         
  634.         List1_Click
  635.  
  636.     Case 5  '-- Pack Database
  637.         MousePointer = 11
  638.         '-- Make a copy of the database
  639.         BackupFile$ = App.Path & "\MODEMS.BAK"
  640.         FileCopy DataFile$, BackupFile$
  641.         Kill DataFile$
  642.  
  643.         '-- Open the backup file
  644.         BackupFileNum = FreeFile
  645.         Open BackupFile$ For Binary As BackupFileNum
  646.     
  647.         '-- Read the total number of records
  648.         Get #BackupFileNum, 1, MW_NumRecords&
  649.     
  650.         '-- Create an array to store them
  651.         ReDim Record(1 To MW_NumRecords&) As MW_ModemInfoType
  652.  
  653.         '-- Read all non-deleted records into Record()
  654.         MRec& = 1
  655.         For Rec& = 1 To MW_NumRecords&
  656.         Get #BackupFileNum, , Record(MRec&)
  657.         If Record(Rec&).DeletedFlag Then
  658.             TotalDeleted = TotalDeleted + 1
  659.         Else
  660.             MRec& = MRec& + 1
  661.         End If
  662.         Next
  663.  
  664.         '-- Subtract the total deleted from the number of records
  665.         MW_NumRecords& = MW_NumRecords& - TotalDeleted
  666.         
  667.         '-- Write the new total to MODEMS.DAT
  668.         DataFileNum = FreeFile
  669.         Open DataFile$ For Binary As DataFileNum
  670.         Put #DataFileNum, 1, MW_NumRecords&
  671.     
  672.         '-- Change the LinkRecords
  673.         For Rec& = 1 To MW_NumRecords&
  674.         If Record(Rec&).LinkRecord Then
  675.             Found = False
  676.             For I& = Rec& + 1 To MW_NumRecords&
  677.             If Record(I&).VendorName = Record(Rec&).VendorName Then
  678.                 Record(Rec&).LinkRecord = I&
  679.                 Found = True
  680.                 Exit For
  681.             End If
  682.             Next
  683.             If Not Found Then
  684.             Record(Rec&).LinkRecord = 0&
  685.             End If
  686.         End If
  687.         Put #DataFileNum, , Record(Rec&)
  688.         Next
  689.  
  690.         Close #DataFileNum, #BackupFileNum
  691.         Erase Record
  692.     
  693.         LoadModemData
  694.  
  695.         MousePointer = 0
  696.     End Select
  697.  
  698. End Sub
  699.  
  700. Function SearchModemList (Criteria$)
  701.     
  702. Dim I As Integer, L As Integer, LoPoint%, HiPoint%, CurRecord&, LastPoint%
  703. Dim Found%, ModemBrand$, ModemSearch$
  704.  
  705. If Criteria$ = List1.List(List1.NewIndex) Then
  706.     SearchModemList = List1.NewIndex + 1
  707.     Exit Function
  708. End If
  709.  
  710. If List1.ListCount > 1 Then
  711.     Found% = 0
  712.     ModemSearch$ = UCase$(Criteria$)
  713.     CurRecord& = List1.ListCount
  714.     L = CurRecord& \ 2
  715.     LoPoint = 0: HiPoint = CurRecord& - 1
  716.     Do
  717.     LastPoint = L
  718.     ModemBrand$ = UCase$(Trim$(List1.List(L)))
  719.     Select Case ModemBrand$
  720.         Case Is > ModemSearch$
  721.         HiPoint = L
  722.         L = LoPoint + ((L - LoPoint) \ 2)
  723.         If L = LastPoint And LastPoint > LoPoint Then L = L - 1
  724.         Case Is < ModemSearch$
  725.         LoPoint = L
  726.         L = L + ((HiPoint - L) \ 2)
  727.         If L = LastPoint And LastPoint < HiPoint Then L = L + 1
  728.         Case Else
  729.         Found% = L + 1
  730.         Exit Do
  731.     End Select
  732.     Loop Until L = LoPoint Or L = HiPoint
  733. End If
  734. SearchModemList = Found%
  735.  
  736. End Function
  737.  
  738.