home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fcc110 / fcctst.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  11.9 KB  |  428 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "FCC Test Program"
  4.    ClientHeight    =   3450
  5.    ClientLeft      =   1125
  6.    ClientTop       =   1470
  7.    ClientWidth     =   7185
  8.    Height          =   3855
  9.    Left            =   1065
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   3450
  13.    ScaleWidth      =   7185
  14.    Top             =   1125
  15.    Width           =   7305
  16.    Begin TextBox Rpercent 
  17.       Height          =   285
  18.       Left            =   3360
  19.       TabIndex        =   9
  20.       Text            =   "10"
  21.       Top             =   2760
  22.       Width           =   735
  23.    End
  24.    Begin CheckBox Rwrites 
  25.       Height          =   255
  26.       Left            =   5880
  27.       TabIndex        =   10
  28.       Top             =   2760
  29.       Width           =   255
  30.    End
  31.    Begin TextBox Rsize 
  32.       Height          =   285
  33.       Left            =   3360
  34.       TabIndex        =   8
  35.       Text            =   "2048"
  36.       Top             =   2400
  37.       Width           =   735
  38.    End
  39.    Begin TextBox Dblk 
  40.       Height          =   285
  41.       Left            =   3360
  42.       TabIndex        =   7
  43.       Text            =   "8192"
  44.       Top             =   2040
  45.       Width           =   735
  46.    End
  47.    Begin TextBox Dcache 
  48.       Height          =   285
  49.       Left            =   3360
  50.       TabIndex        =   6
  51.       Text            =   "128"
  52.       Top             =   1680
  53.       Width           =   735
  54.    End
  55.    Begin Timer Timer2 
  56.       Left            =   3240
  57.       Top             =   0
  58.    End
  59.    Begin CommandButton Frand 
  60.       Caption         =   "Random"
  61.       Height          =   495
  62.       Left            =   120
  63.       TabIndex        =   4
  64.       Top             =   2160
  65.       Width           =   1455
  66.    End
  67.    Begin Timer Timer1 
  68.       Left            =   2520
  69.       Top             =   0
  70.    End
  71.    Begin CommandButton Cancel 
  72.       Caption         =   "Cancel"
  73.       Enabled         =   0   'False
  74.       Height          =   495
  75.       Left            =   120
  76.       TabIndex        =   5
  77.       Top             =   2760
  78.       Width           =   1455
  79.    End
  80.    Begin Frame Frame1 
  81.       Caption         =   "Compress"
  82.       Height          =   975
  83.       Left            =   5640
  84.       TabIndex        =   11
  85.       Top             =   1560
  86.       Width           =   1095
  87.       Begin OptionButton Option2 
  88.          Caption         =   "Off"
  89.          Height          =   255
  90.          Left            =   240
  91.          TabIndex        =   14
  92.          Top             =   600
  93.          Width           =   615
  94.       End
  95.       Begin OptionButton Option1 
  96.          Caption         =   "On"
  97.          Height          =   255
  98.          Left            =   240
  99.          TabIndex        =   13
  100.          Top             =   240
  101.          Value           =   -1  'True
  102.          Width           =   735
  103.       End
  104.    End
  105.    Begin CommandButton Copy 
  106.       Caption         =   "Copy"
  107.       Height          =   495
  108.       Left            =   120
  109.       TabIndex        =   3
  110.       Top             =   1560
  111.       Width           =   1455
  112.    End
  113.    Begin TextBox Destination 
  114.       Height          =   285
  115.       Left            =   2040
  116.       TabIndex        =   2
  117.       Text            =   "c:\fcc.tmp"
  118.       Top             =   840
  119.       Width           =   2055
  120.    End
  121.    Begin TextBox Source 
  122.       Height          =   285
  123.       Left            =   2040
  124.       TabIndex        =   1
  125.       Top             =   480
  126.       Width           =   2055
  127.    End
  128.    Begin Label Label7 
  129.       Caption         =   "(128-16384)"
  130.       Height          =   255
  131.       Left            =   4200
  132.       TabIndex        =   25
  133.       Top             =   2040
  134.       Width           =   1335
  135.    End
  136.    Begin Label Label4 
  137.       Caption         =   "(1-2048)"
  138.       Height          =   255
  139.       Left            =   4200
  140.       TabIndex        =   24
  141.       Top             =   1680
  142.       Width           =   855
  143.    End
  144.    Begin Label Label11 
  145.       Caption         =   "Random %:"
  146.       Height          =   255
  147.       Left            =   1800
  148.       TabIndex        =   23
  149.       Top             =   2760
  150.       Width           =   1215
  151.    End
  152.    Begin Label Label10 
  153.       Caption         =   "Random Writes:"
  154.       Height          =   255
  155.       Left            =   4320
  156.       TabIndex        =   22
  157.       Top             =   2760
  158.       Width           =   1455
  159.    End
  160.    Begin Label Label9 
  161.       Caption         =   "Random Size:"
  162.       Height          =   255
  163.       Left            =   1800
  164.       TabIndex        =   21
  165.       Top             =   2400
  166.       Width           =   1335
  167.    End
  168.    Begin Label Label6 
  169.       Caption         =   "Cache Size (K):"
  170.       Height          =   255
  171.       Left            =   1800
  172.       TabIndex        =   20
  173.       Top             =   1680
  174.       Width           =   1455
  175.    End
  176.    Begin Label Label5 
  177.       Caption         =   "Block Size:"
  178.       Height          =   255
  179.       Left            =   1800
  180.       TabIndex        =   19
  181.       Top             =   2040
  182.       Width           =   1455
  183.    End
  184.    Begin Label elapsed 
  185.       Height          =   255
  186.       Left            =   240
  187.       TabIndex        =   18
  188.       Top             =   1200
  189.       Width           =   6135
  190.    End
  191.    Begin Label Dsize 
  192.       Height          =   255
  193.       Left            =   4320
  194.       TabIndex        =   17
  195.       Top             =   840
  196.       Width           =   2175
  197.    End
  198.    Begin Label Ssize 
  199.       Height          =   255
  200.       Left            =   4320
  201.       TabIndex        =   16
  202.       Top             =   480
  203.       Width           =   2895
  204.    End
  205.    Begin Label Label3 
  206.       Caption         =   "Version:"
  207.       Height          =   255
  208.       Left            =   240
  209.       TabIndex        =   15
  210.       Top             =   120
  211.       Width           =   1815
  212.    End
  213.    Begin Label Label2 
  214.       Caption         =   "Destination File:"
  215.       Height          =   255
  216.       Left            =   240
  217.       TabIndex        =   12
  218.       Top             =   840
  219.       Width           =   1575
  220.    End
  221.    Begin Label Label1 
  222.       Caption         =   "Source File:"
  223.       Height          =   255
  224.       Left            =   240
  225.       TabIndex        =   0
  226.       Top             =   480
  227.       Width           =   1455
  228.    End
  229. Dim rpsize As Long
  230. Dim rprocessed As Long
  231. Dim tstart As Double
  232. Dim progress As FCC_COPYT
  233. Sub Cancel_Click ()
  234.     progress.cancel = 1
  235.     Form1.MousePointer = 11
  236.     status% = DoEvents()
  237. End Sub
  238. Function Comma (n As Long) As String
  239.     Comma = Format(n, "#,###,###,##0")
  240. End Function
  241. Sub Copy_Click ()
  242.     s$ = Source.Text
  243.     d$ = Destination.Text
  244.     If d$ = "" Then
  245.         MsgBox "Destination Not Specified", MB_ICONINFORMATION, ""
  246.         Exit Sub
  247.     End If
  248.     copy.Enabled = False
  249.     frand.Enabled = False
  250.     cancel.Enabled = True
  251.     timer1.Interval = 500
  252.     elapsed.Caption = ""
  253.     progress.hWnd = Form1.hWnd
  254.     progress.message = 257
  255.     progress.wparam = 256
  256.     tstart = Timer
  257.     If option1.Value = True Then
  258.         er% = FCC_copy(s$, d$, Val(Dblk.Text), FCC_CDEFAULT, progress)
  259.     Else
  260.         er% = FCC_copy(s$, d$, Val(Dblk.Text), FCC_CNONE, progress)
  261.     End If
  262.     timer1_timer
  263.     timer1.Interval = 0
  264.     Form1.MousePointer = 0
  265.     i% = FCC_exists(d$, v%, l&, p&)
  266.     If i% = 0 Then Dsize.Caption = Comma(p&) + " bytes"
  267.     If er% <> 0 Then
  268.         s$ = FCC_err(er%)
  269.         MsgBox s$, MB_ICONINFORMATION, "ERROR"
  270.     Else
  271.         MsgBox "File Copied", MB_ICONOK, ""
  272.     End If
  273.     copy.Enabled = True
  274.     frand.Enabled = True
  275.     cancel.Enabled = False
  276. End Sub
  277. Sub Form_KeyUp (keycode As Integer, Shift As Integer)
  278.     If keycode = 256 Then
  279.         state% = DoEvents()
  280.     End If
  281. End Sub
  282. Sub Form_Load ()
  283.     s$ = "Version: " + Str$(FCC_version())
  284.     Label3.Caption = s$
  285. End Sub
  286. Sub Frand_Click ()
  287.     frand.Enabled = False
  288.     copy.Enabled = False
  289.     cancel.Enabled = True
  290.     Randomize
  291.     d$ = Destination.Text
  292.     rprocessed = 0
  293.     progress.cancel = 0
  294.     timer2.Interval = 500
  295.     tstart = Timer
  296.     If Rwrites.Value = 1 Then
  297.         e% = random_test(d$, Val(Dcache.Text), Val(Dblk.Text), Val(Rsize.Text), Val(Rpercent.Text), True)
  298.     Else
  299.         e% = random_test(d$, Val(Dcache.Text), Val(Dblk.Text), Val(Rsize.Text), Val(Rpercent.Text), False)
  300.     End If
  301.     timer2.Interval = 0
  302.     Form1.MousePointer = 0
  303.     ShowElapsed (rprocessed)
  304.     i% = FCC_exists(d$, v%, l&, p&)
  305.     If i% = 0 Then Dsize.Caption = Comma(p&) + " bytes"
  306.     If e% <> 0 Then
  307.         s$ = FCC_err(e%)
  308.         MsgBox s$, MB_ICONINFORMATION, "ERROR"
  309.     Else
  310.         MsgBox "", MB_ICONOK, ""
  311.     End If
  312.     copy.Enabled = True
  313.     frand.Enabled = True
  314.     cancel.Enabled = False
  315. End Sub
  316. Function random_test (s$, kbytes%, blksize%, buffsize%, percent%, writes%)
  317.    Dim pos As Long
  318.    Dim flen As Long
  319.    Dim h As Integer
  320.    Dim num As Integer
  321.    Dim area As Long
  322.    Dim k As Long
  323.    ReDim buff((buffsize / 2) + 1) As Integer
  324.    If percent > 100 Then percent = 100
  325.    If percent < 1 Then percent = 1
  326.    If writes = True Then
  327.         e% = FCC_open(h, s$, FCC_RDWR, 0, kbytes%, blksize%)
  328.    Else
  329.         e% = FCC_open(h, s$, FCC_RDONLY, 0, kbytes%, blksize%)
  330.    End If
  331.    If e% <> 0 Then
  332.       random_test = e%
  333.       Exit Function
  334.    End If
  335.    e% = FCC_length(h, flen)
  336.    If e% <> 0 Then
  337.       random_test = e%
  338.       Exit Function
  339.    End If
  340.    If num > flen Then num = flen / 2 + 1
  341.    While True
  342.       num = Rnd * buffsize% + 1
  343.       If Rnd * 100 > percent Then
  344.         area = (flen - num) * (percent / 100)
  345.       Else
  346.         area = flen - num
  347.       End If
  348.       pos = Rnd * area
  349.       e% = FCC_seek(h, pos, FCC_SEEKSET, newpos&)
  350.       If e% <> 0 Then
  351.          random_test = e%
  352.          Exit Function
  353.       End If
  354.       
  355.       e% = FCC_read(h, buff(0), num, k)
  356.       If e% <> 0 Then
  357.          random_test = e%
  358.          Exit Function
  359.       End If
  360.       If k <> num Then
  361.          random_test = FCC_ERR_READ
  362.          Exit Function
  363.       End If
  364.       rprocessed = rprocessed + num
  365.       If writes = True Then
  366.         If Rnd * 100 > percent Then
  367.             area = (flen - num) * (percent / 100)
  368.         Else
  369.             area = flen - num
  370.         End If
  371.         pos = Rnd * area
  372.         e% = FCC_seek(h, pos, FCC_SEEKSET, newpos&)
  373.         If e% <> 0 Then
  374.              random_test = e%
  375.             Exit Function
  376.         End If
  377.         e% = FCC_write(h, buff(0), num, k)
  378.         If e% <> 0 Then
  379.              random_test = e%
  380.             Exit Function
  381.         End If
  382.         If k <> num Then
  383.              random_test = FCC_ERR_READ
  384.             Exit Function
  385.         End If
  386.         rprocessed = rprocessed + num
  387.       End If
  388.       
  389.       status% = DoEvents()
  390.       If progress.cancel <> 0 Then
  391.          e% = FCC_close(h)
  392.          If e% = 0 Then e% = FCC_ERR_CANCELED
  393.          random_test = e%
  394.          Exit Function
  395.       End If
  396.          
  397.       e% = FCC_plength(h, rpsize)
  398.       If e% <> 0 Then
  399.          random_test = e%
  400.          Exit Function
  401.       End If
  402.    Wend
  403. End Function
  404. Sub ShowElapsed (bytes&)
  405.     s$ = Comma(bytes&) + " bytes processed"
  406.     n# = Timer - tstart
  407.     If n# <> 0 Then
  408.         s$ = s$ + " (" + Format((bytes& / 1024) / n#, "0.00") + " K/sec)"
  409.     End If
  410.     elapsed.Caption = s$
  411. End Sub
  412. Sub timer1_timer ()
  413.     If progress.length = progress.plength Then
  414.         Ssize.Caption = Comma(progress.length) + " Bytes"
  415.     Else
  416.         Ssize.Caption = Comma(progress.plength) + " (" + Comma(progress.length) + ") bytes"
  417.     End If
  418.     If progress.length > 0 Then
  419.         ShowElapsed (progress.curpos)
  420.         i% = (progress.curpos * 100&) / progress.length
  421.         Dsize.Caption = Str$(i%) + "% Done"
  422.     End If
  423. End Sub
  424. Sub Timer2_Timer ()
  425.     ShowElapsed (rprocessed)
  426.     Dsize.Caption = Comma(rpsize) + " bytes"
  427. End Sub
  428.