In Delphi Xe7, there are many extensions to array operations, such as the addition of string-like functions.
For example, the array is added
var a:array of Integer; B:tbytes = [1,2,3,4]; Initialization can be do from Declarationbegin ... a:=[1,2,3]; Assignation using constant array a:=a+[4,5];//Addition-a'll become [1,2,3,4,5] ... end;
Array insertion
var a:array of Integer;begin ... a:=[1,2,3,4]; Insert (5,a,2); A'll become [1,2,5,3,4] ... end;
Array deletion
var a:array of Integer;begin ... a:=[1,2,3,4]; Delete (a,1,2); A'll become [1,4] ... end;
Array connections
A: = Concat ([1,2,3],[4,5,6]); A'll become [1,2,3,4,5,6]
Why in the Xe7 to make such a big change in the array, of course, first of all, it must be convenient to set up the programming, in fact, the reason for the deeper layer is because the ansistring on the mobile platform is missing,
A lot of the past code, because all of the byte as Ansichar processing, to the mobile platform, the code will not run up. And it's hard to change.
Then only use tbytes to replace the traditional ansistring. So the array operation adds so many methods to solve this traditional problem.
That is now the problem, the traditional POS functionality has not been added, resulting in a large number of operations using POS can not be modified.
I didn't know it was in xe? Add it inside? Now the temporary way is to do a find (POS) function to solve this problem.
In order not to conflict with future POS, the function name is called Find, the function is to find another array inside an array, and return to the location.
function Find (const SUB, buffer:tbytes): Integer;var n:integer;begin N: = Length (sub); If N>0 then in Result: = Low (buffer) to high (buffer)-(N-1) does if Comparemem (@Buffer [Result], Sub, N) Then Exit; Result: = -1;end;
This can be used to replace the original Ansistring POS operation.
The missing Find (POS) feature in the Delphi XE7 array operation