home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / FP_DEMO / GIFPDEMO.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-01-18  |  11.1 KB  |  355 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. Option Explicit
  167. DefInt A-Z
  168. Sub cmdBoth_Click ()
  169.     Dim FileSpec$
  170.     Dim Filename$
  171.     Dim Path$
  172.     Dim ParseRtn%
  173.     FileSpec$ = FileOpenDialog()
  174.     If Len(FileSpec$) Then
  175.         ParseRtn% = fpParsePathAndFilename(FileSpec$, Path$, Filename$)
  176.         Cls
  177.         Print "FileSpec: " & FileSpec$
  178.         Print "Path: " & Path$
  179.         Print "Filename: " & Filename$
  180.     End If
  181. End Sub
  182. Sub cmdClearList_Click ()
  183.     lstItems.Clear
  184. End Sub
  185. Sub cmdCollapsePath_Click ()
  186. '------------------------------------------------
  187. '-- The Test Path names and lengths here were
  188. '   taken from "The Windows Interface: An
  189. '   Application Design Guide" pg. 143
  190. '------------------------------------------------
  191.     Dim CollapsedPath$
  192.     Dim i%
  193.     Dim MaxChars%
  194.     ReDim TestPath$(2)
  195.     TestPath$(0) = "C:\Alpha\Beta\GammaAndDelta"
  196.     TestPath$(1) = "C:\Alpha\Beta\Gamma\Delta"
  197.     TestPath$(2) = "C:\Alpha\Beta\Gamm\Delta"
  198.     Cls
  199.     For i% = 0 To UBound(TestPath$)
  200.         Print TestPath$(i%)
  201.         For MaxChars% = 16 To 19
  202.             CollapsedPath$ = fpCollapsePath$(TestPath$(i%), MaxChars%)
  203.             Print CollapsedPath$
  204.         Next MaxChars%
  205.         Print
  206.     Next i%
  207. End Sub
  208. Sub cmdFilename_Click ()
  209.     Dim FileSpec$
  210.     Dim Filename$
  211.     FileSpec$ = FileOpenDialog()
  212.     If Len(FileSpec$) Then
  213.         Filename$ = fpFileFromFileSpec(FileSpec$)
  214.         Cls
  215.         Print "Filespec = " & FileSpec$
  216.         Print "File Name = " & Filename$
  217.     End If
  218. End Sub
  219. Sub cmdFilepath_Click ()
  220.     Dim FileSpec$
  221.     Dim Path$
  222.     FileSpec$ = FileOpenDialog()
  223.     If Len(FileSpec$) Then
  224.         Path$ = fpPathFromFileSpec(FileSpec$)
  225.         Cls
  226.         Print "Filespec = " & FileSpec$
  227.         Print "Path = " & Path$
  228.     End If
  229. End Sub
  230. Sub cmdLoadList_Click ()
  231.     Dim TestString$
  232.     Dim Delimiter$
  233.     TestString$ = txtTestString.Text
  234.     Delimiter$ = txtDelimiter.Text
  235.     Call fpLoadListFromDlmStr(lstItems, TestString$, Delimiter$)
  236. End Sub
  237. Sub cmdParseString_Click ()
  238.     Dim TestString$
  239.     Dim Delimiter$
  240.     Dim NumItemsParsed%
  241.     Dim arrParsedItems$()
  242.     Dim i%
  243.     Dim ErrMsg$
  244.     TestString$ = txtTestString.Text
  245.     Delimiter$ = txtDelimiter.Text
  246.     NumItemsParsed% = fpParseString(TestString$, Delimiter$, arrParsedItems$())
  247.     '-- If NumItemsParsed% is >= 0 then no errors
  248.     '   occurred and we can proceed, otherwise we
  249.     '   need to examine the return value to see
  250.     '   what the error was.
  251.     If NumItemsParsed% >= 0 Then
  252.         Cls
  253.         Print TestString$
  254.         Print NumItemsParsed% & " Items Parsed"
  255.         For i% = 0 To UBound(arrParsedItems)
  256.             Print "Array Element " & i% & " = " & arrParsedItems$(i%)
  257.         Next i%
  258.     Else
  259.         Select Case NumItemsParsed%
  260.             Case FPERR_NULL_STRING
  261.                 ErrMsg$ = "Error: The Test String Parameter was Null."
  262.             Case FPERR_NULL_DELIMITER
  263.                 ErrMsg$ = "Error: The Delimiter Parameter was Null."
  264.         End Select
  265.         MsgBox ErrMsg$
  266.     End If
  267. End Sub
  268. Sub cmdSplitString_Click ()
  269.     Dim FileSpec$
  270.     Dim TestString$
  271.     Dim Delim$
  272.     Dim NumDelims%
  273.     Dim i%
  274.     Dim SplitPos%
  275.     Dim LeftHalf$, RightHalf$
  276.     Dim ErrMsg$
  277.     TestString$ = txtTestString.Text
  278.     Delim$ = txtDelimiter.Text
  279.             
  280.     Cls
  281.     Print "TestString = " & TestString$
  282.     Print
  283.             
  284.     '-- Split at first delimiter
  285.     SplitPos% = fpSplitString%(TestString$, Delim$, FP_DELIM_FIRST, LeftHalf$, RightHalf$)
  286.     '-- Since this is the first time we're using
  287.     '   the parameters we'll check our return code
  288.     '   to see if they're invalid. Obviously it
  289.     '   would be prefereable to check them before
  290.     '   we do anything, but this way we can see if
  291.     '   our return codes are accurate.<g>
  292.     If SplitPos% < 0 Then
  293.         Select Case SplitPos%
  294.             Case FPERR_NULL_STRING
  295.                 ErrMsg$ = "Error: The Test String Parameter was Null."
  296.             Case FPERR_NULL_DELIMITER
  297.                 ErrMsg$ = "Error: The Delimiter Parameter was Null."
  298.         End Select
  299.         MsgBox ErrMsg$
  300.         '-- No need to go on
  301.         Exit Sub
  302.     End If
  303.     Print "Split at First Delimiter"
  304.     Print "Left Side = " & LeftHalf$
  305.     Print "Right Side = " & RightHalf$
  306.     Print
  307.             
  308.     '-- Split at last delim
  309.     SplitPos% = fpSplitString%(TestString$, Delim$, FP_DELIM_LAST, LeftHalf$, RightHalf$)
  310.     Print "Split at Last Delimiter"
  311.     Print "Left Side = " & LeftHalf$
  312.     Print "Right Side = " & RightHalf$
  313.     Print
  314.             
  315.     '-- Split at each delim in string
  316.     NumDelims% = DS_CountDlms(TestString$, Delim$)
  317.     For i% = 1 To NumDelims%
  318.         SplitPos% = fpSplitString%(TestString$, Delim$, i%, LeftHalf$, RightHalf$)
  319.         Print "Split at Delimiter " & i%
  320.         Print "Left Side = " & LeftHalf$
  321.         Print "Right Side = " & RightHalf$
  322.         Print
  323.     Next i%
  324. End Sub
  325. Sub cmdWordCount_Click ()
  326.     Dim TestString$
  327.     Dim Count$
  328.     Dim Msg$
  329.     Dim ErrMsg$
  330.     Dim NumWords&
  331.     TestString$ = txtTestString.Text
  332.     NumWords& = fpWordCount(TestString$)
  333.     If NumWords& <> FPERR_NULL_STRING Then
  334.         Count$ = " contains " & Format$(NumWords&, "#,##0") & " Words"
  335.         Msg$ = "The test string" & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)
  336.         Msg$ = Msg$ & Chr$(34) & TestString$ & Chr$(34) & Chr$(13) & Chr$(10)
  337.         Msg$ = Msg$ & Chr$(13) & Chr$(10)
  338.         Msg$ = Msg$ & Count$
  339.         MsgBox Msg$, 0, "Word Count Test"
  340.     Else
  341.         ErrMsg$ = "Error: The Test String Parameter was Null."
  342.         MsgBox ErrMsg$
  343.     End If
  344. End Sub
  345. Sub Form_Load ()
  346.     Dim fpRtn%
  347.     fpRtn% = FP_Password("Sorry, you'll have to register to get a proper password.")
  348. End Sub
  349. Sub mnuFile_Click (Index As Integer)
  350.     If Index = 1 Then Unload Me
  351. End Sub
  352. Sub mnuHelp_Click (Index As Integer)
  353.     frmAbout.Show MODAL
  354. End Sub
  355.