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