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