home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / fcc110 / fcctst.frm < prev    next >
Text File  |  1993-10-12  |  12KB  |  465 lines

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