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