Browse Source

StringsToArray function

Unknown 6 years ago
parent
commit
87473aa6a6
1 changed files with 15 additions and 1 deletions
  1. 15 1
      Quick.Commons.pas

+ 15 - 1
Quick.Commons.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.8
   Created     : 14/07/2017
-  Modified    : 01/07/2019
+  Modified    : 27/08/2019
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -279,6 +279,8 @@ type
   function CommaText(aList : TStringList) : string; overload;
   //returns a real comma separated text from array of string
   function CommaText(aArray : TArray<string>) : string; overload;
+  //converts TStrings to array
+  function StringsToArray(aStrings : TStrings) : TArray<string>;
   {$IFDEF MSWINDOWS}
   //process messages on console applications
   procedure ProcessMessages;
@@ -1273,6 +1275,18 @@ begin
   end;
 end;
 
+function StringsToArray(aStrings : TStrings) : TArray<string>;
+var
+  i : Integer;
+begin
+  if aStrings.Count = 0 then Exit;
+  SetLength(Result,aStrings.Count);
+  for i := 0 to aStrings.Count - 1 do
+  begin
+    Result[i] := aStrings[i];
+  end;
+end;
+
 { TCounter }
 
 procedure TCounter.Init(aMaxValue : Integer);