home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / fp_demo / gifpdemo.frm < prev    next >
Text File  |  1994-01-18  |  11KB  |  397 lines

  1. VERSION 2.00
  2. Begin Form frmMain 
  3.    Caption         =   "Gregg Irwin's Demo #1 of Software Source's ""FieldPack"""
  4.    ClientHeight    =   5100
  5.    ClientLeft      =   1350
  6.    ClientTop       =   2280
  7.    ClientWidth     =   7935
  8.    Height          =   5790
  9.    Left            =   1290
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   340
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   529
  14.    Top             =   1650
  15.    Width           =   8055
  16.    Begin CommandButton cmdBoth 
  17.       Caption         =   "&Both Path and Filename..."
  18.       Height          =   375
  19.       Left            =   5040
  20.       TabIndex        =   15
  21.       Top             =   930
  22.       Width           =   2565
  23.    End
  24.    Begin Frame fmeDelimitedStringFunctions 
  25.       Caption         =   "Manipulate a Delimited String "
  26.       Height          =   2925
  27.       Left            =   2760
  28.       TabIndex        =   6
  29.       Top             =   2070
  30.       Width           =   4935
  31.       Begin CommandButton cmdClearList 
  32.          Caption         =   "Cl&ear List"
  33.          Height          =   375
  34.          Left            =   120
  35.          TabIndex        =   0
  36.          Top             =   2340
  37.          Width           =   1560
  38.       End
  39.       Begin CommandButton cmdLoadList 
  40.          Caption         =   "&Load List"
  41.          Height          =   375
  42.          Left            =   120
  43.          TabIndex        =   1
  44.          Top             =   1860
  45.          Width           =   1560
  46.       End
  47.       Begin ListBox lstItems 
  48.          Height          =   1005
  49.          Left            =   1950
  50.          TabIndex        =   14
  51.          Top             =   1800
  52.          Width           =   2865
  53.       End
  54.       Begin TextBox txtTestString 
  55.          Height          =   555
  56.          Left            =   1950
  57.          MultiLine       =   -1  'True
  58.          ScrollBars      =   2  'Vertical
  59.          TabIndex        =   11
  60.          Text            =   "Sam, Don, Tony, Gregg"
  61.          Top             =   570
  62.          Width           =   2865
  63.       End
  64.       Begin TextBox txtDelimiter 
  65.          Height          =   345
  66.          Left            =   2880
  67.          MultiLine       =   -1  'True
  68.          TabIndex        =   10
  69.          Text            =   ","
  70.          Top             =   1260
  71.          Width           =   585
  72.       End
  73.       Begin CommandButton cmdWordCount 
  74.          Caption         =   "&Word Count"
  75.          Height          =   375
  76.          Left            =   120
  77.          TabIndex        =   9
  78.          Top             =   300
  79.          Width           =   1560
  80.       End
  81.       Begin CommandButton cmdParseString 
  82.          Caption         =   "Pa&rse String"
  83.          Height          =   375
  84.          Left            =   120
  85.          TabIndex        =   8
  86.          Top             =   780
  87.          Width           =   1560
  88.       End
  89.       Begin CommandButton cmdSplitString 
  90.          Caption         =   "&Split String"
  91.          Height          =   375
  92.          Left            =   120
  93.          TabIndex        =   7
  94.          Top             =   1260
  95.          Width           =   1560
  96.       End
  97.       Begin Label lblTestString 
  98.          Caption         =   "Test &String:"
  99.          Height          =   255
  100.          Left            =   1950
  101.          TabIndex        =   13
  102.          Top             =   330
  103.          Width           =   2835
  104.       End
  105.       Begin Label lblDelimiter 
  106.          Caption         =   "&Delimiter:"
  107.          Height          =   225
  108.          Left            =   1950
  109.          TabIndex        =   12
  110.          Top             =   1320
  111.          Width           =   915
  112.       End
  113.    End
  114.    Begin Frame fmePathAndFileOps 
  115.       Caption         =   "Manipulate a Filespec "
  116.       Height          =   1845
  117.       Left            =   4890
  118.       TabIndex        =   2
  119.       Top             =   90
  120.       Width           =   2805
  121.       Begin CommandButton cmdFilePath 
  122.          Caption         =   "File &Path..."
  123.          Height          =   375
  124.          Left            =   150
  125.          TabIndex        =   5
  126.          Top             =   360
  127.          Width           =   1245
  128.       End
  129.       Begin CommandButton cmdFilename 
  130.          Caption         =   "File &Name..."
  131.          Height          =   375
  132.          Left            =   1470
  133.          TabIndex        =   4
  134.          Top             =   360
  135.          Width           =   1245
  136.       End
  137.       Begin CommandButton cmdCollapsePath 
  138.          Caption         =   "&Collapse Path"
  139.          Height          =   375
  140.          Left            =   150
  141.          TabIndex        =   3
  142.          Top             =   1320
  143.          Width           =   2565
  144.       End
  145.    End
  146.    Begin CommonDialog cmdlgMain 
  147.       Left            =   0
  148.       Top             =   0
  149.    End
  150.    Begin Menu mnuMain 
  151.       Caption         =   "&File"
  152.       Index           =   0
  153.       Begin Menu mnuFile 
  154.          Caption         =   "E&xit"
  155.          Index           =   1
  156.       End
  157.    End
  158.    Begin Menu mnuMain 
  159.       Caption         =   "&Help"
  160.       Index           =   1
  161.       Begin Menu mnuHelp 
  162.          Caption         =   "&About..."
  163.          Index           =   0
  164.       End
  165.    End
  166. End
  167. Option Explicit
  168. DefInt A-Z
  169.  
  170. Sub cmdBoth_Click ()
  171.     Dim FileSpec$
  172.     Dim Filename$
  173.     Dim Path$
  174.     Dim ParseRtn%
  175.  
  176.     FileSpec$ = FileOpenDialog()
  177.     If Len(FileSpec$) Then
  178.         ParseRtn% = fpParsePathAndFilename(FileSpec$, Path$, Filename$)
  179.         Cls
  180.         Print "FileSpec: " & FileSpec$
  181.         Print "Path: " & Path$
  182.         Print "Filename: " & Filename$
  183.     End If
  184.  
  185. End Sub
  186.  
  187. Sub cmdClearList_Click ()
  188.  
  189.     lstItems.Clear
  190.  
  191. End Sub
  192.  
  193. Sub cmdCollapsePath_Click ()
  194. '------------------------------------------------
  195. '-- The Test Path names and lengths here were
  196. '   taken from "The Windows Interface: An
  197. '   Application Design Guide" pg. 143
  198. '------------------------------------------------
  199.     Dim CollapsedPath$
  200.     Dim i%
  201.     Dim MaxChars%
  202.     ReDim TestPath$(2)
  203.  
  204.     TestPath$(0) = "C:\Alpha\Beta\GammaAndDelta"
  205.     TestPath$(1) = "C:\Alpha\Beta\Gamma\Delta"
  206.     TestPath$(2) = "C:\Alpha\Beta\Gamm\Delta"
  207.     
  208.     Cls
  209.     For i% = 0 To UBound(TestPath$)
  210.         Print TestPath$(i%)
  211.         For MaxChars% = 16 To 19
  212.             CollapsedPath$ = fpCollapsePath$(TestPath$(i%), MaxChars%)
  213.             Print CollapsedPath$
  214.         Next MaxChars%
  215.         Print
  216.     Next i%
  217.  
  218. End Sub
  219.  
  220. Sub cmdFilename_Click ()
  221.     Dim FileSpec$
  222.     Dim Filename$
  223.  
  224.     FileSpec$ = FileOpenDialog()
  225.     If Len(FileSpec$) Then
  226.         Filename$ = fpFileFromFileSpec(FileSpec$)
  227.         Cls
  228.         Print "Filespec = " & FileSpec$
  229.         Print "File Name = " & Filename$
  230.     End If
  231.  
  232. End Sub
  233.  
  234. Sub cmdFilepath_Click ()
  235.     Dim FileSpec$
  236.     Dim Path$
  237.     
  238.     FileSpec$ = FileOpenDialog()
  239.     If Len(FileSpec$) Then
  240.         Path$ = fpPathFromFileSpec(FileSpec$)
  241.         Cls
  242.         Print "Filespec = " & FileSpec$
  243.         Print "Path = " & Path$
  244.     End If
  245.  
  246. End Sub
  247.  
  248. Sub cmdLoadList_Click ()
  249.     Dim TestString$
  250.     Dim Delimiter$
  251.     
  252.     TestString$ = txtTestString.Text
  253.     Delimiter$ = txtDelimiter.Text
  254.     Call fpLoadListFromDlmStr(lstItems, TestString$, Delimiter$)
  255.  
  256. End Sub
  257.  
  258. Sub cmdParseString_Click ()
  259.     Dim TestString$
  260.     Dim Delimiter$
  261.     Dim NumItemsParsed%
  262.     Dim arrParsedItems$()
  263.     Dim i%
  264.     Dim ErrMsg$
  265.     
  266.     TestString$ = txtTestString.Text
  267.     Delimiter$ = txtDelimiter.Text
  268.     NumItemsParsed% = fpParseString(TestString$, Delimiter$, arrParsedItems$())
  269.     '-- If NumItemsParsed% is >= 0 then no errors
  270.     '   occurred and we can proceed, otherwise we
  271.     '   need to examine the return value to see
  272.     '   what the error was.
  273.     If NumItemsParsed% >= 0 Then
  274.         Cls
  275.         Print TestString$
  276.         Print NumItemsParsed% & " Items Parsed"
  277.         For i% = 0 To UBound(arrParsedItems)
  278.             Print "Array Element " & i% & " = " & arrParsedItems$(i%)
  279.         Next i%
  280.     Else
  281.         Select Case NumItemsParsed%
  282.             Case FPERR_NULL_STRING
  283.                 ErrMsg$ = "Error: The Test String Parameter was Null."
  284.             Case FPERR_NULL_DELIMITER
  285.                 ErrMsg$ = "Error: The Delimiter Parameter was Null."
  286.         End Select
  287.         MsgBox ErrMsg$
  288.     End If
  289.  
  290. End Sub
  291.  
  292. Sub cmdSplitString_Click ()
  293.     Dim FileSpec$
  294.     Dim TestString$
  295.     Dim Delim$
  296.     Dim NumDelims%
  297.     Dim i%
  298.     Dim SplitPos%
  299.     Dim LeftHalf$, RightHalf$
  300.     Dim ErrMsg$
  301.     
  302.     TestString$ = txtTestString.Text
  303.     Delim$ = txtDelimiter.Text
  304.             
  305.     Cls
  306.     Print "TestString = " & TestString$
  307.     Print
  308.             
  309.     '-- Split at first delimiter
  310.     SplitPos% = fpSplitString%(TestString$, Delim$, FP_DELIM_FIRST, LeftHalf$, RightHalf$)
  311.     '-- Since this is the first time we're using
  312.     '   the parameters we'll check our return code
  313.     '   to see if they're invalid. Obviously it
  314.     '   would be prefereable to check them before
  315.     '   we do anything, but this way we can see if
  316.     '   our return codes are accurate.<g>
  317.     If SplitPos% < 0 Then
  318.         Select Case SplitPos%
  319.             Case FPERR_NULL_STRING
  320.                 ErrMsg$ = "Error: The Test String Parameter was Null."
  321.             Case FPERR_NULL_DELIMITER
  322.                 ErrMsg$ = "Error: The Delimiter Parameter was Null."
  323.         End Select
  324.         MsgBox ErrMsg$
  325.         '-- No need to go on
  326.         Exit Sub
  327.     End If
  328.     Print "Split at First Delimiter"
  329.     Print "Left Side = " & LeftHalf$
  330.     Print "Right Side = " & RightHalf$
  331.     Print
  332.             
  333.     '-- Split at last delim
  334.     SplitPos% = fpSplitString%(TestString$, Delim$, FP_DELIM_LAST, LeftHalf$, RightHalf$)
  335.     Print "Split at Last Delimiter"
  336.     Print "Left Side = " & LeftHalf$
  337.     Print "Right Side = " & RightHalf$
  338.     Print
  339.             
  340.     '-- Split at each delim in string
  341.     NumDelims% = DS_CountDlms(TestString$, Delim$)
  342.     For i% = 1 To NumDelims%
  343.         SplitPos% = fpSplitString%(TestString$, Delim$, i%, LeftHalf$, RightHalf$)
  344.         Print "Split at Delimiter " & i%
  345.         Print "Left Side = " & LeftHalf$
  346.         Print "Right Side = " & RightHalf$
  347.         Print
  348.     Next i%
  349.  
  350.  
  351. End Sub
  352.  
  353. Sub cmdWordCount_Click ()
  354.     Dim TestString$
  355.     Dim Count$
  356.     Dim Msg$
  357.     Dim ErrMsg$
  358.     Dim NumWords&
  359.     
  360.     TestString$ = txtTestString.Text
  361.     NumWords& = fpWordCount(TestString$)
  362.     If NumWords& <> FPERR_NULL_STRING Then
  363.         Count$ = " contains " & Format$(NumWords&, "#,##0") & " Words"
  364.     
  365.         Msg$ = "The test string" & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)
  366.     
  367.         Msg$ = Msg$ & Chr$(34) & TestString$ & Chr$(34) & Chr$(13) & Chr$(10)
  368.         Msg$ = Msg$ & Chr$(13) & Chr$(10)
  369.         Msg$ = Msg$ & Count$
  370.         MsgBox Msg$, 0, "Word Count Test"
  371.     Else
  372.         ErrMsg$ = "Error: The Test String Parameter was Null."
  373.         MsgBox ErrMsg$
  374.     End If
  375.  
  376. End Sub
  377.  
  378. Sub Form_Load ()
  379.     Dim fpRtn%
  380.  
  381.     fpRtn% = FP_Password("Sorry, you'll have to register to get a proper password.")
  382.  
  383. End Sub
  384.  
  385. Sub mnuFile_Click (Index As Integer)
  386.  
  387.     If Index = 1 Then Unload Me
  388.  
  389. End Sub
  390.  
  391. Sub mnuHelp_Click (Index As Integer)
  392.  
  393.     frmAbout.Show MODAL
  394.  
  395. End Sub
  396.  
  397.