| 1 | Unit ACLLibraryTestForm;
|
|---|
| 2 |
|
|---|
| 3 | Interface
|
|---|
| 4 |
|
|---|
| 5 | Uses
|
|---|
| 6 | Classes, Forms, Graphics, Buttons,
|
|---|
| 7 | StdCtrls,
|
|---|
| 8 | ACLFileIOUtility,
|
|---|
| 9 | ACLFindFunctions,
|
|---|
| 10 | ACLUtility,
|
|---|
| 11 | PCharList,
|
|---|
| 12 | ACLResourceUtility,
|
|---|
| 13 | ACLVersionUtilityUnit,
|
|---|
| 14 | Semaphores,
|
|---|
| 15 | SharedMemoryUnit,
|
|---|
| 16 |
|
|---|
| 17 | FileUtilsUnit,
|
|---|
| 18 | StringUtilsUnit,
|
|---|
| 19 | CharUtilsUnit,
|
|---|
| 20 | DebugUnit;
|
|---|
| 21 |
|
|---|
| 22 | Type
|
|---|
| 23 | TACLLibraryTestForm = Class (TForm)
|
|---|
| 24 | Memo1: TMemo;
|
|---|
| 25 | Edit1: TEdit;
|
|---|
| 26 | Edit2: TEdit;
|
|---|
| 27 | FindButton: TButton;
|
|---|
| 28 | Button1: TButton;
|
|---|
| 29 | Button2: TButton;
|
|---|
| 30 | Button3: TButton;
|
|---|
| 31 | Procedure FindButtonOnClick (Sender: TObject);
|
|---|
| 32 | Procedure Button4OnClick (Sender: TObject);
|
|---|
| 33 | Procedure Button3OnClick (Sender: TObject);
|
|---|
| 34 | Procedure Button2OnClick (Sender: TObject);
|
|---|
| 35 | Procedure ACLLibraryTestFormOnCreate (Sender: TObject);
|
|---|
| 36 | Procedure ACLLibraryTestFormOnDestroy (Sender: TObject);
|
|---|
| 37 | Procedure ACLLibraryTestFormOnDismissDlg (Sender: TObject);
|
|---|
| 38 | Procedure Button1OnClick (Sender: TObject);
|
|---|
| 39 | Private
|
|---|
| 40 | {Insert private declarations here}
|
|---|
| 41 | Public
|
|---|
| 42 | {Insert public declarations here}
|
|---|
| 43 | End;
|
|---|
| 44 |
|
|---|
| 45 | Var
|
|---|
| 46 | ACLLibraryTestForm: TACLLibraryTestForm;
|
|---|
| 47 |
|
|---|
| 48 | Implementation
|
|---|
| 49 |
|
|---|
| 50 | uses
|
|---|
| 51 | SysUtils,
|
|---|
| 52 | ACLString, AStringUtilityUnit,
|
|---|
| 53 | RunProgramUnit;
|
|---|
| 54 |
|
|---|
| 55 | Procedure TACLLibraryTestForm.FindButtonOnClick (Sender: TObject);
|
|---|
| 56 | var
|
|---|
| 57 | i: integer;
|
|---|
| 58 | Begin
|
|---|
| 59 | i := CaseInsensitivePos( Edit1.Text,
|
|---|
| 60 | Edit2.Text );
|
|---|
| 61 | Memo1.Lines.Add( 'Result: ' + intToStr( i ) );
|
|---|
| 62 | End;
|
|---|
| 63 |
|
|---|
| 64 | Procedure TACLLibraryTestForm.Button4OnClick (Sender: TObject);
|
|---|
| 65 | var
|
|---|
| 66 | a: TAString;
|
|---|
| 67 | Begin
|
|---|
| 68 | a := TAString.CreateFromPCharWithDispose( Memo1.Lines.GetText );
|
|---|
| 69 | a.InsertString( 5, Edit1.Text );
|
|---|
| 70 | Memo1.Lines.SetText( a.AsPChar );
|
|---|
| 71 | a.Destroy;
|
|---|
| 72 | End;
|
|---|
| 73 |
|
|---|
| 74 | Procedure TACLLibraryTestForm.Button3OnClick (Sender: TObject);
|
|---|
| 75 | Begin
|
|---|
| 76 | End;
|
|---|
| 77 |
|
|---|
| 78 | const
|
|---|
| 79 | test: string = 'This is the string I want to test the CRC with. Ha ha haa';
|
|---|
| 80 | test2: string = 'HERES ANOTHER #&*#^*& STRING';
|
|---|
| 81 | test3: string = #234#221#014;
|
|---|
| 82 |
|
|---|
| 83 | Procedure TACLLibraryTestForm.Button2OnClick (Sender: TObject);
|
|---|
| 84 | var
|
|---|
| 85 | crc: longword;
|
|---|
| 86 | Begin
|
|---|
| 87 | crc := GetCRC32( Addr( test ), Length( test ) + 1 );
|
|---|
| 88 | Memo1.Lines.Add( 'Asm Crc = ' + IntToStr( crc ) );
|
|---|
| 89 | crc := Pascal_GetCRC32( Addr( test ), Length( test ) + 1 );
|
|---|
| 90 | Memo1.Lines.Add( 'Pascal Crc = ' + IntToStr( crc ) );
|
|---|
| 91 |
|
|---|
| 92 | crc := GetCRC32( Addr( test2 ), Length( test2 ) + 1 );
|
|---|
| 93 | Memo1.Lines.Add( 'Asm Crc = ' + IntToStr( crc ) );
|
|---|
| 94 | crc := Pascal_GetCRC32( Addr( test2 ), Length( test2 ) + 1 );
|
|---|
| 95 | Memo1.Lines.Add( 'Pascal Crc = ' + IntToStr( crc ) );
|
|---|
| 96 |
|
|---|
| 97 | crc := GetCRC32( Addr( test3 ), Length( test3 ) + 1 );
|
|---|
| 98 | Memo1.Lines.Add( 'Asm Crc = ' + IntToStr( crc ) );
|
|---|
| 99 | crc := Pascal_GetCRC32( Addr( test3 ), Length( test3 ) + 1 );
|
|---|
| 100 | Memo1.Lines.Add( 'Pascal Crc = ' + IntToStr( crc ) );
|
|---|
| 101 |
|
|---|
| 102 | End;
|
|---|
| 103 |
|
|---|
| 104 | type
|
|---|
| 105 | TTestSharedMemObject = record
|
|---|
| 106 | Cake: longint;
|
|---|
| 107 | Sausage: string;
|
|---|
| 108 | end;
|
|---|
| 109 | TPTestSharedMemObject = ^TTestSharedMemObject;
|
|---|
| 110 |
|
|---|
| 111 | Procedure TACLLibraryTestForm.ACLLibraryTestFormOnCreate (Sender: TObject);
|
|---|
| 112 | var
|
|---|
| 113 | SharedMem1, SharedMem2: TSuballocatedSharedMemory;
|
|---|
| 114 | a,b: TPTestSharedMemObject;
|
|---|
| 115 | Begin
|
|---|
| 116 | Memo1.Lines.Add( GetApplicationDir );
|
|---|
| 117 | // Memo1.Lines.Add( 'Color depth: ' + IntToStr( GetScreenColorDepth ) );
|
|---|
| 118 | // Memo1.Lines.Add( 'Video driver: ' + GetVideoDriverName );
|
|---|
| 119 |
|
|---|
| 120 | SharedMem1 := TSuballocatedSharedMemory.Create( 'TEST_SHARED_MEM', 4096, sizeof( TTestSharedMemObject ) );
|
|---|
| 121 | SharedMem2 := TSuballocatedSharedMemory.Create( 'TEST_SHARED_MEM', 4096, sizeof( TTestSharedMemObject ) );
|
|---|
| 122 |
|
|---|
| 123 | a := SharedMem1.Data;
|
|---|
| 124 | b := SharedMem2.Data;
|
|---|
| 125 |
|
|---|
| 126 | a^.Cake := 7;
|
|---|
| 127 | a^.Sausage := 'The Seventh Sausage';
|
|---|
| 128 |
|
|---|
| 129 | SharedMem1.Allocate( a, sizeof( TTestSharedMemObject ) );
|
|---|
| 130 | a^.Cake := 12;
|
|---|
| 131 | a^.Sausage := 'Four Times Fifty Living Men';
|
|---|
| 132 |
|
|---|
| 133 | SharedMem1.Destroy;
|
|---|
| 134 |
|
|---|
| 135 | Memo1.Lines.Add( 'Shared Mem: ' + IntToStr( b^.Cake ) );
|
|---|
| 136 | Memo1.Lines.Add( 'Shared Mem: ' + b^.Sausage );
|
|---|
| 137 |
|
|---|
| 138 | Memo1.Lines.Add( 'Suballoced: ' + IntToStr( a^.Cake ) );
|
|---|
| 139 | Memo1.Lines.Add( 'Suballoced: ' + a^.Sausage );
|
|---|
| 140 |
|
|---|
| 141 | SharedMem2.Free( a );
|
|---|
| 142 |
|
|---|
| 143 | SharedMem2.Destroy;
|
|---|
| 144 | End;
|
|---|
| 145 |
|
|---|
| 146 | Procedure TACLLibraryTestForm.ACLLibraryTestFormOnDestroy (Sender: TObject);
|
|---|
| 147 | Begin
|
|---|
| 148 | CheckAllAStringsDestroyed;
|
|---|
| 149 | End;
|
|---|
| 150 |
|
|---|
| 151 | Procedure TACLLibraryTestForm.ACLLibraryTestFormOnDismissDlg (Sender: TObject);
|
|---|
| 152 | Begin
|
|---|
| 153 |
|
|---|
| 154 | End;
|
|---|
| 155 |
|
|---|
| 156 | Procedure TACLLibraryTestForm.Button1OnClick (Sender: TObject);
|
|---|
| 157 | var
|
|---|
| 158 | VersionsModule: TVersionsModule;
|
|---|
| 159 | Version: string;
|
|---|
| 160 | begin
|
|---|
| 161 | if OpenModuleForVersions( GetApplicationFilename,
|
|---|
| 162 | VersionsModule ) then
|
|---|
| 163 | begin
|
|---|
| 164 | while GetVersionFromModule( VersionsModule,
|
|---|
| 165 | Version ) do
|
|---|
| 166 | Memo1.Lines.Add( Version );
|
|---|
| 167 | end;
|
|---|
| 168 |
|
|---|
| 169 | End;
|
|---|
| 170 |
|
|---|
| 171 | Initialization
|
|---|
| 172 | RegisterClasses ([TACLLibraryTestForm, TMemo, TEdit, TButton]);
|
|---|
| 173 | End.
|
|---|