home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / T2WIN-32.ZIP / _COMPRES.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-01  |  16.4 KB  |  361 lines

  1. VERSION 4.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.    Height          =   5250
  10.    Left            =   1830
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4845
  14.    ScaleWidth      =   7485
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   2925
  17.    Width           =   7605
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   4110
  22.       Left            =   105
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   0
  27.       Top             =   630
  28.       Width           =   7260
  29.    End
  30.    Begin Threed.SSPanel SSPanel1 
  31.       Align           =   1  'Align Top
  32.       Height          =   480
  33.       Left            =   0
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   7485
  37.       _Version        =   65536
  38.       _ExtentX        =   13203
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   315
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   4785
  49.       End
  50.       Begin Threed.SSCommand cmdNP 
  51.          Height          =   300
  52.          Index           =   1
  53.          Left            =   7140
  54.          TabIndex        =   6
  55.          Top             =   90
  56.          Width           =   255
  57.          _Version        =   65536
  58.          _ExtentX        =   450
  59.          _ExtentY        =   529
  60.          _StockProps     =   78
  61.          Caption         =   ">"
  62.          BevelWidth      =   1
  63.          Font3D          =   3
  64.          RoundedCorners  =   0   'False
  65.          Outline         =   0   'False
  66.       End
  67.       Begin Threed.SSCommand cmdNP 
  68.          Height          =   300
  69.          Index           =   0
  70.          Left            =   6300
  71.          TabIndex        =   5
  72.          Top             =   90
  73.          Width           =   255
  74.          _Version        =   65536
  75.          _ExtentX        =   450
  76.          _ExtentY        =   529
  77.          _StockProps     =   78
  78.          Caption         =   "<"
  79.          BevelWidth      =   1
  80.          Font3D          =   3
  81.          RoundedCorners  =   0   'False
  82.          Outline         =   0   'False
  83.       End
  84.       Begin VB.Label Label2 
  85.          Caption         =   "&Select a function"
  86.          Height          =   255
  87.          Left            =   90
  88.          TabIndex        =   4
  89.          Top             =   120
  90.          Width           =   1275
  91.       End
  92.       Begin Threed.SSCommand SSCommand1 
  93.          Default         =   -1  'True
  94.          Height          =   300
  95.          Left            =   6615
  96.          TabIndex        =   3
  97.          Top             =   90
  98.          Width           =   465
  99.          _Version        =   65536
  100.          _ExtentX        =   820
  101.          _ExtentY        =   529
  102.          _StockProps     =   78
  103.          Caption         =   "&Go"
  104.          BevelWidth      =   1
  105.          RoundedCorners  =   0   'False
  106.          Outline         =   0   'False
  107.       End
  108.    End
  109. Attribute VB_Name = "frmCompress"
  110. Attribute VB_Creatable = False
  111. Attribute VB_Exposed = False
  112. Option Explicit
  113. Option Base 1
  114. Private Const Iteration = 10
  115. Dim IsLoaded         As Integer
  116. Dim TimerStartOk     As Integer
  117. Dim TimerCloseOk     As Integer
  118. Dim TimerHandle      As Integer
  119. Dim TimerValue       As Long
  120. Private Sub cmb_Function_Click()
  121.    If (IsLoaded = False) Then Exit Sub
  122.    Call cDisableFI(mdiT2W.Picture1)
  123.    txt_Result = ""
  124.    DoEvents
  125.    Select Case cmb_Function.ListIndex
  126.       Case 0
  127.          Call TestFileCompress
  128.       Case 1
  129.          Call TestStringCompress
  130.       Case 2
  131.          Call TestLZARIcompress
  132.       Case 3
  133.          Call TestGZIPFileCompress
  134.       Case 4
  135.          Call TestGZIPStringCompress
  136.       Case 5
  137.          Call TestASHFileCompress
  138.    End Select
  139.    DoEvents
  140.    Call cEnableFI(mdiT2W.Picture1)
  141. End Sub
  142. Private Sub cmdNP_Click(Index As Integer)
  143.    Call sub_NextPrev(cmb_Function, Index)
  144. End Sub
  145. Private Sub Form_Activate()
  146.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  147. End Sub
  148. Private Sub Form_Load()
  149.    IsLoaded = False
  150.    Show
  151.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_compres.t2w")
  152.    IsLoaded = True
  153. End Sub
  154. Private Sub SSCommand1_Click()
  155.    Call cmb_Function_Click
  156. End Sub
  157. Private Sub TestFileCompress()
  158.    Dim lngResult        As Long
  159.    Dim strResult        As String
  160.    Dim strDisplay       As String
  161.    Dim i                As Integer
  162.    Dim File1            As String
  163.    Dim File2            As String
  164.    Dim File3            As String
  165.    strResult = ""
  166.    strDisplay = ""
  167.    File1 = T2WFileTest
  168.    File2 = "autoexec.compressed"
  169.    File3 = "autoexec.expanded"
  170.    strDisplay = strDisplay & "File Compress '" & File1 & "' to '" & File2 & "' is " & cFileCompress(File1, File2) & vbCrLf
  171.    strDisplay = strDisplay & "File Expand '" & File2 & "' to '" & File3 & "' is " & cFileExpand(File2, File3) & vbCrLf
  172.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  173.    txt_Result = strDisplay
  174.    'time the function
  175.    TimerHandle = cTimerOpen()
  176.    TimerStartOk = cTimerStart(TimerHandle)
  177.    For i = 1 To Iteration
  178.       lngResult = cFileCompress(File1, File2)
  179.    Next i
  180.    lngResult = cFileExpand(File2, File3)
  181.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  182.    TimerCloseOk = cTimerClose(TimerHandle)
  183. End Sub
  184. Public Sub TestStringCompress()
  185.    Dim lngResult        As Long
  186.    Dim strResult        As String
  187.    Dim strDisplay       As String
  188.    Dim i                As Integer
  189.    Dim Str1             As String
  190.    Dim Str2             As String
  191.    Dim Str3             As String
  192.    strResult = ""
  193.    strDisplay = ""
  194.    Str1 = "T2WIN-32, t2win-32, T2WIN-32, t2win-32, T2WIN-32, t2win-32"
  195.    Str2 = cStringCompress(Str1)
  196.    Str3 = cStringExpand(Str2)
  197.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  198.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  199.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  200.    Str1 = "t2win-32, t2win-32, t2win-32, t2win-32, t2win-32, t2win-32"
  201.    Str2 = cStringCompress(Str1)
  202.    Str3 = cStringExpand(Str2)
  203.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  204.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  205.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  206.    Str1 = String$(13, "a") + String$(11, "b") + String$(9, "c") + String$(7, "d") + String$(5, "e") + String$(3, "f") + String$(1, "g")
  207.    Str2 = cStringCompress(Str1)
  208.    Str3 = cStringExpand(Str2)
  209.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  210.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  211.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  212.    txt_Result = strDisplay
  213.    'time the function
  214.    TimerHandle = cTimerOpen()
  215.    TimerStartOk = cTimerStart(TimerHandle)
  216.    For i = 1 To Iteration
  217.       Str2 = cStringCompress(Str1)
  218.    Next i
  219.    Str3 = cStringExpand(Str2)
  220.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  221.    TimerCloseOk = cTimerClose(TimerHandle)
  222. End Sub
  223. Private Sub TestLZARIcompress()
  224.    Dim lngResult        As Long
  225.    Dim strResult        As String
  226.    Dim strDisplay       As String
  227.    Dim i                As Integer
  228.    Dim File1            As String
  229.    Dim File2            As String
  230.    Dim File3            As String
  231.    strResult = ""
  232.    strDisplay = ""
  233.    File1 = T2WFileTest
  234.    File2 = "autoexec.lzaricompressed"
  235.    File3 = "autoexec.lzariexpanded"
  236.    strDisplay = strDisplay & "LZARI Compress '" & File1 & "' to '" & File2 & "' is " & cLZARIcompress(File1, File2) & vbCrLf
  237.    strDisplay = strDisplay & "LZARI Expand '" & File2 & "' to '" & File3 & "' is " & cLZARIexpand(File2, File3) & vbCrLf
  238.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  239.    txt_Result = strDisplay
  240.    'time the function
  241.    TimerHandle = cTimerOpen()
  242.    TimerStartOk = cTimerStart(TimerHandle)
  243.    For i = 1 To Iteration
  244.       lngResult = cLZARIcompress(File1, File2)
  245.    Next i
  246.    lngResult = cLZARIexpand(File2, File3)
  247.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  248.    TimerCloseOk = cTimerClose(TimerHandle)
  249. End Sub
  250. Private Sub TestGZIPFileCompress()
  251.    Dim lngResult        As Long
  252.    Dim strResult        As String
  253.    Dim strDisplay       As String
  254.    Dim i                As Integer
  255.    Dim File1            As String
  256.    Dim File2            As String
  257.    Dim File3            As String
  258.    strResult = ""
  259.    strDisplay = ""
  260.    File1 = T2WFileTest
  261.    File2 = "autoexec.gzipcompressed"
  262.    File3 = "autoexec.gzipexpanded"
  263.    strDisplay = strDisplay & "GZIP Compress '" & File1 & "' to '" & File2 & "' is " & cGZIPFileCompress(File1, File2) & vbCrLf
  264.    strDisplay = strDisplay & "GZIP Expand '" & File2 & "' to '" & File3 & "' is " & cGZIPFileExpand(File2, File3) & vbCrLf
  265.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  266.    txt_Result = strDisplay
  267.    'time the function
  268.    TimerHandle = cTimerOpen()
  269.    TimerStartOk = cTimerStart(TimerHandle)
  270.    For i = 1 To Iteration
  271.       lngResult = cGZIPFileCompress(File1, File2)
  272.    Next i
  273.    lngResult = cGZIPFileExpand(File2, File3)
  274.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  275.    TimerCloseOk = cTimerClose(TimerHandle)
  276. End Sub
  277. Private Sub TestGZIPStringCompress()
  278.    Dim lngResult        As Long
  279.    Dim strResult        As String
  280.    Dim strDisplay       As String
  281.    Dim i                As Integer
  282.    Dim Str1             As String
  283.    Dim Str2             As String
  284.    Dim Str3             As String
  285.    strResult = ""
  286.    strDisplay = ""
  287.    Str1 = "T2WIN-32, t2win-32, T2WIN-32, t2win-32, T2WIN-32, t2win-32"
  288.    Str2 = cGZIPStringCompress(Str1)
  289.    Str3 = cGZIPStringExpand(Str2)
  290.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  291.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  292.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  293.    Str1 = "t2win-32, t2win-32, t2win-32, t2win-32, t2win-32, t2win-32"
  294.    Str2 = cGZIPStringCompress(Str1)
  295.    Str3 = cGZIPStringExpand(Str2)
  296.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  297.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  298.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  299.    Str1 = String$(13, "a") + String$(11, "b") + String$(9, "c") + String$(7, "d") + String$(5, "e") + String$(3, "f") + String$(1, "g")
  300.    Str2 = cGZIPStringCompress(Str1)
  301.    Str3 = cGZIPStringExpand(Str2)
  302.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  303.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  304.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  305.    txt_Result = strDisplay
  306.    'time the function
  307.    TimerHandle = cTimerOpen()
  308.    TimerStartOk = cTimerStart(TimerHandle)
  309.    For i = 1 To Iteration
  310.       Str2 = cGZIPStringCompress(Str1)
  311.    Next i
  312.    Str3 = cGZIPStringExpand(Str2)
  313.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  314.    TimerCloseOk = cTimerClose(TimerHandle)
  315. End Sub
  316. Private Sub TestASHFileCompress()
  317.    Dim lngResult        As Long
  318.    Dim strResult        As String
  319.    Dim strDisplay       As String
  320.    Dim i                As Integer
  321.    Dim order            As Integer
  322.    Dim File1            As String
  323.    Dim File2            As String
  324.    Dim File3            As String
  325.    strResult = ""
  326.    strDisplay = ""
  327.    File1 = T2WFileTest
  328.    File2 = "autoexec.ashcompressed"
  329.    File3 = "autoexec.ashexpanded"
  330.    order = 0
  331.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  332.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  333.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  334.    order = 1
  335.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  336.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  337.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  338.    order = 2
  339.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  340.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  341.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  342.    order = 3
  343.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  344.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  345.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  346.    order = 4
  347.    strDisplay = strDisplay & "ASH Compress (order " & order & ")' " & File1 & "' to '" & File2 & "' is " & cASHFileCompress(File1, File2, order) & vbCrLf
  348.    strDisplay = strDisplay & "ASH Expand (order " & order & ")' " & File2 & "' to '" & File3 & "' is " & cASHFileExpand(File2, File3, order) & vbCrLf
  349.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  350.    txt_Result = strDisplay
  351.    'time the function
  352.    TimerHandle = cTimerOpen()
  353.    TimerStartOk = cTimerStart(TimerHandle)
  354.    For i = 1 To Iteration
  355.       lngResult = cASHFileCompress(File1, File2, 0)
  356.    Next i
  357.    lngResult = cASHFileExpand(File2, File3, 0)
  358.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  359.    TimerCloseOk = cTimerClose(TimerHandle)
  360. End Sub
  361.