Advertisement
Janilabo

Janilabo | integer_.dpr v1.1 [SCAR Divi]

May 29th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 44.85 KB | None | 0 0
  1. library integer_;
  2.  
  3. uses
  4.   FastShareMem,
  5.   SysUtils,
  6.   Math;
  7.  
  8. {$R *.res}
  9.  
  10. type
  11.   MSSL_TControlMethod = (cm_None, cm_Filter, cm_Extract);
  12.   MSSL_TPartitionMethod = (pm_PartSize, pm_PartAmount);
  13.   TIntegerArray = array of Integer;
  14.   TIntArray = TIntegerArray;
  15.   T2DIntegerArray = array of TIntegerArray;
  16.   T2DIntArray = T2DIntegerArray;
  17.  
  18. procedure TIAReverse(var TIA: TIntArray);
  19. var
  20.   g, i, l, t: Integer;
  21. begin
  22.   l := (Length(TIA) - 1);
  23.   if (l < 1) then
  24.     Exit;
  25.   g := (l div 2);
  26.   for i := 0 to g do
  27.   begin
  28.     t := TIA[i];
  29.     TIA[i] := TIA[(l - i)];
  30.     TIA[(l - i)] := t;
  31.   end;
  32. end;
  33.  
  34. function TIAContains(TIA: TIntArray; x: Integer): Boolean;
  35. var
  36.   h, i: Integer;
  37. begin
  38.   h := High(TIA);
  39.   for i := 0 to h do
  40.     if (TIA[i] = x) then
  41.       Break;
  42.   Result := ((h > -1) and (i <= h));
  43. end;
  44.  
  45. procedure TIARemoveEx(var TIA: TIntArray; x: Integer; all: Boolean);
  46. var
  47.   h, i, d: Integer;
  48. begin
  49.   h := High(TIA);
  50.   if (h > -1) then
  51.   begin
  52.     case all of
  53.       True:      
  54.       for i := h downto 0 do
  55.         if (TIA[i] = x) then
  56.         begin
  57.           for d := i to (h - 1) do
  58.             TIA[d] := TIA[(d + 1)];
  59.           Dec(h);
  60.         end;
  61.       False:
  62.       for i := 0 to h do
  63.         if (TIA[i] = x) then
  64.         begin
  65.           for d := i to (h - 1) do
  66.             TIA[d] := TIA[(d + 1)];
  67.           Dec(h);
  68.           Break;      
  69.         end;
  70.     end;
  71.     SetLength(TIA, (h + 1));
  72.   end;
  73. end;
  74.  
  75. {==============================================================================]  
  76.   Explanation: Returns a TIA that contains all the value from start value (aStart)
  77.                to finishing value (aFinish)..
  78. [==============================================================================}
  79. function MSSL_TIAByRange(aStart, aFinish: Integer): TIntArray; stdcall;
  80. var
  81.   i, s, f: Integer;
  82. begin
  83.   if (aStart <> aFinish) then
  84.   begin
  85.     s := Integer(aStart);
  86.     f := Integer(aFinish);
  87.     SetLength(Result, (Abs(aStart - aFinish) + 1));
  88.     case (aStart > aFinish) of
  89.       True:
  90.       for i := s downto f do
  91.         Result[(s - i)] := i;
  92.       False:
  93.       for i := s to f do
  94.         Result[(i - s)] := i;
  95.     end;
  96.   end else
  97.   begin
  98.     SetLength(Result, 1);
  99.     Result[0] := Integer(aStart);
  100.   end;
  101. end;
  102.  
  103. {==============================================================================]
  104.   Explanation: Returns a TIA that contains all the value from start value (aStart)
  105.                to finishing value (aFinish)..
  106.                Works with 2-bit method, that cuts loop in half.
  107. [==============================================================================}
  108. function MSSL_TIAByRange2bit(aStart, aFinish: Integer): TIntArray; stdcall;
  109. var
  110.   g, l, i, s, f: Integer;
  111. begin
  112.   if (aStart <> aFinish) then
  113.   begin
  114.     s := Integer(aStart);
  115.     f := Integer(aFinish);
  116.     l := (Abs(aStart - aFinish) + 1);            
  117.     SetLength(Result, l);    
  118.     g := ((l - 1) div 2);  
  119.     case (aStart < aFinish) of
  120.       True:
  121.       begin
  122.         for i := 0 to g do
  123.         begin                      
  124.           Result[i] := (s + i);
  125.           Result[((l - 1) - i)] := (f - i);
  126.         end;
  127.         if ((l mod 2) <> 0) then
  128.           Result[i] := (s + i);  
  129.       end;
  130.       False:
  131.       begin
  132.         for i := 0 to g do
  133.         begin                      
  134.           Result[i] := (s - i);
  135.           Result[((l - 1) - i)] := (f + i);
  136.         end;
  137.         if ((l mod 2) <> 0) then
  138.           Result[i] := (s - i);  
  139.       end;  
  140.     end;    
  141.   end else
  142.   begin
  143.     SetLength(Result, 1);
  144.     Result[0] := Integer(aStart);
  145.   end;
  146. end;
  147.  
  148. {==============================================================================]
  149.   Explanation: Returns array of x, count being the size of the result.
  150. [==============================================================================}
  151. function MSSL_TIAOfInteger(x, count: Integer): TIntArray; stdcall;
  152. var
  153.   i: Integer;
  154. begin
  155.   if (count > 0) then
  156.   begin
  157.     SetLength(Result, count);
  158.     for i := 0 to (count - 1) do
  159.       Result[i] := Integer(x);
  160.   end else
  161.     SetLength(Result, 0);
  162. end;
  163.  
  164. {==============================================================================]
  165.   Explanation: Converts integer value (int) to digits of it.
  166.   Example: 1234 => 1,2,3,4
  167. [==============================================================================}
  168. function MSSL_IntDigits(int: Integer): TIntArray; stdcall;
  169. var
  170.   s: string;
  171.   l, i: Integer;
  172. begin
  173.   s := IntToStr(Abs(int));
  174.   l := Length(s);
  175.   SetLength(Result, l);
  176.   for i := 0 to (l - 1) do
  177.     Result[i] := StrToInt(s[(i + 1)]);
  178. end;
  179.  
  180. {==============================================================================]
  181.   Explanation: Returns true if str is integer value.
  182. [==============================================================================}
  183. function MSSL_StrIsInt(str: string): Boolean; stdcall;
  184. begin
  185.   try
  186.     StrToInt(str);
  187.     Result := True;
  188.   except
  189.     Result := False;
  190.   end;
  191. end;
  192.  
  193. {==============================================================================]
  194.   Explanation: Sets minimum value (x) to val.
  195. [==============================================================================}
  196. procedure MSSL_IntSetMin(var val: Integer; x: Integer); stdcall;
  197. begin
  198.   if (val < x) then
  199.     val := Integer(x);
  200. end;
  201.  
  202. {==============================================================================]
  203.   Explanation: Sets maximum value (x) to val.
  204. [==============================================================================}
  205. procedure MSSL_IntSetMax(var val: Integer; x: Integer); stdcall;
  206. begin
  207.   if (val > x) then
  208.     val := Integer(x);
  209. end;
  210.  
  211. {==============================================================================]
  212.   Explanation: Sets val inside range (mn = minimum, mx = maximum)
  213. [==============================================================================}
  214. procedure MSSL_IntSetRange(var val: Integer; mn, mx: Integer); stdcall;
  215. var
  216.   t: Integer;
  217. begin
  218.   if (mn > mx) then
  219.   begin
  220.     t := mn;
  221.     mn := mx;
  222.     mx := t;
  223.   end;
  224.   if (mn <> mx) then
  225.   begin        
  226.     if (val < mn) then
  227.       val := Integer(mn);
  228.     if (val > mx) then
  229.       val := Integer(mx);
  230.   end else    
  231.     if ((val < mn) or (val > mx)) then
  232.       val := Integer(mn);
  233. end;
  234.  
  235. {==============================================================================]
  236.   Explanation: Sets minimum value (x) to TIA items.
  237. [==============================================================================}
  238. procedure MSSL_TIASetMin(var TIA: TIntArray; x: Integer); stdcall;
  239. var
  240.   h, i: Integer;
  241. begin
  242.   h := High(TIA);
  243.   for i := 0 to h do
  244.     if (TIA[i] < x) then
  245.       TIA[i] := Integer(x);
  246. end;
  247.  
  248. {==============================================================================]
  249.   Explanation: Sets maximum value (x) to TIA items.
  250. [==============================================================================}
  251. procedure MSSL_TIASetMax(var TIA: TIntArray; x: Integer); stdcall;
  252. var
  253.   h, i: Integer;
  254. begin
  255.   h := High(TIA);
  256.   for i := 0 to h do
  257.     if (TIA[i] > x) then
  258.       TIA[i] := Integer(x);
  259. end;
  260.  
  261. {==============================================================================]
  262.   Explanation: Sets TIA values inside range (mn = minimum, mx = maximum)
  263. [==============================================================================}
  264. procedure MSSL_TIASetRange(var TIA: TIntArray; mn, mx: Integer); stdcall;
  265. var
  266.   h, i, t: Integer;
  267. begin
  268.   if (mn > mx) then
  269.   begin
  270.     t := mn;
  271.     mn := mx;
  272.     mx := t;
  273.   end;
  274.   h := High(TIA);
  275.   if (h > -1) then
  276.   case (mn = mx) of
  277.     True:
  278.     for i := 0 to h do
  279.       if ((TIA[i] < mn) or (TIA[i] > mx)) then
  280.         TIA[i] := Integer(mn);
  281.     False:
  282.     for i := 0 to h do
  283.     begin
  284.       if (TIA[i] < mn) then
  285.         TIA[i] := Integer(mn);
  286.       if (TIA[i] > mx) then
  287.         TIA[i] := Integer(mx);
  288.     end;    
  289.   end;
  290. end;
  291.  
  292. {==============================================================================]
  293.   Explanation: Control's TIA by range. Contains actions for 2 methods: cm_Filter and cm_Extract.
  294. [==============================================================================}
  295. procedure MSSL_TIAControlByRange(var TIA: TIntArray; minimum, maximum: Integer; method: MSSL_TControlMethod); stdcall;
  296. var
  297.   h, i, l, v: Integer;
  298. begin
  299.   h := High(TIA);
  300.   if ((minimum <= maximum) and (h > -1) and (method <> cm_None)) then
  301.   case method of
  302.     cm_Filter:
  303.     for i := h downto 0 do
  304.       if ((TIA[i] >= minimum) and (TIA[i] <= maximum)) then
  305.       begin
  306.         l := Length(TIA);
  307.         for v := i to (l - 2) do
  308.           TIA[v] := TIA[(v + 1)];
  309.         SetLength(TIA, (l - 1));
  310.       end;
  311.     cm_Extract:
  312.     for i := h downto 0 do
  313.       if ((TIA[i] < minimum) or (TIA[i] > maximum)) then
  314.       begin
  315.         l := Length(TIA);
  316.         for v := i to (l - 2) do
  317.           TIA[v] := TIA[(v + 1)];
  318.         SetLength(TIA, (l - 1));
  319.       end;
  320.   end;
  321. end;
  322.  
  323. {==============================================================================]
  324.   Explanation: Returns true if TIA is built ONLY with allowed values.
  325. [==============================================================================}
  326. function MSSL_TIABuiltWith(TIA, allowed: TIntArray): Boolean; stdcall;
  327. var
  328.   h, l, i, v: Integer;
  329. begin
  330.   Result := False;
  331.   l := Length(TIA);
  332.   h := High(allowed);
  333.   if ((h > -1) and (l > 0)) then
  334.   begin
  335.     for i := 0 to h do
  336.     begin
  337.       for v := 0 to (l - 1) do
  338.         if (TIA[v] = allowed[i]) then
  339.           Break;
  340.       if (v >= l) then
  341.         Exit;
  342.     end;
  343.     Result := True;
  344.   end;
  345. end;
  346.  
  347. {==============================================================================]
  348.   Explanation: Randomizes TIA.
  349.                Example: [1, 2, 3] => [2, 3, 1]
  350.                The higher count of shuffles is, the "stronger" randomization you'll get.
  351. [==============================================================================}
  352. procedure MSSL_TIARandomizeEx(var TIA: TIntArray; shuffles: Integer); stdcall;
  353. var
  354.   a, b, l, i, t, v: Integer;
  355. begin
  356.   l := Length(TIA);
  357.   if ((l > 1) and (shuffles > 0)) then
  358.     for t := 1 to shuffles do
  359.       for i := 0 to (l - 1) do
  360.       begin
  361.         a := Random(l);
  362.         b := Random(l);
  363.         if (a <> b) then
  364.         begin
  365.           v := TIA[a];
  366.           TIA[a] := TIA[b];
  367.           TIA[b] := v;
  368.         end;
  369.       end;
  370. end;
  371.  
  372. {==============================================================================]
  373.   Explanation: Randomizes TIA.
  374.                Example: [1, 2, 3] => [2, 3, 1]
  375. [==============================================================================}
  376. procedure MSSL_TIARandomize(var TIA: TIntArray); stdcall;
  377. begin
  378.   MSSL_TIARandomizeEx(TIA, 1);
  379. end;
  380.  
  381. {==============================================================================]
  382.   Explanation: Deletes item with index (x) from TIA. Returns true with success.
  383. [==============================================================================}
  384. function MSSL_TIADelete(var TIA: TIntArray; x: Integer): Boolean; stdcall;
  385. var
  386.   h, i, v: Integer;
  387. begin
  388.   h := High(TIA);
  389.   Result := ((x <= h) and (x > -1));
  390.   if Result then
  391.   begin
  392.     for i := v to (h - 1) do
  393.       TIA[i] := TIA[(i + 1)];
  394.     SetLength(TIA, h);
  395.   end;
  396. end;
  397.  
  398. {==============================================================================]
  399.   Explanation: Removes integers from TIA, x = array of indexes.
  400. [==============================================================================}
  401. procedure MSSL_TIARemove(var TIA: TIntArray; x: TIntArray); stdcall;
  402. var
  403.   i, h, h2, v: Integer;
  404. begin
  405.   h := High(TIA);
  406.   h2 := High(x);
  407.   if ((h > -1) and (h2 > -1)) then
  408.     for i := 0 to h2 do
  409.       if ((x[i] <= h) and (x[i] > -1)) then
  410.       begin
  411.         for v := x[i] to (h - 1) do
  412.           TIA[v] := TIA[(v + 1)];
  413.         SetLength(TIA, h);
  414.         Dec(h);
  415.       end;
  416. end;
  417.  
  418. {==============================================================================]
  419.   Explanation: Adds all addTIA items to TIA. Returns the highest index in the end.
  420. [==============================================================================}
  421. function MSSL_TIAAdd(var TIA: TIntArray; addTIA: TIntArray): Integer; stdcall;
  422. var
  423.   h, l, i: Integer;
  424. begin
  425.   h := High(addTIA);
  426.   if (h > -1) then
  427.   begin
  428.     l := Length(TIA);
  429.     SetLength(TIA, (l + (h + 1)));
  430.     for i := 0 to h do
  431.       TIA[(i + l)] := Integer(addTIA[i]);
  432.   end;
  433.   Result := High(TIA);
  434. end;
  435.  
  436. {==============================================================================]
  437.   Explanation: Returns all the TIA positions where x can be found.
  438. [==============================================================================}
  439. function MSSL_TIAPositions(TIA: TIntArray; x: Integer): TIntArray; stdcall;
  440. var
  441.   i, h, r: Integer;
  442. begin
  443.   h := High(TIA);          
  444.   if (h > -1) then
  445.   begin
  446.     SetLength(Result, (h + 1));
  447.     for i := 0 to h do
  448.       if (TIA[i] = x) then
  449.       begin
  450.         Result[r] := i;
  451.         Inc(r);
  452.       end;  
  453.   end;
  454.   SetLength(Result, r);
  455. end;
  456.  
  457. {==============================================================================]
  458.   Explanation: Returns the TIA positions where index contains any integer from ints.
  459.   NOTE: Doesn't return ALL indexes, like MSSL_TIAPositionsEx() does.
  460. [==============================================================================}
  461. function MSSL_TIAPositionsMulti(TIA, ints: TIntArray): TIntArray; stdcall;
  462. var
  463.   a, b, i, h: Integer;
  464. begin
  465.   h := High(ints);
  466.   b := High(TIA);
  467.   if ((b > -1) and (h > -1)) then
  468.   begin
  469.     SetLength(Result, (h + 1));
  470.     for i := 0 to h do
  471.     begin
  472.       Result[i] := -1;
  473.       for a := 0 to b do
  474.         if (TIA[a] = ints[i]) then
  475.         begin
  476.           Result[i] := a;
  477.           Break;
  478.         end;
  479.     end;
  480.   end else
  481.     SetLength(Result, 0);
  482. end;
  483.  
  484. {==============================================================================]
  485.   Explanation: Returns all the TIA positions where index contains any integer from ints.
  486. [==============================================================================}
  487. function MSSL_TIAPositionsEx(TIA, ints: TIntArray): TIntArray; stdcall;
  488. var
  489.   i, h, r, l, v: Integer;
  490. begin
  491.   h := High(TIA);
  492.   l := Length(ints);
  493.   if ((l > 0) and (h > -1)) then
  494.   begin
  495.     SetLength(Result, (h + 1));
  496.     for i := 0 to h do
  497.     begin
  498.       for v := 0 to (l - 1) do
  499.         if (ints[v] = TIA[i]) then
  500.           Break;
  501.       if (v < l) then
  502.       begin
  503.         Result[r] := i;
  504.         Inc(r);
  505.       end;
  506.     end;
  507.   end;
  508.   SetLength(Result, r);
  509. end;
  510.  
  511. {==============================================================================]
  512.   Explanation: Copies TIA from pos1 to pos2.
  513. [==============================================================================}
  514. function MSSL_TIACopyEx(TIA: TIntArray; pos1, pos2: Integer): TIntArray; stdcall;
  515. var
  516.   i, l: Integer;
  517. begin
  518.   l := Length(TIA);
  519.   if (l > 0) then
  520.   begin  
  521.     MSSL_IntSetRange(pos1, 0, (l - 1));
  522.     MSSL_IntSetRange(pos2, 0, (l - 1));
  523.     case (pos1 <> pos2) of
  524.       True:
  525.       begin
  526.         SetLength(Result, (Abs(pos1 - pos2) + 1));
  527.         case (pos1 < pos2) of            
  528.           True:
  529.           for i := pos1 to pos2 do
  530.             Result[(i - pos1)] := Integer(TIA[i]);
  531.           False:
  532.           for i := pos1 downto pos2 do
  533.             Result[(pos1 - i)] := Integer(TIA[i]);  
  534.         end;
  535.       end;
  536.       False:
  537.       begin
  538.         SetLength(Result, 1);
  539.         Result[0] := Integer(TIA[pos1]);
  540.       end;
  541.     end;
  542.   end else
  543.     SetLength(Result, 0);
  544. end;
  545.  
  546. {==============================================================================]
  547.   Explanation: Moves oldIndex to newIndex in TIA. Returns true, if movement was succesfully done!
  548. [==============================================================================}
  549. function MSSL_TIAMove(var TIA: TIntArray; oldIndex, newIndex: Integer): Boolean; stdcall;
  550. var
  551.   h, i, t: Integer;
  552. begin
  553.   h := High(TIA);
  554.   Result := ((h > 0) and (oldIndex <> newIndex) and InRange(oldIndex, 0, h) and InRange(newIndex, 0, h));
  555.   if Result then
  556.   case (oldIndex > newIndex) of
  557.     True:
  558.     for i := oldIndex downto (newIndex + 1) do
  559.     begin
  560.       t := TIA[i];
  561.       TIA[i] := TIA[(i - 1)];
  562.       TIA[(i - 1)] := t;
  563.     end;
  564.     False:
  565.     for i := oldIndex to (newIndex - 1) do
  566.     begin
  567.       t := TIA[i];
  568.       TIA[i] := TIA[(i + 1)];
  569.       TIA[(i + 1)] := t;
  570.     end;
  571.   end;
  572. end;
  573.  
  574. {==============================================================================]
  575.   Explanation: Breaks TIA to parts (TIA => ATIA). Contains 2 methods:
  576.                -pm_PartSize (Breaks TIA to ATIA by size of the parts) [x = size]
  577.                -pm_PartAmount (Breaks TIA to ATIA by amount of the parts) [x = amount]
  578. [==============================================================================}
  579. function MSSL_TIAToParts(TIA: TIntArray; method: MSSL_TPartitionMethod; x: Integer): T2DIntArray; stdcall;
  580. var
  581.   a, e, h, h2, i, i2, p, l, z: Integer;
  582.   f: Boolean;
  583. begin
  584.   h := High(TIA);
  585.   case ((h > -1) and (x > 0)) of
  586.     True:
  587.     begin
  588.       case method of
  589.         pm_PartSize:
  590.         if (x <= h) then
  591.         begin
  592.           Inc(h);
  593.           p := (h div x);
  594.           if ((p * x) < h) then
  595.             Inc(p);
  596.           SetLength(Result, p);
  597.           for i := 0 to (p - 1) do
  598.             for i2 := 0 to (x - 1) do
  599.             begin
  600.               SetLength(Result[i], x);
  601.               if (a < h) then
  602.               begin
  603.                 Result[i][i2] := Integer(TIA[a]);
  604.                 Inc(a);
  605.               end else
  606.               begin
  607.                 SetLength(Result[i], i2);
  608.                 Exit;
  609.               end;
  610.             end;
  611.         end else
  612.           f := True;      
  613.         pm_PartAmount:
  614.         case (h <= 0) of
  615.           False:
  616.           begin
  617.             if (h < (x - 1)) then
  618.               x := (h + 1);
  619.             p := Floor((h + 1) / x);
  620.             if (p = 0) then
  621.               p := 1;
  622.             e := ((h + 1) - (p * x));
  623.             if (e >= (h + 1)) then
  624.               e := 0;
  625.             SetLength(Result, x);
  626.             for i := 0 to (x - 1) do
  627.             begin
  628.               if ((e >= (i + 1)) and (e > 0)) then
  629.                 SetLength(Result[i], (p + 1))
  630.               else
  631.                 if (i <= h) then
  632.                   SetLength(Result[i], p);
  633.               h2 := High(Result[i]);
  634.               for i2 := 0 to h2 do
  635.               begin
  636.                 Result[i][i2] := Integer(TIA[a]);
  637.                 Inc(a);
  638.               end;
  639.             end;      
  640.           end;
  641.           True: f := True;
  642.         end;
  643.       end;
  644.       if f then
  645.       begin                    
  646.         SetLength(Result, 1);
  647.         l := Length(TIA);
  648.         SetLength(Result[0], l);
  649.         for z := 0 to (l - 1) do
  650.           Result[0][z] := Integer(TIA[z]);
  651.       end;
  652.     end;      
  653.     False: SetLength(Result, 0);          
  654.   end;
  655. end;
  656.  
  657. {==============================================================================]
  658.   Explanation: Returns a TIA from start position, where step is the difference between each range value.
  659.                Count is the size of the result..
  660.   Examples: (3, -1, 3) => [3, 2, 1] and (0, 2, 4) => [0, 2, 4, 6]
  661. [==============================================================================}
  662. function MSSL_TIARangeFrom(start, step, count: Integer): TIntArray; stdcall;
  663. var
  664.   i: Integer;
  665. begin
  666.   case (count > 0) of
  667.     True:
  668.     begin
  669.       SetLength(Result, count);
  670.       for i := 0 to (count - 1) do
  671.         Result[i] := (start + (i * step));
  672.     end;
  673.     False: SetLength(Result, 0);
  674.   end;
  675. end;
  676.  
  677. {==============================================================================]
  678.   Explanation: Returns array of items from TIA by IDs.
  679.                Stores invalid ID's [index positions] to iIDs.
  680. [==============================================================================}
  681. function MSSL_TIAGetEx(TIA, IDs: TIntArray; var iIDs: TIntArray): TIntArray; stdcall;
  682. var
  683.   i, h, h2, iC, rC: Integer;
  684. begin
  685.   SetLength(Result, 0);
  686.   h := High(TIA);
  687.   h2 := High(IDs);
  688.   case ((h2 > -1) and (h > -1)) of
  689.     True:
  690.     begin
  691.       SetLength(Result, (h2 + 1));
  692.       SetLength(iIDs, (h2 + 1));
  693.       for i := 0 to h2 do
  694.       case ((IDs[i] <= h) and (IDs[i] > -1)) of
  695.         True:
  696.         begin
  697.           Result[rC] := Integer(TIA[IDs[i]]);
  698.           Inc(rC);
  699.         end;
  700.         False:
  701.         begin
  702.           iIDs[iC] := i;
  703.           Inc(iC);
  704.         end;
  705.       end;
  706.       SetLength(iIDs, iC);
  707.     end;
  708.     False:
  709.     begin
  710.       SetLength(iIDs, (h2 + 1));
  711.       for i := 0 to h2 do
  712.         iIDs[i] := Integer(IDs[i]);
  713.     end;
  714.   end;  
  715.   SetLength(Result, rC);
  716. end;
  717.  
  718. {==============================================================================]
  719.   Explanation: Returns item[s] from TIA by IDs. Ignores invalid ID's.
  720. [==============================================================================}
  721. function MSSL_TIAGet(TIA, IDs: TIntArray): TIntArray; stdcall;
  722. var
  723.   i, h, h2, r: Integer;
  724. begin
  725.   h := High(TIA);
  726.   h2 := High(IDs);
  727.   if ((h2 > -1) and (h > -1)) then
  728.   begin
  729.     SetLength(Result, (h2 + 1));
  730.     for i := 0 to h2 do
  731.       if ((IDs[i] <= h) and (IDs[i] > -1)) then
  732.       begin
  733.         Result[r] := Integer(TIA[IDs[i]]);
  734.         Inc(r);
  735.       end;
  736.   end;
  737.   SetLength(Result, r);
  738. end;
  739.  
  740. {==============================================================================]
  741.   Explanation: Removes integers by x from TIA.
  742. [==============================================================================}
  743. procedure MSSL_TIARemoveEx(var TIA: TIntArray; x: TIntArray); stdcall;
  744. var
  745.   i: Integer;
  746. begin
  747.   for i := High(x) downto 0 do
  748.   begin        
  749.     TIARemoveEx(TIA, x[i], True);
  750.     if (High(TIA) < 0) then
  751.       Break;
  752.     TIARemoveEx(x, x[i], True);
  753.   end;
  754. end;
  755.  
  756. {==============================================================================]
  757.   Explanation: Copies source to target. If resetTarget is set to true,
  758.                target will be cleared before the copying process.
  759. [==============================================================================}
  760. procedure MSSL_TIACopy(source: TIntArray; var target: TIntArray; resetTarget: Boolean); stdcall;
  761. var
  762.   i, tAL, sAL: Integer;
  763. begin
  764.   if resetTarget then
  765.     SetLength(target, 0);
  766.   tAL := Length(target);
  767.   sAL := Length(source);
  768.   SetLength(target, (tAL + sAL));
  769.   for i := 0 to (sAL - 1) do
  770.     target[(tAL + i)] := Integer(source[i]);
  771. end;
  772.  
  773. {==============================================================================]
  774.   Explanation: Moves source to target. If resetTarget is set to true,
  775.                target will be cleared before the moving process.
  776. [==============================================================================}
  777. procedure MSSL_TIATransferEx(var source, target: TIntArray; resetTarget: Boolean); stdcall;
  778. begin
  779.   MSSL_TIACopy(source, target, resetTarget);
  780.   SetLength(source, 0);
  781. end;
  782.  
  783. {==============================================================================]
  784.   Explanation: Moves source to target.
  785.   NOTE: Target wont get cleaned before moving source!
  786. [==============================================================================}
  787. procedure MSSL_TIATransfer(var source, target: TIntArray); stdcall;
  788. begin
  789.   MSSL_TIACopy(source, target, False);
  790.   SetLength(source, 0);  
  791. end;
  792.  
  793. {==============================================================================]
  794.   Explanation: Plants/places ints to index position in TIA.
  795.                Like TIAInsert(), with an exception that this inserts array of integers.
  796.                Returns the highest index from TIA in the end.
  797. [==============================================================================}
  798. function MSSL_TIAPlant(var TIA: TIntArray; index: Integer; ints: TIntArray): Integer; stdcall;
  799. var
  800.   i, l, h: Integer;
  801. begin
  802.   h := High(ints);
  803.   if (h > -1) then
  804.   begin                                      
  805.     l := Length(TIA);
  806.     SetLength(TIA, (l + (h + 1)));
  807.     if (index < 0) then
  808.       index := 0;
  809.     if (index > l) then
  810.       index := l;      
  811.     for i := (l + (h + 1) - 1) downto (index + (h + 1)) do
  812.       TIA[i] := TIA[(i - (h + 1))];    
  813.     for i := 0 to h do
  814.       TIA[(i + index)] := Integer(ints[i]);      
  815.   end;
  816.   Result := High(TIA);
  817. end;
  818.  
  819. {==============================================================================]
  820.   Explanation: Returns integer (by pick_ID) from TIA and then deletes it from TIA.
  821.                Result will be -1, if TIA is empty of pick_ID invalid.
  822. [==============================================================================}
  823. function MSSL_TIAPick(var TIA: TIntArray; pick_ID: Integer): Integer; stdcall;
  824. var
  825.   h, i: Integer;
  826. begin
  827.   h := High(TIA);
  828.   if ((h > -1) and InRange(pick_ID, 0, h)) then
  829.   begin
  830.     Result := Integer(TIA[pick_ID]);
  831.     for i := pick_ID to (h - 1) do
  832.       TIA[i] := TIA[(i + 1)];
  833.     SetLength(TIA, h);
  834.   end else
  835.     Result := -1;
  836. end;
  837.  
  838. {==============================================================================]
  839.   Explanation: Returns integers (by pick_IDs) from TIA and then deletes em. Ignores invalid indexes. DYNAMIC!
  840. [==============================================================================}
  841. function MSSL_TIAPickEx(var TIA: TIntArray; pick_IDs: TIntArray): TIntArray; stdcall;
  842. var
  843.   h, h2, i, d, r: Integer;
  844. begin
  845.   h2 := High(TIA);
  846.   h := High(pick_IDs);
  847.   if ((h2 > -1) and (h > -1)) then
  848.   begin        
  849.     SetLength(Result, (h2 + 1));
  850.     for i := 0 to h do
  851.       if ((pick_IDs[i] <= h2) and (pick_IDs[i] > -1)) then
  852.       begin
  853.         Result[r] := Integer(TIA[pick_IDs[i]]);
  854.         Inc(r);
  855.         for d := pick_IDs[i] to (h2 - 1) do
  856.           TIA[d] := TIA[(d + 1)];
  857.         Dec(h2);
  858.         if (h2 < 0) then
  859.           Break;
  860.       end;
  861.     SetLength(TIA, h2);
  862.     SetLength(Result, r);
  863.   end else
  864.     SetLength(Result, 0);
  865. end;
  866.  
  867. {==============================================================================]
  868.   Explanation: Returns the count where TIA1[*] matches TIA2[*] (*=same position!)
  869.                If either TIA1[*] or TIA2[*] contains any value from specialMatches, it will be counted as match.
  870. [==============================================================================}
  871. function MSSL_TIAMatchEx(TIA1, TIA2, specialMatches: TIntArray): Integer; stdcall;
  872. var
  873.   i, m: Integer;
  874. begin
  875.   Result := 0;
  876.   m := Min(High(TIA1), High(TIA2));
  877.   for i := 0 to m do
  878.   case (TIA1[i] = TIA2[i]) of
  879.     True: Inc(Result);
  880.     False:
  881.     if (TIAContains(specialMatches, TIA1[i]) or TIAContains(specialMatches, TIA2[i])) then
  882.       Inc(Result);
  883.   end;        
  884. end;
  885.  
  886. {==============================================================================]
  887.   Explanation: Returns the count where TIA1[*] matches TIA2[*] (*=same position!)
  888.                If either TIA1[*] or TIA2[*] contains specialMatch value, it will be counted as match.
  889. [==============================================================================}
  890. function MSSL_TIAMatch2(TIA1, TIA2: TIntArray; specialMatch: Integer): Integer; stdcall;
  891. var
  892.   i, m: Integer;
  893. begin
  894.   Result := 0;
  895.   m := Min(High(TIA1), High(TIA2));
  896.   for i := 0 to m do
  897.   case (TIA1[i] = TIA2[i]) of
  898.     True: Inc(Result);
  899.     False:
  900.     if ((TIA1[i] = specialMatch) or (TIA2[i] = specialMatch)) then
  901.       Inc(Result);
  902.   end;        
  903. end;
  904.  
  905. {==============================================================================]
  906.   Explanation: Returns the count where TIA1[*] matches TIA2[*] (*=same position!)
  907. [==============================================================================}
  908. function MSSL_TIAMatch(TIA1, TIA2: TIntArray): Integer; stdcall;
  909. var
  910.   i, m: Integer;
  911. begin
  912.   Result := 0;
  913.   m := Min(High(TIA1), High(TIA2));
  914.   for i := 0 to m do
  915.     if (TIA1[i] = TIA2[i]) then
  916.       Inc(Result);
  917. end;
  918.  
  919. {==============================================================================]
  920.   Explanation: Returns the positions where TIA1[*] matches TIA2[*] (*=same position!)
  921.                If either TIA1[*] or TIA2[*] contains any value from specialMatches, it will be counted as match.
  922. [==============================================================================}
  923. function MSSL_TIAMatchesEx(TIA1, TIA2, specialMatches: TIntArray): TIntArray; stdcall;
  924. var
  925.   i, m, r: Integer;
  926. begin
  927.   m := Min(High(TIA1), High(TIA2));
  928.   if (m > -1) then                
  929.   begin
  930.     SetLength(Result, (m + 1));
  931.     for i := 0 to m do
  932.     case (TIA1[i] = TIA2[i]) of
  933.       True:
  934.       begin
  935.         Result[r] := i;
  936.         Inc(r);    
  937.       end;
  938.       False:
  939.       if (TIAContains(specialMatches, TIA1[i]) or TIAContains(specialMatches, TIA2[i])) then
  940.       begin
  941.         Result[r] := i;
  942.         Inc(r);    
  943.       end;
  944.     end;
  945.     SetLength(Result, r);
  946.   end else
  947.     SetLength(Result, 0);        
  948. end;
  949.  
  950. {==============================================================================]
  951.   Explanation: Returns the positions where TIA1[*] matches TIA2[*] (*=same position!)
  952.                If either TIA1[*] or TIA2[*] contains specialMatch value, it will be counted as match.
  953. [==============================================================================}
  954. function MSSL_TIAMatches2(TIA1, TIA2: TIntArray; specialMatch: Integer): TIntArray; stdcall;
  955. var
  956.   i, m, r: Integer;
  957. begin
  958.   m := Min(High(TIA1), High(TIA2));
  959.   if (m > -1) then
  960.   begin  
  961.     SetLength(Result, (m + 1));
  962.     for i := 0 to m do
  963.     case (TIA1[i] = TIA2[i]) of
  964.       True:  
  965.       begin
  966.         Result[r] := i;
  967.         Inc(r);
  968.       end;
  969.       False:
  970.       if ((TIA1[i] = specialMatch) or (TIA2[i] = specialMatch)) then
  971.       begin
  972.         Result[r] := i;
  973.         Inc(r);    
  974.       end;
  975.     end;
  976.     SetLength(Result, r);  
  977.   end else
  978.     SetLength(Result, 0);      
  979. end;
  980.  
  981. {==============================================================================]
  982.   Explanation: Returns the positions where TIA1[*] matches TIA2[*] (*=same position!)
  983. [==============================================================================}
  984. function MSSL_TIAMatches(TIA1, TIA2: TIntArray): TIntArray; stdcall;
  985. var
  986.   i, m, r: Integer;
  987. begin
  988.   m := Min(High(TIA1), High(TIA2));
  989.   if (m > -1) then
  990.   begin  
  991.     SetLength(Result, (m + 1));
  992.     for i := 0 to m do
  993.       if (TIA1[i] = TIA2[i]) then
  994.       begin
  995.         Result[r] := i;
  996.         Inc(r);
  997.       end;
  998.     SetLength(Result, r);  
  999.   end else
  1000.     SetLength(Result, 0);        
  1001. end;
  1002.  
  1003. {==============================================================================]
  1004.   Explanation: Returns the count of positions where TIA1[*] does not match TIA2[*].
  1005.                (* = same positions)
  1006. [==============================================================================}
  1007. function MSSL_TIAUnmatch(TIA1, TIA2: TIntArray): Integer; stdcall;
  1008. var
  1009.   i, m: Integer;
  1010. begin
  1011.   Result := 0;
  1012.   m := Min(High(TIA1), High(TIA2));
  1013.   for i := 0 to m do
  1014.     if (TIA1[i] <> TIA2[i]) then
  1015.       Inc(Result);
  1016. end;
  1017.  
  1018. {==============================================================================]
  1019.   Explanation: Returns all positions where TIA1[*] does not match TIA2[*].
  1020.                (* = same positions)
  1021. [==============================================================================}
  1022. function MSSL_TIAUnmatches(TIA1, TIA2: TIntArray): TIntArray; stdcall;
  1023. var
  1024.   i, m, r: Integer;
  1025. begin
  1026.   m := Min(High(TIA1), High(TIA2));
  1027.   if (m > -1) then
  1028.   begin
  1029.     SetLength(Result, (m + 1));
  1030.     for i := 0 to m do
  1031.       if (TIA1[i] <> TIA2[i]) then
  1032.       begin
  1033.         Result[r] := i;
  1034.         Inc(r);
  1035.       end;    
  1036.   end;
  1037.   SetLength(Result, r);
  1038. end;
  1039.  
  1040. {==============================================================================]
  1041.   Explanation: Will return all the items that are unique in TIA.
  1042. [==============================================================================}
  1043. function MSSL_TIAGetUniques(TIA: TIntArray): TIntArray; stdcall;
  1044. var
  1045.   h, i, i2, r: Integer;
  1046. begin
  1047.   h := High(TIA);
  1048.   if (h < 1) then
  1049.   begin
  1050.     SetLength(Result, (h + 1));
  1051.     for i := 0 to h do
  1052.       Result[i] := Integer(TIA[i]);
  1053.     Exit;
  1054.   end;
  1055.   SetLength(Result, (h + 1));
  1056.   for i := 0 to h do
  1057.   begin
  1058.     for i2 := 0 to h do
  1059.       if (i2 <> i) then
  1060.         if (TIA[i] = TIA[i2]) then
  1061.           Break;
  1062.     if (i2 <= h) then
  1063.       Continue;
  1064.     Result[r] := Integer(TIA[i]);
  1065.     Inc(r);
  1066.   end;
  1067.   SetLength(Result, r);
  1068. end;
  1069.  
  1070. {==============================================================================]
  1071.   Explanation: Returns true if TIA is equal to TIA2.
  1072.                Ignores specialMatch value in both of the arrays
  1073.                (..that means, they are always counted as match!)
  1074. [==============================================================================}
  1075. function MSSL_TIAEquals(TIA1, TIA2: TIntArray; specialMatch: Integer): Boolean; stdcall;
  1076. var
  1077.   h, i: Integer;
  1078. begin
  1079.   Result := False;
  1080.   h := High(TIA1);
  1081.   if ((h > -1) and (h = High(TIA2))) then
  1082.   begin
  1083.     for i := 0 to h do
  1084.       if ((TIA1[i] <> specialMatch) and (TIA2[i] <> specialMatch) and (TIA1[i] <> TIA2[i])) then
  1085.         Break;  
  1086.     Result := (i > h);
  1087.   end;
  1088. end;
  1089.  
  1090. {==============================================================================]
  1091.   Explanation: Returns true if TIA is equal to TIA2.
  1092.                Ignores values from specialMatches in both of the arrays
  1093.                (..that means, they are always counted as match!)
  1094. [==============================================================================}
  1095. function MSSL_TIAEqualsEx(TIA1, TIA2, specialMatches: TIntArray): Boolean; stdcall;
  1096. var
  1097.   h, i: Integer;
  1098. begin
  1099.   h := High(TIA1);
  1100.   if ((h > -1) and (h = High(TIA2))) then
  1101.   begin
  1102.     for i := 0 to h do
  1103.       if (not TIAContains(specialMatches, TIA1[i]) and not TIAContains(specialMatches, TIA2[i]) and (TIA1[i] <> TIA2[i])) then
  1104.         Break;  
  1105.     Result := (i > h);
  1106.   end else
  1107.     Result := False;
  1108. end;
  1109.  
  1110. {==============================================================================]
  1111.   Explanation: Returns true if ALL values in arr are identical to each other.
  1112. [==============================================================================}
  1113. function MSSL_TIAAllValuesSame(arr: TIntArray): Boolean; stdcall;
  1114. var
  1115.   h, i: Integer;
  1116. begin
  1117.   h := High(arr);
  1118.   if (h < 1) then
  1119.   begin
  1120.     Result := (h = 0);
  1121.     Exit;
  1122.   end;  
  1123.   Result := False;
  1124.   for i := 1 to h do
  1125.     if (arr[i] <> arr[0]) then
  1126.       Exit;
  1127.   Result := True;
  1128. end;
  1129.  
  1130. {==============================================================================]
  1131.   Explanation: Returns true if ALL values in arr are unique to each other.
  1132. [==============================================================================}
  1133. function MSSL_TIAAllValuesUnique(arr: TIntArray): Boolean; stdcall;
  1134. var
  1135.   h, i, i2: Integer;
  1136. begin
  1137.   h := High(arr);
  1138.   if (h < 1) then
  1139.   begin
  1140.     Result := (h = 0);
  1141.     Exit;
  1142.   end;    
  1143.   Result := False;
  1144.   for i := 0 to (h - 1) do
  1145.     for i2 := (i + 1) to h do
  1146.       if (i <> i2) then
  1147.       begin
  1148.         Result := (arr[i] <> arr[i2]);
  1149.         if not Result then
  1150.           Exit;
  1151.       end;
  1152. end;
  1153.  
  1154. {==============================================================================]
  1155.   Explanation: Splits given TIntArray (TIA) into T2DIntArray by grouping together the integer values
  1156.                that are within a given difference range (minDifference, maxDifference) from each other.
  1157. [==============================================================================}
  1158. function MSSL_TIASplitEx(TIA: TIntArray; minDifference, maxDifference: Integer): T2DIntArray; stdcall;
  1159. var
  1160.   a, b, h, l, i, r, d, t: Integer;
  1161. begin
  1162.   h := High(TIA);
  1163.   if (h > -1) then
  1164.   begin                
  1165.     SetLength(Result, (h + 1));
  1166.     SetLength(Result[0], 1);
  1167.     Result[0][0] := Integer(TIA[0]);
  1168.     if (h > 0) then
  1169.     begin                  
  1170.       r := 1;
  1171.       if (minDifference > maxDifference) then
  1172.       begin
  1173.         t := minDifference;
  1174.         minDifference := maxDifference;
  1175.         maxDifference := t;
  1176.       end;
  1177.       for i := 1 to h do    
  1178.       begin
  1179.         for a := 0 to (r - 1) do
  1180.         begin
  1181.           l := Length(Result[a]);
  1182.           for b := 0 to (l - 1) do      
  1183.           begin
  1184.             d := Abs(TIA[i] - Result[a][b]);
  1185.             if ((d >= minDifference) and (d <= maxDifference)) then
  1186.             begin
  1187.               SetLength(Result[a], (l + 1));
  1188.               Result[a][l] := Integer(TIA[i]);
  1189.               Break;
  1190.             end;
  1191.           end;  
  1192.           if (b < l) then
  1193.             Break;
  1194.         end;    
  1195.         if (a >= r) then
  1196.         begin
  1197.           SetLength(Result[r], 1);
  1198.           Result[r][0] := Integer(TIA[i]);
  1199.           Inc(r);
  1200.         end;
  1201.       end;
  1202.     end;
  1203.   end;
  1204.   SetLength(Result, r);
  1205. end;
  1206.  
  1207. {==============================================================================]
  1208.   Explanation: Splits given TIntArray (TIA) into T2DIntArray by grouping together the integer values
  1209.                that are within a given difference from each other.
  1210. [==============================================================================}
  1211. function MSSL_TIASplit(TIA: TIntArray; difference: Integer): T2DIntArray; stdcall;
  1212. begin
  1213.   Result := MSSL_TIASplitEx(TIA, 0, difference);
  1214. end;
  1215.  
  1216. {==============================================================================]
  1217.   Explanation: Splits given TIntArray (TIA) into T2DIntArray by grouping together the integer values
  1218.                that are within a given difference range (minDifference, maxDifference) of the first integer value in the sub-array.
  1219. [==============================================================================}
  1220. function MSSL_TIAGroupEx(TIA: TIntArray; minDifference, maxDifference: Integer): T2DIntArray; stdcall;
  1221. var
  1222.   a, h, l, i, r, d, t: Integer;
  1223. begin
  1224.   h := High(TIA);
  1225.   if (h > -1) then
  1226.   begin                
  1227.     SetLength(Result, (h + 1));
  1228.     SetLength(Result[0], 1);
  1229.     Result[0][0] := Integer(TIA[0]);
  1230.     if (h > 0) then
  1231.     begin
  1232.       r := 1;
  1233.       if (minDifference > maxDifference) then
  1234.       begin
  1235.         t := minDifference;
  1236.         minDifference := maxDifference;
  1237.         maxDifference := t;
  1238.       end;
  1239.       for i := 1 to h do    
  1240.       begin
  1241.         for a := 0 to (r - 1) do
  1242.         begin
  1243.           d := Abs(TIA[i] - Result[a][0]);
  1244.           if ((d >= minDifference) and (d <= maxDifference)) then
  1245.           begin
  1246.             l := Length(Result[a]);
  1247.             SetLength(Result[a], (l + 1));
  1248.             Result[a][l] := Integer(TIA[i]);
  1249.             Break;
  1250.           end;
  1251.         end;    
  1252.         if (a >= r) then
  1253.         begin
  1254.           SetLength(Result[r], 1);
  1255.           Result[r][0] := Integer(TIA[i]);
  1256.           Inc(r);
  1257.         end;
  1258.       end;
  1259.     end;
  1260.   end;
  1261.   SetLength(Result, r);
  1262. end;
  1263.  
  1264. {==============================================================================]
  1265.   Explanation: Splits given TIntArray (TIA) into T2DIntArray by grouping together the integer values
  1266.                that are within a given difference range of the first integer value in the sub-array.
  1267. [==============================================================================}
  1268. function MSSL_TIAGroup(TIA: TIntArray; difference: Integer): T2DIntArray; stdcall;
  1269. begin
  1270.   Result := MSSL_TIAGroupEx(TIA, 0, difference);
  1271. end;
  1272.  
  1273. type
  1274.   TExportCommand = record
  1275.     procAddr: Pointer;
  1276.     procDef: string;
  1277.   end;
  1278.  
  1279. var
  1280.   ecA: array of TExportCommand;
  1281.   ecL: Boolean;
  1282.  
  1283. procedure EC(procAddr: Pointer; procDef: string);
  1284. var
  1285.   l: Integer;
  1286. begin
  1287.   l := Length(ecA);
  1288.   SetLength(ecA, (l + 1));
  1289.   ecA[l].procAddr := procAddr;
  1290.   ecA[l].procDef := procDef;
  1291. end;
  1292.  
  1293. procedure ECS;
  1294. begin
  1295.   EC(@MSSL_TIAByRange, 'function MSSL_TIAByRange(aStart, aFinish: Integer): TIntArray;');
  1296.   EC(@MSSL_TIAByRange2Bit, 'function MSSL_TIAByRange2Bit(aStart, aFinish: Integer): TIntArray;');
  1297.   EC(@MSSL_TIAOfInteger, 'function MSSL_TIAOfInteger(x, count: Integer): TIntArray;');
  1298.   EC(@MSSL_IntDigits, 'function MSSL_IntDigits(int: Integer): TIntArray;');
  1299.   EC(@MSSL_StrIsInt, 'function MSSL_StrIsInt(str: string): Boolean;');
  1300.   EC(@MSSL_IntSetMin, 'procedure MSSL_IntSetMin(var val: Integer; x: Integer);');
  1301.   EC(@MSSL_IntSetMax, 'procedure MSSL_IntSetMax(var val: Integer; x: Integer);');
  1302.   EC(@MSSL_IntSetRange, 'procedure MSSL_IntSetRange(var val: Integer; mn, mx: Integer);');
  1303.   EC(@MSSL_TIASetMin, 'procedure MSSL_TIASetMin(var TIA: TIntArray; x: Integer);');
  1304.   EC(@MSSL_TIASetMax, 'procedure MSSL_TIASetMax(var TIA: TIntArray; x: Integer);');
  1305.   EC(@MSSL_TIASetRange, 'procedure MSSL_TIASetRange(var TIA: TIntArray; mn, mx: Integer);');
  1306.   EC(@MSSL_TIAControlByRange, 'procedure MSSL_TIAControlByRange(var TIA: TIntArray; minimum, maximum: Integer; method: MSSL_TControlMethod);');
  1307.   EC(@MSSL_TIABuiltWith, 'function MSSL_TIABuiltWith(TIA, allowed: TIntArray): Boolean;');
  1308.   EC(@MSSL_TIARandomizeEx, 'procedure MSSL_TIARandomizeEx(var TIA: TIntArray; shuffles: Integer);');
  1309.   EC(@MSSL_TIARandomize, 'procedure MSSL_TIARandomize(var TIA: TIntArray);');
  1310.   EC(@MSSL_TIADelete, 'function MSSL_TIADelete(var TIA: TIntArray; x: Integer): Boolean;');
  1311.   EC(@MSSL_TIARemove, 'procedure MSSL_TIARemove(var TIA: TIntArray; x: TIntArray);');
  1312.   EC(@MSSL_TIAAdd, 'function MSSL_TIAAdd(var TIA: TIntArray; addTIA: TIntArray): Integer;');
  1313.   EC(@MSSL_TIAPositions, 'function MSSL_TIAPositions(TIA: TIntArray; x: Integer): TIntArray;');
  1314.   EC(@MSSL_TIAPositionsMulti, 'function MSSL_TIAPositionsMulti(TIA, ints: TIntArray): TIntArray;');
  1315.   EC(@MSSL_TIAPositionsEx, 'function MSSL_TIAPositionsEx(TIA, ints: TIntArray): TIntArray;');
  1316.   EC(@MSSL_TIACopyEx, 'function MSSL_TIACopyEx(TIA: TIntArray; pos1, pos2: Integer): TIntArray;');
  1317.   EC(@MSSL_TIAMove, 'function MSSL_TIAMove(var TIA: TIntArray; oldIndex, newIndex: Integer): Boolean;');
  1318.   EC(@MSSL_TIAToParts, 'function MSSL_TIAToParts(TIA: TIntArray; method: MSSL_TPartitionMethod; x: Integer): T2DIntArray;');
  1319.   EC(@MSSL_TIARangeFrom, 'function MSSL_TIARangeFrom(start, step, count: Integer): TIntArray;');
  1320.   EC(@MSSL_TIAGetEx, 'function MSSL_TIAGetEx(TIA, IDs: TIntArray; var iIDs: TIntArray): TIntArray;');
  1321.   EC(@MSSL_TIAGet, 'function MSSL_TIAGet(TIA, IDs: TIntArray): TIntArray;');
  1322.   EC(@MSSL_TIARemoveEx, 'procedure MSSL_TIARemoveEx(var TIA: TIntArray; x: TIntArray);');
  1323.   EC(@MSSL_TIACopy, 'procedure MSSL_TIACopy(source: TIntArray; var target: TIntArray; resetTarget: Boolean);');
  1324.   EC(@MSSL_TIATransferEx, 'procedure MSSL_TIATransferEx(var source, target: TIntArray; resetTarget: Boolean);');
  1325.   EC(@MSSL_TIATransfer, 'procedure MSSL_TIATransfer(var source, target: TIntArray);');
  1326.   EC(@MSSL_TIAPlant, 'function MSSL_TIAPlant(var TIA: TIntArray; index: Integer; ints: TIntArray): Integer;');
  1327.   EC(@MSSL_TIAPick, 'function MSSL_TIAPick(var TIA: TIntArray; pick_ID: Integer): Integer;');
  1328.   EC(@MSSL_TIAPickEx, 'function MSSL_TIAPickEx(var TIA: TIntArray; pick_IDs: TIntArray): TIntArray;');
  1329.   EC(@MSSL_TIAMatchEx, 'function MSSL_TIAMatchEx(TIA1, TIA2, specialMatches: TIntArray): Integer;');
  1330.   EC(@MSSL_TIAMatch2, 'function MSSL_TIAMatch2(TIA1, TIA2: TIntArray; specialMatch: Integer): Integer;');
  1331.   EC(@MSSL_TIAMatch, 'function MSSL_TIAMatch(TIA1, TIA2: TIntArray): Integer;');
  1332.   EC(@MSSL_TIAMatchesEx, 'function MSSL_TIAMatchesEx(TIA1, TIA2, specialMatches: TIntArray): TIntArray;');
  1333.   EC(@MSSL_TIAMatches2, 'function MSSL_TIAMatches2(TIA1, TIA2: TIntArray; specialMatch: Integer): TIntArray;');
  1334.   EC(@MSSL_TIAMatches, 'function MSSL_TIAMatches(TIA1, TIA2: TIntArray): TIntArray;');
  1335.   EC(@MSSL_TIAUnmatch, 'function MSSL_TIAUnmatch(TIA1, TIA2: TIntArray): Integer;');
  1336.   EC(@MSSL_TIAUnmatches, 'function MSSL_TIAUnmatches(TIA1, TIA2: TIntArray): TIntArray;');
  1337.   EC(@MSSL_TIAGetUniques, 'function MSSL_TIAGetUniques(TIA: TIntArray): TIntArray;');
  1338.   EC(@MSSL_TIAEquals, 'function MSSL_TIAEquals(TIA1, TIA2: TIntArray; specialMatch: Integer): Boolean;');
  1339.   EC(@MSSL_TIAEqualsEx, 'function MSSL_TIAEqualsEx(TIA1, TIA2, specialMatches: TIntArray): Boolean;');
  1340.   EC(@MSSL_TIAAllValuesSame, 'function MSSL_TIAAllValuesSame(arr: TIntArray): Boolean;');
  1341.   EC(@MSSL_TIAAllValuesUnique, 'function MSSL_TIAAllValuesUnique(arr: TIntArray): Boolean;');
  1342.   EC(@MSSL_TIASplitEx, 'function MSSL_TIASplitEx(TIA: TIntArray; minDifference, maxDifference: Integer): T2DIntArray;');
  1343.   EC(@MSSL_TIASplit, 'function MSSL_TIASplit(TIA: TIntArray; difference: Integer): T2DIntArray;');
  1344.   EC(@MSSL_TIAGroupEx, 'function MSSL_TIAGroupEx(TIA: TIntArray; minDifference, maxDifference: Integer): T2DIntArray;');
  1345.   EC(@MSSL_TIAGroup, 'function MSSL_TIAGroup(TIA: TIntArray; difference: Integer): T2DIntArray;');
  1346.   ecL := True;
  1347. end;
  1348.  
  1349. procedure ECU;
  1350. begin
  1351.   SetLength(ecA, 0);
  1352.   ecL := False;
  1353. end;
  1354.  
  1355. function GetFunctionCount(): Integer; stdcall;
  1356. begin
  1357.   if not ecL then
  1358.     ECS;
  1359.   Result := Length(ecA);
  1360. end;
  1361.  
  1362. function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PAnsiChar): Integer; stdcall;
  1363. var
  1364.   c: TExportCommand;
  1365. begin
  1366.   case ((x > -1) and InRange(x, Low(ecA), High(ecA))) of
  1367.     True:
  1368.     begin
  1369.       ProcAddr := ecA[x].procAddr;
  1370.       StrPCopy(ProcDef, ecA[x].procDef);
  1371.       Result := x;
  1372.       if (Result = High(ecA)) then
  1373.         ecU;
  1374.     end;
  1375.     False: Result := -1;
  1376.   end;
  1377. end;
  1378.  
  1379. exports GetFunctionCount;
  1380. exports GetFunctionInfo;
  1381.  
  1382. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement