home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LVB / T2W32543.ZIP / _COMPRES.FRM < prev    next >
Text File  |  1998-05-21  |  16KB  |  463 lines

  1. VERSION 5.00
  2. Begin VB.Form frmCompress 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Compress - Expand"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   4845
  13.    ScaleWidth      =   7485
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame1 
  16.       Height          =   570
  17.       Left            =   0
  18.       TabIndex        =   1
  19.       Top             =   -90
  20.       Width           =   7485
  21.       Begin VB.CommandButton cmdNP 
  22.          Caption         =   ">"
  23.          Height          =   285
  24.          Index           =   1
  25.          Left            =   7110
  26.          TabIndex        =   6
  27.          Top             =   195
  28.          Width           =   285
  29.       End
  30.       Begin VB.CommandButton cmdNP 
  31.          Caption         =   "<"
  32.          Height          =   285
  33.          Index           =   0
  34.          Left            =   6210
  35.          TabIndex        =   5
  36.          Top             =   195
  37.          Width           =   285
  38.       End
  39.       Begin VB.CommandButton Command1 
  40.          Caption         =   "&Go"
  41.          Default         =   -1  'True
  42.          Height          =   285
  43.          Left            =   6570
  44.          TabIndex        =   4
  45.          Top             =   195
  46.          Width           =   465
  47.       End
  48.       Begin VB.ComboBox cmb_Function 
  49.          Height          =   315
  50.          Left            =   1365
  51.          TabIndex        =   2
  52.          Top             =   180
  53.          Width           =   4755
  54.       End
  55.       Begin VB.Label Label2 
  56.          Caption         =   "&Select a function"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   3
  60.          Top             =   210
  61.          Width           =   1275
  62.       End
  63.    End
  64.    Begin VB.TextBox txt_Result 
  65.       BackColor       =   &H00C0C0C0&
  66.       BorderStyle     =   0  'None
  67.       Height          =   4110
  68.       Left            =   105
  69.       Locked          =   -1  'True
  70.       MultiLine       =   -1  'True
  71.       ScrollBars      =   2  'Vertical
  72.       TabIndex        =   0
  73.       Top             =   630
  74.       Width           =   7260
  75.    End
  76. End
  77. Attribute VB_Name = "frmCompress"
  78. Attribute VB_GlobalNameSpace = False
  79. Attribute VB_Creatable = False
  80. Attribute VB_PredeclaredId = True
  81. Attribute VB_Exposed = False
  82. Option Explicit
  83. Option Base 1
  84.  
  85. Private Const Iteration = 10
  86.  
  87. Dim IsLoaded         As Integer
  88.  
  89. Dim TimerStartOk     As Integer
  90. Dim TimerCloseOk     As Integer
  91.  
  92. Dim TimerHandle      As Integer
  93. Dim TimerValue       As Long
  94.  
  95. Private Sub cmb_Function_Click()
  96.    
  97.    If (IsLoaded = False) Then Exit Sub
  98.    
  99.    Call cDisableFI(mdiT2W.Picture1)
  100.    
  101.    txt_Result = ""
  102.    
  103.    DoEvents
  104.    
  105.    Select Case cmb_Function.ListIndex
  106.       Case 0
  107.          Call TestFileCompress
  108.       Case 1
  109.          Call TestStringCompress
  110.       Case 2
  111.          Call TestLZARIcompress
  112.       Case 3
  113.          Call TestGZIPFileCompress
  114.       Case 4
  115.          Call TestGZIPStringCompress
  116.       Case 5
  117.          Call TestASHFileCompress
  118.    End Select
  119.  
  120.    DoEvents
  121.    Call cEnableFI(mdiT2W.Picture1)
  122.    
  123. End Sub
  124.  
  125.  
  126. Private Sub cmdNP_Click(Index As Integer)
  127.  
  128.    Call sub_NextPrev(cmb_Function, Index)
  129.  
  130. End Sub
  131.  
  132. Private Sub Form_Activate()
  133.  
  134.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  135.  
  136. End Sub
  137.  
  138. Private Sub Form_Load()
  139.  
  140.    IsLoaded = False
  141.    
  142.    Show
  143.  
  144.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_compres.t2w")
  145.    
  146.    IsLoaded = True
  147.    
  148. End Sub
  149.  
  150. Private Sub Command1_Click()
  151.    
  152.    Call cmb_Function_Click
  153.    
  154. End Sub
  155.  
  156. Private Sub TestFileCompress()
  157.  
  158.    Dim lResult          As Long
  159.    Dim strResult        As String
  160.    Dim strDisplay       As String
  161.    
  162.    Dim i                As Integer
  163.    
  164.    Dim File1            As String
  165.    Dim File2            As String
  166.    Dim File3            As String
  167.    
  168.    strResult = ""
  169.    strDisplay = ""
  170.    
  171.    File1 = T2WFileTest
  172.    File2 = "autoexec.compressed"
  173.    File3 = "autoexec.expanded"
  174.    
  175.    strDisplay = strDisplay & "File Compress '" & File1 & "' to '" & File2 & "' is " & cFileCompress(File1, File2) & vbCrLf
  176.    strDisplay = strDisplay & "File Expand '" & File2 & "' to '" & File3 & "' is " & cFileExpand(File2, File3) & vbCrLf
  177.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  178.  
  179.    txt_Result = strDisplay
  180.  
  181.    'time the function
  182.  
  183.    TimerHandle = cTimerOpen()
  184.    TimerStartOk = cTimerStart(TimerHandle)
  185.    
  186.    For i = 1 To Iteration
  187.       lResult = cFileCompress(File1, File2)
  188.    Next i
  189.    
  190.    lResult = cFileExpand(File2, File3)
  191.    
  192.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  193.    
  194.    TimerCloseOk = cTimerClose(TimerHandle)
  195.  
  196. End Sub
  197.  
  198. Public Sub TestStringCompress()
  199.  
  200.    Dim lResult          As Long
  201.    Dim strResult        As String
  202.    Dim strDisplay       As String
  203.    
  204.    Dim i                As Integer
  205.    
  206.    Dim Str1             As String
  207.    Dim Str2             As String
  208.    Dim Str3             As String
  209.    
  210.    strResult = ""
  211.    strDisplay = ""
  212.    
  213.    Str1 = "T2WIN-32, t2win-32, T2WIN-32, t2win-32, T2WIN-32, t2win-32"
  214.    Str2 = cStringCompress(Str1)
  215.    Str3 = cStringExpand(Str2)
  216.    
  217.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  218.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  219.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  220.  
  221.    Str1 = "t2win-32, t2win-32, t2win-32, t2win-32, t2win-32, t2win-32"
  222.    Str2 = cStringCompress(Str1)
  223.    Str3 = cStringExpand(Str2)
  224.    
  225.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  226.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  227.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  228.  
  229.    Str1 = String$(13, "a") + String$(11, "b") + String$(9, "c") + String$(7, "d") + String$(5, "e") + String$(3, "f") + String$(1, "g")
  230.    Str2 = cStringCompress(Str1)
  231.    Str3 = cStringExpand(Str2)
  232.    
  233.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  234.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  235.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  236.  
  237.    txt_Result = strDisplay
  238.  
  239.    'time the function
  240.  
  241.    TimerHandle = cTimerOpen()
  242.    TimerStartOk = cTimerStart(TimerHandle)
  243.    
  244.    For i = 1 To Iteration
  245.       Str2 = cStringCompress(Str1)
  246.    Next i
  247.    
  248.    Str3 = cStringExpand(Str2)
  249.    
  250.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  251.    
  252.    TimerCloseOk = cTimerClose(TimerHandle)
  253.  
  254. End Sub
  255.  
  256. Private Sub TestLZARIcompress()
  257.  
  258.    Dim lResult          As Long
  259.    Dim strResult        As String
  260.    Dim strDisplay       As String
  261.    
  262.    Dim i                As Integer
  263.    
  264.    Dim File1            As String
  265.    Dim File2            As String
  266.    Dim File3            As String
  267.    
  268.    strResult = ""
  269.    strDisplay = ""
  270.    
  271.    File1 = T2WFileTest
  272.    File2 = "autoexec.lzaricompressed"
  273.    File3 = "autoexec.lzariexpanded"
  274.    
  275.    strDisplay = strDisplay & "LZARI Compress '" & File1 & "' to '" & File2 & "' is " & cLZARIcompress(File1, File2) & vbCrLf
  276.    strDisplay = strDisplay & "LZARI Expand '" & File2 & "' to '" & File3 & "' is " & cLZARIexpand(File2, File3) & vbCrLf
  277.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  278.  
  279.    txt_Result = strDisplay
  280.  
  281.    'time the function
  282.  
  283.    TimerHandle = cTimerOpen()
  284.    TimerStartOk = cTimerStart(TimerHandle)
  285.    
  286.    For i = 1 To Iteration
  287.       lResult = cLZARIcompress(File1, File2)
  288.    Next i
  289.    
  290.    lResult = cLZARIexpand(File2, File3)
  291.    
  292.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  293.    
  294.    TimerCloseOk = cTimerClose(TimerHandle)
  295.  
  296. End Sub
  297.  
  298. Private Sub TestGZIPFileCompress()
  299.  
  300.    Dim lResult          As Long
  301.    Dim strResult        As String
  302.    Dim strDisplay       As String
  303.    
  304.    Dim i                As Integer
  305.    
  306.    Dim File1            As String
  307.    Dim File2            As String
  308.    Dim File3            As String
  309.    
  310.    strResult = ""
  311.    strDisplay = ""
  312.    
  313.    File1 = T2WFileTest
  314.    File2 = "autoexec.gzipcompressed"
  315.    File3 = "autoexec.gzipexpanded"
  316.    
  317.    strDisplay = strDisplay & "GZIP Compress '" & File1 & "' to '" & File2 & "' is " & cGZIPFileCompress(File1, File2) & vbCrLf
  318.    strDisplay = strDisplay & "GZIP Expand '" & File2 & "' to '" & File3 & "' is " & cGZIPFileExpand(File2, File3) & vbCrLf
  319.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  320.  
  321.    txt_Result = strDisplay
  322.  
  323.    'time the function
  324.  
  325.    TimerHandle = cTimerOpen()
  326.    TimerStartOk = cTimerStart(TimerHandle)
  327.    
  328.    For i = 1 To Iteration
  329.       lResult = cGZIPFileCompress(File1, File2)
  330.    Next i
  331.    
  332.    lResult = cGZIPFileExpand(File2, File3)
  333.    
  334.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  335.    
  336.    TimerCloseOk = cTimerClose(TimerHandle)
  337.  
  338. End Sub
  339.  
  340. Private Sub TestGZIPStringCompress()
  341.  
  342.    Dim lResult          As Long
  343.    Dim strResult        As String
  344.    Dim strDisplay       As String
  345.    
  346.    Dim i                As Integer
  347.    
  348.    Dim Str1             As String
  349.    Dim Str2             As String
  350.    Dim Str3             As String
  351.    
  352.    strResult = ""
  353.    strDisplay = ""
  354.    
  355.    Str1 = "T2WIN-32, t2win-32, T2WIN-32, t2win-32, T2WIN-32, t2win-32"
  356.    Str2 = cGZIPStringCompress(Str1)
  357.    Str3 = cGZIPStringExpand(Str2)
  358.    
  359.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  360.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  361.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  362.  
  363.    Str1 = "t2win-32, t2win-32, t2win-32, t2win-32, t2win-32, t2win-32"
  364.    Str2 = cGZIPStringCompress(Str1)
  365.    Str3 = cGZIPStringExpand(Str2)
  366.    
  367.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  368.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  369.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  370.  
  371.    Str1 = String$(13, "a") + String$(11, "b") + String$(9, "c") + String$(7, "d") + String$(5, "e") + String$(3, "f") + String$(1, "g")
  372.    Str2 = cGZIPStringCompress(Str1)
  373.    Str3 = cGZIPStringExpand(Str2)
  374.    
  375.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  376.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  377.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  378.  
  379.    txt_Result = strDisplay
  380.  
  381.    'time the function
  382.  
  383.    TimerHandle = cTimerOpen()
  384.    TimerStartOk = cTimerStart(TimerHandle)
  385.    
  386.    For i = 1 To Iteration
  387.       Str2 = cGZIPStringCompress(Str1)
  388.    Next i
  389.    
  390.    Str3 = cGZIPStringExpand(Str2)
  391.    
  392.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  393.    
  394.    TimerCloseOk = cTimerClose(TimerHandle)
  395.  
  396. End Sub
  397.  
  398. Private Sub TestASHFileCompress()
  399.  
  400.    Dim lResult          As Long
  401.    Dim strResult        As String
  402.    Dim strDisplay       As String
  403.    
  404.    Dim i                As Integer
  405.    Dim order            As Integer
  406.    
  407.    Dim File1            As String
  408.    Dim File2            As String
  409.    Dim File3            As String
  410.    
  411.    strResult = ""
  412.    strDisplay = ""
  413.    
  414.    File1 = T2WFileTest
  415.    File2 = "autoexec.ashcompressed"
  416.    File3 = "autoexec.ashexpanded"
  417.    
  418.    order = 0
  419.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  420.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  421.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  422.  
  423.    order = 1
  424.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  425.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  426.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  427.  
  428.    order = 2
  429.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  430.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  431.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  432.  
  433.    order = 3
  434.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  435.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  436.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  437.  
  438.    order = 4
  439.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  440.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  441.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  442.  
  443.    txt_Result = strDisplay
  444.  
  445.    'time the function
  446.  
  447.    TimerHandle = cTimerOpen()
  448.    TimerStartOk = cTimerStart(TimerHandle)
  449.    
  450.    For i = 1 To Iteration
  451.       lResult = cASHFileCompress(File1, File2, 0)
  452.    Next i
  453.    
  454.    lResult = cASHFileExpand(File2, File3, 0)
  455.    
  456.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  457.    
  458.    TimerCloseOk = cTimerClose(TimerHandle)
  459.  
  460. End Sub
  461.  
  462.  
  463.