home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / FCC110 / FCCTST.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-10-12  |  11.8 KB  |  424 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. Dim rpsize As Long
  226. Dim rprocessed As Long
  227. Dim tstart As Double
  228. Dim progress As FCC_COPYT
  229. Sub Cancel_Click ()
  230.     progress.cancel = 1
  231.     Form1.MousePointer = 11
  232.     status% = DoEvents()
  233. End Sub
  234. Function Comma (n As Long) As String
  235.     Comma = Format(n, "#,###,###,##0")
  236. End Function
  237. Sub Copy_Click ()
  238.     s$ = Source.Text
  239.     d$ = Destination.Text
  240.     If d$ = "" Then
  241.         MsgBox "Destination Not Specified", MB_ICONINFORMATION, ""
  242.         Exit Sub
  243.     End If
  244.     copy.Enabled = False
  245.     frand.Enabled = False
  246.     cancel.Enabled = True
  247.     timer1.Interval = 500
  248.     elapsed.Caption = ""
  249.     progress.hWnd = Form1.hWnd
  250.     progress.message = 257
  251.     progress.wparam = 256
  252.     tstart = Timer
  253.     If option1.Value = True Then
  254.         er% = FCC_copy(s$, d$, Val(Dblk.Text), FCC_CDEFAULT, progress)
  255.     Else
  256.         er% = FCC_copy(s$, d$, Val(Dblk.Text), FCC_CNONE, progress)
  257.     End If
  258.     timer1_timer
  259.     timer1.Interval = 0
  260.     Form1.MousePointer = 0
  261.     i% = FCC_exists(d$, v%, l&, p&)
  262.     If i% = 0 Then Dsize.Caption = Comma(p&) + " bytes"
  263.     If er% <> 0 Then
  264.         s$ = FCC_err(er%)
  265.         MsgBox s$, MB_ICONINFORMATION, "ERROR"
  266.     Else
  267.         MsgBox "File Copied", MB_ICONOK, ""
  268.     End If
  269.     copy.Enabled = True
  270.     frand.Enabled = True
  271.     cancel.Enabled = False
  272. End Sub
  273. Sub Form_KeyUp (keycode As Integer, Shift As Integer)
  274.     If keycode = 256 Then
  275.         state% = DoEvents()
  276.     End If
  277. End Sub
  278. Sub Form_Load ()
  279.     s$ = "Version: " + Str$(FCC_version())
  280.     Label3.Caption = s$
  281. End Sub
  282. Sub Frand_Click ()
  283.     frand.Enabled = False
  284.     copy.Enabled = False
  285.     cancel.Enabled = True
  286.     Randomize
  287.     d$ = Destination.Text
  288.     rprocessed = 0
  289.     progress.cancel = 0
  290.     timer2.Interval = 500
  291.     tstart = Timer
  292.     If Rwrites.Value = 1 Then
  293.         e% = random_test(d$, Val(Dcache.Text), Val(Dblk.Text), Val(Rsize.Text), Val(Rpercent.Text), True)
  294.     Else
  295.         e% = random_test(d$, Val(Dcache.Text), Val(Dblk.Text), Val(Rsize.Text), Val(Rpercent.Text), False)
  296.     End If
  297.     timer2.Interval = 0
  298.     Form1.MousePointer = 0
  299.     ShowElapsed (rprocessed)
  300.     i% = FCC_exists(d$, v%, l&, p&)
  301.     If i% = 0 Then Dsize.Caption = Comma(p&) + " bytes"
  302.     If e% <> 0 Then
  303.         s$ = FCC_err(e%)
  304.         MsgBox s$, MB_ICONINFORMATION, "ERROR"
  305.     Else
  306.         MsgBox "", MB_ICONOK, ""
  307.     End If
  308.     copy.Enabled = True
  309.     frand.Enabled = True
  310.     cancel.Enabled = False
  311. End Sub
  312. Function random_test (s$, kbytes%, blksize%, buffsize%, percent%, writes%)
  313.    Dim pos As Long
  314.    Dim flen As Long
  315.    Dim h As Integer
  316.    Dim num As Integer
  317.    Dim area As Long
  318.    Dim k As Long
  319.    ReDim buff((buffsize / 2) + 1) As Integer
  320.    If percent > 100 Then percent = 100
  321.    If percent < 1 Then percent = 1
  322.    If writes = True Then
  323.         e% = FCC_open(h, s$, FCC_RDWR, 0, kbytes%, blksize%)
  324.    Else
  325.         e% = FCC_open(h, s$, FCC_RDONLY, 0, kbytes%, blksize%)
  326.    End If
  327.    If e% <> 0 Then
  328.       random_test = e%
  329.       Exit Function
  330.    End If
  331.    e% = FCC_length(h, flen)
  332.    If e% <> 0 Then
  333.       random_test = e%
  334.       Exit Function
  335.    End If
  336.    If num > flen Then num = flen / 2 + 1
  337.    While True
  338.       num = Rnd * buffsize% + 1
  339.       If Rnd * 100 > percent Then
  340.         area = (flen - num) * (percent / 100)
  341.       Else
  342.         area = flen - num
  343.       End If
  344.       pos = Rnd * area
  345.       e% = FCC_seek(h, pos, FCC_SEEKSET, newpos&)
  346.       If e% <> 0 Then
  347.          random_test = e%
  348.          Exit Function
  349.       End If
  350.       
  351.       e% = FCC_read(h, buff(0), num, k)
  352.       If e% <> 0 Then
  353.          random_test = e%
  354.          Exit Function
  355.       End If
  356.       If k <> num Then
  357.          random_test = FCC_ERR_READ
  358.          Exit Function
  359.       End If
  360.       rprocessed = rprocessed + num
  361.       If writes = True Then
  362.         If Rnd * 100 > percent Then
  363.             area = (flen - num) * (percent / 100)
  364.         Else
  365.             area = flen - num
  366.         End If
  367.         pos = Rnd * area
  368.         e% = FCC_seek(h, pos, FCC_SEEKSET, newpos&)
  369.         If e% <> 0 Then
  370.              random_test = e%
  371.             Exit Function
  372.         End If
  373.         e% = FCC_write(h, buff(0), num, k)
  374.         If e% <> 0 Then
  375.              random_test = e%
  376.             Exit Function
  377.         End If
  378.         If k <> num Then
  379.              random_test = FCC_ERR_READ
  380.             Exit Function
  381.         End If
  382.         rprocessed = rprocessed + num
  383.       End If
  384.       
  385.       status% = DoEvents()
  386.       If progress.cancel <> 0 Then
  387.          e% = FCC_close(h)
  388.          If e% = 0 Then e% = FCC_ERR_CANCELED
  389.          random_test = e%
  390.          Exit Function
  391.       End If
  392.          
  393.       e% = FCC_plength(h, rpsize)
  394.       If e% <> 0 Then
  395.          random_test = e%
  396.          Exit Function
  397.       End If
  398.    Wend
  399. End Function
  400. Sub ShowElapsed (bytes&)
  401.     s$ = Comma(bytes&) + " bytes processed"
  402.     n# = Timer - tstart
  403.     If n# <> 0 Then
  404.         s$ = s$ + " (" + Format((bytes& / 1024) / n#, "0.00") + " K/sec)"
  405.     End If
  406.     elapsed.Caption = s$
  407. End Sub
  408. Sub timer1_timer ()
  409.     If progress.length = progress.plength Then
  410.         Ssize.Caption = Comma(progress.length) + " Bytes"
  411.     Else
  412.         Ssize.Caption = Comma(progress.plength) + " (" + Comma(progress.length) + ") bytes"
  413.     End If
  414.     If progress.length > 0 Then
  415.         ShowElapsed (progress.curpos)
  416.         i% = (progress.curpos * 100&) / progress.length
  417.         Dsize.Caption = Str$(i%) + "% Done"
  418.     End If
  419. End Sub
  420. Sub Timer2_Timer ()
  421.     ShowElapsed (rprocessed)
  422.     Dsize.Caption = Comma(rpsize) + " bytes"
  423. End Sub
  424.