home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / text_utl / parsed / parse.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-04  |  10.7 KB  |  323 lines

  1. VERSION 2.00
  2. Begin Form frmParse 
  3.    Caption         =   "Parse Demo - Parse and Process Text"
  4.    ClientHeight    =   5685
  5.    ClientLeft      =   75
  6.    ClientTop       =   675
  7.    ClientWidth     =   9450
  8.    Height          =   6405
  9.    Icon            =   PARSE.FRX:0000
  10.    Left            =   0
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   540
  13.    ScaleWidth      =   540
  14.    Top             =   30
  15.    Width           =   9600
  16.    Begin CommandButton cmdReturn 
  17.       Caption         =   "&Return To Main Menu"
  18.       Height          =   435
  19.       Left            =   6240
  20.       TabIndex        =   15
  21.       Top             =   420
  22.       Width           =   2715
  23.    End
  24.    Begin CommandButton cmdChange 
  25.       Caption         =   "&Change"
  26.       FontBold        =   0   'False
  27.       FontItalic      =   0   'False
  28.       FontName        =   "MS Sans Serif"
  29.       FontSize        =   8.25
  30.       FontStrikethru  =   0   'False
  31.       FontUnderline   =   0   'False
  32.       Height          =   315
  33.       Left            =   4440
  34.       TabIndex        =   14
  35.       Top             =   660
  36.       Width           =   915
  37.    End
  38.    Begin VScrollBar VScroll1 
  39.       Height          =   315
  40.       Left            =   8880
  41.       Max             =   32000
  42.       Min             =   1
  43.       TabIndex        =   12
  44.       TabStop         =   0   'False
  45.       Top             =   1620
  46.       Value           =   1000
  47.       Width           =   255
  48.    End
  49.    Begin CommandButton cmdProcess 
  50.       Caption         =   "&Process Text"
  51.       Height          =   390
  52.       Left            =   6810
  53.       TabIndex        =   1
  54.       Top             =   2100
  55.       Width           =   1965
  56.    End
  57.    Begin TextBox txtFileContents 
  58.       Height          =   3060
  59.       Left            =   270
  60.       MultiLine       =   -1  'True
  61.       ScrollBars      =   3  'Both
  62.       TabIndex        =   2
  63.       Top             =   1995
  64.       Width           =   5910
  65.    End
  66.    Begin CommandButton cmdSelectFile 
  67.       Caption         =   "&Select File"
  68.       Height          =   345
  69.       Left            =   360
  70.       TabIndex        =   0
  71.       Top             =   1500
  72.       Width           =   1650
  73.    End
  74.    Begin Label lblCurFunc 
  75.       Caption         =   "lblCurFunc"
  76.       FontBold        =   -1  'True
  77.       FontItalic      =   -1  'True
  78.       FontName        =   "MS Sans Serif"
  79.       FontSize        =   9.75
  80.       FontStrikethru  =   0   'False
  81.       FontUnderline   =   0   'False
  82.       ForeColor       =   &H00000000&
  83.       Height          =   375
  84.       Left            =   840
  85.       TabIndex        =   13
  86.       Top             =   660
  87.       Width           =   3375
  88.    End
  89.    Begin Shape Shape2 
  90.       Height          =   4230
  91.       Left            =   120
  92.       Shape           =   4  'Rounded Rectangle
  93.       Top             =   1320
  94.       Width           =   9225
  95.    End
  96.    Begin Label lblReDimInt 
  97.       BorderStyle     =   1  'Fixed Single
  98.       Caption         =   "10"
  99.       ForeColor       =   &H00C0C0C0&
  100.       Height          =   285
  101.       Left            =   8130
  102.       TabIndex        =   11
  103.       Top             =   1635
  104.       Width           =   600
  105.    End
  106.    Begin Label Label2 
  107.       Caption         =   "ReDim Interval:"
  108.       ForeColor       =   &H00C0C0C0&
  109.       Height          =   270
  110.       Left            =   6720
  111.       TabIndex        =   10
  112.       Top             =   1635
  113.       Width           =   1425
  114.    End
  115.    Begin Label lblLineCountAdj 
  116.       BorderStyle     =   1  'Fixed Single
  117.       Height          =   795
  118.       Left            =   6495
  119.       TabIndex        =   9
  120.       Top             =   3345
  121.       Width           =   2655
  122.    End
  123.    Begin Label lblLineCount 
  124.       BorderStyle     =   1  'Fixed Single
  125.       Height          =   690
  126.       Left            =   6495
  127.       TabIndex        =   8
  128.       Top             =   2595
  129.       Width           =   2655
  130.    End
  131.    Begin Label lblWordCount 
  132.       BorderStyle     =   1  'Fixed Single
  133.       Height          =   330
  134.       Left            =   6495
  135.       TabIndex        =   7
  136.       Top             =   4215
  137.       Width           =   2655
  138.    End
  139.    Begin Label Label1 
  140.       Alignment       =   2  'Center
  141.       BorderStyle     =   1  'Fixed Single
  142.       Caption         =   "Currently Selected Function"
  143.       Height          =   315
  144.       Left            =   1740
  145.       TabIndex        =   6
  146.       Top             =   180
  147.       Width           =   2475
  148.    End
  149.    Begin Shape Shape1 
  150.       Height          =   1215
  151.       Left            =   420
  152.       Shape           =   4  'Rounded Rectangle
  153.       Top             =   60
  154.       Width           =   5160
  155.    End
  156.    Begin Label lblFileLen 
  157.       BorderStyle     =   1  'Fixed Single
  158.       Height          =   330
  159.       Left            =   360
  160.       TabIndex        =   5
  161.       Top             =   5145
  162.       Width           =   3090
  163.    End
  164.    Begin Label lblInfo 
  165.       BorderStyle     =   1  'Fixed Single
  166.       Height          =   750
  167.       Left            =   6495
  168.       TabIndex        =   4
  169.       Top             =   4605
  170.       Width           =   2655
  171.    End
  172.    Begin Label lblFileName 
  173.       BorderStyle     =   1  'Fixed Single
  174.       Height          =   300
  175.       Left            =   2160
  176.       TabIndex        =   3
  177.       Top             =   1560
  178.       Width           =   4335
  179.    End
  180.    Begin Menu mnuExit 
  181.       Caption         =   "E&xit!"
  182.    End
  183. Option Explicit
  184. Sub cmdChange_Click ()
  185.     Me.WindowState = MINIMIZED
  186.     Screen.MousePointer = HOURGLASS
  187.     SetfrmSelect (lblCurFunc), FLG_PROCPARSE
  188. End Sub
  189. Sub cmdProcess_Click ()
  190.    Dim LineCount%, LineCountAdj%, WordCount%
  191.    Dim ret%, SetReDim%
  192.    Dim NewString$
  193.    Dim crlf$, SpaceChar$
  194.    Dim DynArray$()
  195.    Dim CurTime!, NewTime!, TotalTime!
  196.    'set delimiters
  197.    crlf$ = Chr$(13) & Chr$(10)
  198.    SpaceChar$ = Chr$(32)
  199.    'clear previous displayed info
  200.    lblLineCount = ""
  201.    lblLineCountAdj = ""
  202.    lblWordCount = ""
  203.    lblInfo = ""
  204.    'allow these labels to clear
  205.    DoEvents
  206.    'NOTE: In a previous program
  207.    'I also tested QuickPak Professional parse routines
  208.    'and VideoSoft VSAWK (VSVBX). If
  209.    'you come up with a faster routine, just add it to
  210.    'this project and create another optParse radio button
  211.    'for it on frmSelect.
  212.    Screen.MousePointer = HOURGLASS
  213.    'call appropriate proc.
  214.    If lblCurFunc = "ParseAndFillArray1%()" Then
  215.    'use ParseAndFillArray1% function
  216.       CurTime! = Timer
  217.       LineCount% = ParseAndFillArray1%((txtFileContents), crlf$, DynArray$())
  218.       'build a new string with crlf's replaced by Chr$(32) 's
  219.       'LineCountAdj% passed byref. and filled with adjusted value for # lines
  220.       NewString$ = ProcessArray$(DynArray$(), Chr$(32), LineCountAdj%)
  221.       'erase array storage
  222.       Erase DynArray$
  223.       'get word count by passing processed string with all spaces
  224.       WordCount% = ParseAndFillArray1%(NewString$, SpaceChar$, DynArray$())
  225.       NewTime! = Timer
  226.       Screen.MousePointer = DEFAULT
  227.       MsgBox "ParseAndFillArray1% calls Completed.", MB_ICONINFORMATION
  228.    ElseIf lblCurFunc = "ParseAndFillArray2%()" Then
  229.       'get ReDim setting from user
  230.       'assign the Redim setting
  231.       SetReDim% = ret%
  232.       CurTime! = Timer
  233.       LineCount% = ParseAndFillArray2%((txtFileContents), crlf$, DynArray$(), CInt(lblReDimInt))
  234.       'build a new string with crlf's replaced by Chr$(32) 's
  235.       'LineCountAdj% passed byref. and filled with adjusted value for # lines
  236.       NewString$ = ProcessArray$(DynArray$(), Chr$(32), LineCountAdj%)
  237.       'erase array storage
  238.       Erase DynArray$
  239.       'get word count by passing processed string with all spaces
  240.       WordCount% = ParseAndFillArray2%(NewString$, SpaceChar$, DynArray$(), 10)
  241.       NewTime! = Timer
  242.       Screen.MousePointer = DEFAULT
  243.       MsgBox "ParseAndFillArray2%  calls Completed.", MB_ICONINFORMATION
  244.    Else 'lblCurFunc = "Pars&eAndFill&ListBox%()"
  245.       CurTime! = Timer
  246.       LineCount% = ParseAndFillListBox%((txtFileContents), crlf$, frmListBox!List1)
  247.       
  248.       'build a new string with crlf's replaced by spaces
  249.       'LineCountAdj% passed byref. and filled with adjusted value for # lines
  250.       NewString$ = ProcessList$(frmListBox!List1, Chr$(32), LineCountAdj%)
  251.       
  252.       frmListBox!List1.Clear
  253.       'get word count by passing processed string with all spaces
  254.       WordCount% = ParseAndFillListBox%(NewString$, SpaceChar$, frmListBox!List1)
  255.       NewTime! = Timer
  256.       Screen.MousePointer = DEFAULT
  257.       MsgBox "ParseAndFillListBox% calls Completed.", MB_ICONINFORMATION
  258.       'clear list again since it may be used later here or in frmMultiDelim
  259.       frmListBox!List1.Clear
  260.    End If
  261.    'display the info
  262.    'line count
  263.    lblLineCount = "Number of Lines (including extra CRLF pairs): " & CStr(LineCount%)
  264.    'adjusted line count
  265.    lblLineCountAdj = "Adjusted Number of Lines (Extra CRLF pairs were removed): " & CStr(LineCountAdj%)
  266.    'word count
  267.    lblWordCount = "Number of Words: " & CStr(WordCount%)
  268.    'total time elapsed
  269.    TotalTime! = NewTime! - CurTime!
  270.    If TotalTime! >= .05 Then
  271.       lblInfo = "Total execution time to fill array with words: " & Format$(TotalTime!, "###.###") & " s."
  272.    Else
  273.       lblInfo = "Total execution time to fill array with words: < 50 ms"
  274.    End If
  275. End Sub
  276. Sub cmdReturn_Click ()
  277.     Me.WindowState = MINIMIZED
  278.     frmMain.Show
  279.     frmMain.WindowState = NORMAL
  280. End Sub
  281. Sub cmdSelectFile_Click ()
  282.    Screen.MousePointer = HOURGLASS
  283.    frmSelFile.Show MODAL
  284. End Sub
  285. Sub Form_Activate ()
  286.    Screen.MousePointer = DEFAULT
  287.     'set controls related to array resizing for
  288.     'ParseAndFillArray2%()
  289.     If lblCurFunc = "ParseAndFillArray2%()" Then
  290.         Label2.ForeColor = BLACK
  291.         lblReDimInt.ForeColor = BLACK
  292.         VScroll1.Enabled = True
  293.     Else
  294.         Label2.ForeColor = LIGHT_GRAY
  295.         lblReDimInt.ForeColor = LIGHT_GRAY
  296.         VScroll1.Enabled = False
  297.     End If
  298.             
  299. End Sub
  300. Sub mnuExit_Click ()
  301.     EndProg
  302. End Sub
  303. Sub VScroll1_Change ()
  304.     Static OldVScrollValue%
  305.     Static vsChangeCt%
  306.     vsChangeCt% = vsChangeCt% + 1
  307.     'change the redim label based on the change in the scrollbar
  308.     'value from the last scrollbar change event
  309.     If VScroll1.Value > OldVScrollValue% And vsChangeCt% > 1 Then
  310.     'set 1 less
  311.         If CInt(lblReDimInt) > 5 Then
  312.             lblReDimInt = CStr(CInt(lblReDimInt) - 1)
  313.         End If
  314.     Else  'VScroll1.Value < OldVScrollValue% Then
  315.     'increase by 1
  316.         If CInt(lblReDimInt) < 200 Then
  317.             lblReDimInt = CStr(CInt(lblReDimInt) + 1)
  318.         End If
  319.     End If
  320.     'save scroll value in static var for next VScroll1_Change
  321.     OldVScrollValue% = VScroll1.Value
  322. End Sub
  323.