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