Jump to content
FranzB

Tarray , uses unit not found :-(

Recommended Posts

which unit contains the TArray class , I*m  using Delphi 10.4 

 

not  working units

 

  
System.Generics.Collections.TArray,
System.TArray,

 

 

Share this post


Link to post

I want to compile this test code below  for regular expressions, but none uses option works for me ... 

 

error 

 

[dcc32 Fatal Error] ..... .pas(10): F2613 Unit 'System.Generics.Collections.TArray' not found.

 

 

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
  FMX.StdCtrls, FMX.ScrollBox, FMX.Memo, FMX.Controls.Presentation, FMX.Edit,
 // System.Generics.Collections.TArray,
 // System.TArray,
  System.RegularExpressions;;





.....

procedure TForm2.Button_evalregexpressionsClick(Sender: TObject);
var
  regex: string;
  analysistxt: string;

  list: TArray<string>;
  item: String;

begin
  regex := Edit_regexp.Text;
  analysistxt := Edit_analysisText.Text;

  list := TRegEx.Split(analysistxt, regex);
  for item in list do
  begin
    ShowMessage(item);
  end;

end;

end.

 

Share this post


Link to post

I'm not sure if think you might be thinking that 'uses' works similarly to the 'import' statement in Java. In Java, you normally import the type from the fully qualified package as you have attempted.

 

'System.Generics.Collections' is the unit, with many types/functions defined within. if you just needed to use it, you simply do 'uses System.Generics.Collections;'


From the online help, if you see something like 'System.Generic.Collections.TArray' -  it normally means that 'TArray' will be defined in 'System.Generics.Collections', so you 'uses' as illustrated above.

 

Share this post


Link to post
19 hours ago, FranzB said:

error


[dcc32 Fatal Error] ..... .pas(10): F2613 Unit 'System.Generics.Collections.TArray' not found.

The non-generic TArray is a type in the System unit, and the generic TArray<T> is a type in the System.Generics.Collections unit.  The uses clause is used to specify units only, not types.  TArray is not its own unit, so don't specify TArray in your uses clause, eg you need to change 'System.Generics.Collections.TArray' to just 'System.Generics.Collections' in the uses clause.  But don't change 'System.TArray' to 'System', just drop it entirely, as specify 'System' by itself in a uses clause will cause a compiler error (the System unit is already used implicitly in every unit).

 

Edited by Remy Lebeau

Share this post


Link to post
On 11/3/2021 at 7:23 PM, Remy Lebeau said:

The non-generic TArray is a type in the System unit, and the generic TArray<T> is a type in the System.Generics.Collections unit. 

TArray<T> = array of T;

XE2's System.pas...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×