home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol12n18.zip / FONSRC.ZIP / FONEWORD.FRM < prev    next >
Text File  |  1993-07-15  |  17KB  |  590 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "FONEWORD"
  5.    ClientHeight    =   6630
  6.    ClientLeft      =   2535
  7.    ClientTop       =   3240
  8.    ClientWidth     =   7275
  9.    ForeColor       =   &H00000000&
  10.    Height          =   7155
  11.    Left            =   2475
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   6630
  15.    ScaleWidth      =   7275
  16.    Top             =   2775
  17.    Width           =   7395
  18.    Begin CommandButton CommandAbout 
  19.       Caption         =   "&About"
  20.       Height          =   495
  21.       HelpContextID   =   5
  22.       Left            =   6180
  23.       TabIndex        =   20
  24.       Top             =   120
  25.       Width           =   975
  26.    End
  27.    Begin SSCommand ClipBtnOnly 
  28.       Font3D          =   3  'Inset w/light shading
  29.       ForeColor       =   &H00000000&
  30.       Height          =   615
  31.       HelpContextID   =   6
  32.       Left            =   6480
  33.       Picture         =   FONEWORD.FRX:0000
  34.       TabIndex        =   10
  35.       Top             =   960
  36.       Width           =   615
  37.    End
  38.    Begin SSCommand ClipBtnReal 
  39.       Font3D          =   3  'Inset w/light shading
  40.       ForeColor       =   &H00000000&
  41.       Height          =   615
  42.       HelpContextID   =   6
  43.       Left            =   4080
  44.       Picture         =   FONEWORD.FRX:083A
  45.       TabIndex        =   7
  46.       Top             =   960
  47.       Width           =   615
  48.    End
  49.    Begin SSCommand ClipBtnAll 
  50.       Font3D          =   3  'Inset w/light shading
  51.       ForeColor       =   &H00000000&
  52.       Height          =   615
  53.       HelpContextID   =   6
  54.       Left            =   1680
  55.       Picture         =   FONEWORD.FRX:1074
  56.       TabIndex        =   3
  57.       Top             =   960
  58.       Width           =   615
  59.    End
  60.    Begin CommandButton CommandAll 
  61.       BackColor       =   &H00000080&
  62.       Caption         =   "&All words"
  63.       Height          =   615
  64.       HelpContextID   =   1
  65.       Left            =   360
  66.       TabIndex        =   2
  67.       Top             =   960
  68.       Width           =   1335
  69.    End
  70.    Begin CommandButton CommandReal 
  71.       Caption         =   "&Real words"
  72.       Height          =   615
  73.       HelpContextID   =   2
  74.       Left            =   2760
  75.       TabIndex        =   6
  76.       Top             =   960
  77.       Width           =   1335
  78.    End
  79.    Begin CommandButton CommandOnly 
  80.       BackColor       =   &H00FF0000&
  81.       Caption         =   "&Only words"
  82.       Height          =   615
  83.       HelpContextID   =   3
  84.       Left            =   5160
  85.       TabIndex        =   9
  86.       Top             =   960
  87.       Width           =   1335
  88.    End
  89.    Begin CommandButton CommandBreak 
  90.       Caption         =   "&Break"
  91.       Height          =   495
  92.       HelpContextID   =   4
  93.       Left            =   4020
  94.       TabIndex        =   12
  95.       Top             =   120
  96.       Width           =   975
  97.    End
  98.    Begin CommandButton CommandHelp 
  99.       Caption         =   "&Help"
  100.       Default         =   -1  'True
  101.       Height          =   495
  102.       HelpContextID   =   5
  103.       Left            =   5100
  104.       TabIndex        =   13
  105.       Top             =   120
  106.       Width           =   975
  107.    End
  108.    Begin ListBox ListAll 
  109.       DragIcon        =   FONEWORD.FRX:18AE
  110.       FontBold        =   0   'False
  111.       FontItalic      =   0   'False
  112.       FontName        =   "Fixedsys"
  113.       FontSize        =   9
  114.       FontStrikethru  =   0   'False
  115.       FontUnderline   =   0   'False
  116.       Height          =   4530
  117.       HelpContextID   =   7
  118.       Left            =   360
  119.       MultiSelect     =   2  'Extended
  120.       TabIndex        =   5
  121.       Top             =   1620
  122.       Width           =   1935
  123.    End
  124.    Begin ListBox ListReal 
  125.       DragIcon        =   FONEWORD.FRX:1BB0
  126.       DragMode        =   1  'Automatic
  127.       FontBold        =   0   'False
  128.       FontItalic      =   0   'False
  129.       FontName        =   "Fixedsys"
  130.       FontSize        =   9
  131.       FontStrikethru  =   0   'False
  132.       FontUnderline   =   0   'False
  133.       Height          =   4530
  134.       HelpContextID   =   7
  135.       Left            =   2760
  136.       MultiSelect     =   2  'Extended
  137.       TabIndex        =   8
  138.       Top             =   1620
  139.       Width           =   1935
  140.    End
  141.    Begin ListBox ListOnly 
  142.       FontBold        =   0   'False
  143.       FontItalic      =   0   'False
  144.       FontName        =   "Fixedsys"
  145.       FontSize        =   9
  146.       FontStrikethru  =   0   'False
  147.       FontUnderline   =   0   'False
  148.       Height          =   4530
  149.       HelpContextID   =   7
  150.       Left            =   5160
  151.       MultiSelect     =   2  'Extended
  152.       TabIndex        =   11
  153.       Top             =   1620
  154.       Width           =   1935
  155.    End
  156.    Begin ListBox ListCover 
  157.       FontBold        =   0   'False
  158.       FontItalic      =   0   'False
  159.       FontName        =   "Fixedsys"
  160.       FontSize        =   9
  161.       FontStrikethru  =   0   'False
  162.       FontUnderline   =   0   'False
  163.       ForeColor       =   &H00000000&
  164.       Height          =   255
  165.       Left            =   2340
  166.       TabIndex        =   19
  167.       Top             =   900
  168.       Visible         =   0   'False
  169.       Width           =   195
  170.    End
  171.    Begin Gauge GaugeAll 
  172.       Autosize        =   -1  'True
  173.       BackColor       =   &H00C0C0C0&
  174.       ForeColor       =   &H0000FF00&
  175.       Height          =   5595
  176.       HelpContextID   =   8
  177.       InnerBottom     =   2
  178.       InnerLeft       =   1
  179.       InnerRight      =   2
  180.       InnerTop        =   2
  181.       Left            =   120
  182.       Max             =   100
  183.       NeedleWidth     =   1
  184.       Style           =   1  'Vertical Bar
  185.       TabIndex        =   14
  186.       TabStop         =   0   'False
  187.       Top             =   900
  188.       Width           =   135
  189.    End
  190.    Begin Gauge GaugeReal 
  191.       Autosize        =   -1  'True
  192.       BackColor       =   &H00C0C0C0&
  193.       ForeColor       =   &H000000FF&
  194.       Height          =   5595
  195.       HelpContextID   =   8
  196.       InnerBottom     =   2
  197.       InnerLeft       =   1
  198.       InnerRight      =   2
  199.       InnerTop        =   2
  200.       Left            =   2520
  201.       Max             =   100
  202.       NeedleWidth     =   1
  203.       Style           =   1  'Vertical Bar
  204.       TabIndex        =   15
  205.       TabStop         =   0   'False
  206.       Top             =   900
  207.       Width           =   135
  208.    End
  209.    Begin Gauge GaugeOnly 
  210.       Autosize        =   -1  'True
  211.       BackColor       =   &H00C0C0C0&
  212.       ForeColor       =   &H00FF0000&
  213.       Height          =   5595
  214.       HelpContextID   =   8
  215.       InnerBottom     =   2
  216.       InnerLeft       =   1
  217.       InnerRight      =   2
  218.       InnerTop        =   2
  219.       Left            =   4920
  220.       Max             =   100
  221.       NeedleWidth     =   1
  222.       Style           =   1  'Vertical Bar
  223.       TabIndex        =   16
  224.       TabStop         =   0   'False
  225.       Top             =   900
  226.       Width           =   135
  227.    End
  228.    Begin MaskEdBox PhoneEdit 
  229.       FontBold        =   -1  'True
  230.       FontItalic      =   0   'False
  231.       FontName        =   "MS Sans Serif"
  232.       FontSize        =   15
  233.       FontStrikethru  =   0   'False
  234.       FontUnderline   =   0   'False
  235.       Height          =   495
  236.       HelpContextID   =   10
  237.       Left            =   2100
  238.       Mask            =   "###-####"
  239.       MaxLength       =   8
  240.       PromptChar      =   "_"
  241.       TabIndex        =   1
  242.       Top             =   120
  243.       Width           =   1635
  244.    End
  245.    Begin Line Line1 
  246.       X1              =   0
  247.       X2              =   7260
  248.       Y1              =   720
  249.       Y2              =   720
  250.    End
  251.    Begin Label LabelOnly 
  252.       BorderStyle     =   1  'Fixed Single
  253.       Height          =   255
  254.       Left            =   5160
  255.       TabIndex        =   4
  256.       Top             =   6180
  257.       Width           =   1935
  258.    End
  259.    Begin Label LabelReal 
  260.       BorderStyle     =   1  'Fixed Single
  261.       Height          =   255
  262.       Left            =   2760
  263.       TabIndex        =   17
  264.       Top             =   6180
  265.       Width           =   1935
  266.    End
  267.    Begin Label LabelAll 
  268.       BorderStyle     =   1  'Fixed Single
  269.       Height          =   255
  270.       Left            =   360
  271.       TabIndex        =   18
  272.       Top             =   6180
  273.       Width           =   1935
  274.    End
  275.    Begin Label LabelPhone 
  276.       Caption         =   "Enter Phone Number:"
  277.       Height          =   315
  278.       Left            =   120
  279.       TabIndex        =   0
  280.       Top             =   240
  281.       Width           =   1875
  282.    End
  283.    Begin Shape ShapeOnly 
  284.       BackColor       =   &H00FF0000&
  285.       BackStyle       =   1  'Opaque
  286.       BorderColor     =   &H00000000&
  287.       FillColor       =   &H00FF0000&
  288.       FillStyle       =   0  'Solid
  289.       Height          =   5595
  290.       Left            =   5100
  291.       Top             =   900
  292.       Width           =   2055
  293.    End
  294.    Begin Shape ShapeReal 
  295.       BackColor       =   &H000000FF&
  296.       BackStyle       =   1  'Opaque
  297.       BorderColor     =   &H00000000&
  298.       FillColor       =   &H000000FF&
  299.       FillStyle       =   0  'Solid
  300.       Height          =   5595
  301.       Left            =   2700
  302.       Top             =   900
  303.       Width           =   2055
  304.    End
  305.    Begin Shape ShapeAll 
  306.       BackColor       =   &H0000FF00&
  307.       BackStyle       =   1  'Opaque
  308.       BorderColor     =   &H00000000&
  309.       FillColor       =   &H0000FF00&
  310.       FillStyle       =   0  'Solid
  311.       Height          =   5595
  312.       Left            =   300
  313.       Top             =   900
  314.       Width           =   2055
  315.    End
  316. End
  317. Option Explicit
  318. Dim A(50 To 57, 0 To 2)
  319. Dim MyDB As database
  320. Dim MySet As DynaSet
  321. Dim MinWord, Continue%
  322.  
  323. Declare Function sndPlaySound% Lib "MMSystem" (ByVal lpszSoundName$, ByVal wFlags%)
  324. Const SND_ASYNC = 1
  325. Const SND_NODEFAULT = 2
  326.  
  327. Sub AllCombos (ByVal S$, ByVal N%)
  328.   Dim Ch%
  329.   DoEvents
  330.   If Not Continue Then Exit Sub
  331.   If N% > Len(S$) Then
  332.     ListAll.AddItem S$
  333.     GaugeAll.Value = ListAll.ListCount
  334.   Else
  335.     Ch% = Asc(Mid$(S, N%, 1))
  336.     If (Ch% >= 50) And (Ch% <= 57) Then
  337.       Mid$(S$, N%, 1) = A(Ch%, 0)
  338.       AllCombos S$, N% + 1
  339.       Mid$(S$, N%, 1) = A(Ch%, 1)
  340.       AllCombos S$, N% + 1
  341.       Mid$(S$, N%, 1) = A(Ch%, 2)
  342.       AllCombos S$, N% + 1
  343.     Else
  344.       AllCombos S$, N% + 1
  345.     End If
  346.   End If
  347. End Sub
  348.  
  349. Sub ClipBtnAll_Click ()
  350.   ToClip ListAll
  351. End Sub
  352.  
  353. Sub ClipBtnOnly_Click ()
  354.   ToClip ListOnly
  355. End Sub
  356.  
  357. Sub ClipBtnReal_Click ()
  358.   ToClip ListReal
  359. End Sub
  360.  
  361. Sub Command1_Click ()
  362.   ' uh?
  363. End Sub
  364.  
  365. Sub CommandAbout_Click ()
  366.   Form2.Show
  367. End Sub
  368.  
  369. Sub CommandAll_Click ()
  370.   Dim N%, Success%
  371.   If Len(PhoneEdit.ClipText) = 0 Then Exit Sub
  372.   Continue = True
  373.   GaugeAll.Max = 1
  374.   ListAll.Clear
  375.   For N% = 1 To Len(PhoneEdit.ClipText)
  376.     Select Case Mid$(PhoneEdit.ClipText, N%, 1)
  377.       Case "0"
  378.       Case "1"
  379.       Case Else
  380.         GaugeAll.Max = GaugeAll.Max * 3
  381.     End Select
  382.   Next N%
  383.   ListCover.Visible = True
  384.   ListAll.Visible = False
  385.   Form1.MousePointer = 11
  386.   AllCombos PhoneEdit.ClipText, 1
  387.   Form1.MousePointer = 0
  388.   ListAll.Visible = True
  389.   ListCover.Visible = False
  390.   LabelAll.Caption = ListAll.ListCount + " Items"
  391.   Success = sndPlaySound("DING.WAV", SND_ASYNC + SND_NODEFAULT)
  392. End Sub
  393.  
  394. Sub CommandBreak_Click ()
  395.   Continue = False
  396. End Sub
  397.  
  398. Sub CommandHelp_Click ()
  399.   Dim Success%
  400.   Success% = Shell("WINHELP.EXE " + App.HelpFile, 1)
  401. End Sub
  402.  
  403. Sub CommandOnly_Click ()
  404.   Dim N%, Success%
  405.   If Len(PhoneEdit.ClipText) = 0 Then Exit Sub
  406.   Continue = True
  407.   GaugeOnly.Max = Len(PhoneEdit.ClipText)
  408.   ListOnly.Clear
  409.   GaugeOnly.Value = 0
  410.   Form1.MousePointer = 11
  411.   OnlyRealWords PhoneEdit.ClipText, ""
  412.   Form1.MousePointer = 0
  413.   LabelOnly.Caption = ListOnly.ListCount + " Items"
  414.   Success = sndPlaySound("DING.WAV", SND_ASYNC + SND_NODEFAULT)
  415. End Sub
  416.  
  417. Sub CommandReal_Click ()
  418.   Dim Success%
  419.   If Len(PhoneEdit.ClipText) = 0 Then Exit Sub
  420.   If Len(PhoneEdit.ClipText) < MinWord Then
  421.     MsgBox "You must enter at least " + MinWord + " digits", 0, "FoneWord Message"
  422.     Exit Sub
  423.   End If
  424.   Continue = True
  425.   ListReal.Clear
  426.   Form1.MousePointer = 11
  427.   FindRealWords
  428.   Form1.MousePointer = 0
  429.   LabelReal.Caption = ListReal.ListCount + " items"
  430.   Success = sndPlaySound("DING.WAV", SND_ASYNC + SND_NODEFAULT)
  431. End Sub
  432.  
  433. Function Decode$ (ByVal S$, ByVal Code%)
  434.   Dim N%, TempS$
  435.   If (Len(S) = 1) And InStr("01", S) Then
  436.     Decode = S
  437.   Else
  438.     TempS = ""
  439.     For N = 1 To Len(S)
  440.       TempS = TempS + A(Asc(Mid$(S, N, 1)), Code Mod 3)
  441.       Code = Code \ 3
  442.     Next N
  443.     Decode = TempS
  444.   End If
  445. End Function
  446.  
  447. Sub FindRealWords ()
  448.   Dim Start%, Num%, vLen%, Code%
  449.   Dim S$, SPart$, SDecode$
  450.   Dim Char As String * 1
  451.   vLen = Len(PhoneEdit.ClipText)
  452.   GaugeReal.Max = 1
  453.   For Num = MinWord To vLen
  454.     For Start = 1 To (vLen + 1 - Num)
  455.       GaugeReal.Max = GaugeReal.Max + 1
  456.     Next Start
  457.   Next Num
  458.   GaugeReal.Max = GaugeReal.Max - 1
  459.   GaugeReal.Value = 0
  460.   For Num = MinWord To vLen
  461.     For Start = 1 To (vLen + 1 - Num)
  462.       DoEvents
  463.       If Not Continue Then Exit Sub
  464.       SPart = Mid$(PhoneEdit.ClipText, Start, Num)
  465.       Char = "@"
  466.       SDecode = NextMatch(SPart, Char)
  467.       Do While SDecode <> ""
  468.         DoEvents
  469.         If Not Continue Then Exit Sub
  470.         S = ""
  471.         If Start > 1 Then S = Mid$(PhoneEdit.ClipText, 1, Start - 1) + " "
  472.         S = S + SDecode
  473.         If Start + Num <= vLen Then S = S + " " + Mid$(PhoneEdit.ClipText, Start + Num)
  474.         'S = PhoneEdit.ClipText
  475.         'Mid(S, Start, Num) = SDecode
  476.         ListReal.AddItem S
  477.         SDecode = NextMatch(SPart, Char)
  478.       Loop
  479.       GaugeReal.Value = GaugeReal.Value + 1
  480.     Next Start
  481.   Next Num
  482. End Sub
  483.  
  484. Sub Form_Load ()
  485.   Dim X%, Y%
  486.   Const FoneLets$ = "ABCDEFGHIJKLMNOPRSTUVWXY"
  487.   For X% = 0 To 7
  488.     For Y% = 0 To 2
  489.       A(X% + Asc("2"), Y%) = Mid(FoneLets$, X% * 3 + Y% + 1, 1)
  490.     Next Y%
  491.   Next X%
  492.   MinWord = 2
  493.   Set MyDB = OpenDatabase("D:\UTIL\FONE", True, True, "Paradox;")
  494.   Set MySet = MyDB.CreateDynaset("FONENUMS")
  495.   ListCover.Move ListAll.Left, ListAll.Top, ListAll.Width, ListAll.Height
  496.   ListCover.AddItem "One"
  497.   ListCover.AddItem "Moment"
  498.   ListCover.AddItem "Please..."
  499.   GaugeAll.Min = 0
  500.   GaugeReal.Min = 0
  501.   GaugeOnly.Min = 0
  502. End Sub
  503.  
  504. Function NextMatch$ (ByVal S$, C$)
  505.   Dim Criteria$, Code%
  506.   NextMatch = ""
  507.   If (Len(S) = 1) And (C = "@") And InStr("01", S) Then
  508.     NextMatch = S$
  509.   Else
  510.     If C = "@" Then
  511.       Criteria$ = "Foneword = '" + S + "'"
  512.     Else
  513.       Criteria$ = "Foneword = '" + S + C + "'"
  514.     End If
  515.     MySet.FindFirst Criteria
  516.     If Not MySet.NoMatch Then
  517.       Code = MySet("Code")
  518.       NextMatch = Decode(S, Code)
  519.     End If
  520.   End If
  521.   C$ = Chr$(Asc(C$) + 1)
  522. End Function
  523.  
  524. Sub OnlyRealWords (ByVal S$, ByVal SAcc$)
  525.   Dim N%, SPart$, SDecode$
  526.   Dim Char As String * 1
  527.   If Not Continue Then Exit Sub
  528.   For N = 1 To Len(S)
  529.     DoEvents
  530.     If Not Continue Then Exit Sub
  531.     SPart$ = Mid$(S, 1, N)
  532.     Char = "@"
  533.     SDecode = NextMatch(SPart, Char)
  534.     Do While SDecode <> ""
  535.       DoEvents
  536.       If Not Continue Then Exit Sub
  537.       If N = Len(S$) Then
  538.         ListOnly.AddItem Mid$(SAcc$ + " " + SDecode$, 2)
  539.       Else
  540.         OnlyRealWords Mid$(S$, N + 1), SAcc$ + " " + Left$(SDecode$, N)
  541.       End If
  542.       SDecode = NextMatch(SPart, Char)
  543.     Loop
  544.     GaugeOnly.Value = GaugeOnly.Value + 1
  545.   Next N
  546. End Sub
  547.  
  548. Sub PhoneEdit_Change ()
  549.   ListAll.Clear
  550.   ListReal.Clear
  551.   ListOnly.Clear
  552.   'NO ListCover.Clear
  553.   LabelAll.Caption = ""
  554.   LabelReal.Caption = ""
  555.   LabelOnly.Caption = ""
  556.   GaugeAll.Value = 0
  557.   GaugeReal.Value = 0
  558.   GaugeOnly.Value = 0
  559. End Sub
  560.  
  561. Sub PictureAll_Click ()
  562.   ToClip ListAll
  563. End Sub
  564.  
  565. Sub PictureOnly_Click ()
  566.   ToClip ListOnly
  567. End Sub
  568.  
  569. Sub PictureReal_Click ()
  570.   ToClip ListReal
  571. End Sub
  572.  
  573. Sub ToClip (L As ListBox)
  574.   Dim N%, Text$
  575.   Text$ = ""
  576.   For N% = 0 To L.ListCount - 1
  577.     If L.Selected(N) Then
  578.       Text$ = Text$ + L.List(N)
  579.       Text$ = Text$ + Chr$(13) + Chr$(10)
  580.     End If
  581.   Next N%
  582.   If Text$ = "" Then
  583.     MsgBox "No items are selected", 0
  584.   Else
  585.     Clipboard.Clear
  586.     Clipboard.SetText Text$
  587.   End If
  588. End Sub
  589.  
  590.