So I have a function that takes a dataset and needs to return all values from a field. I can't figure out how to make the function return an array, as when I declare an array I keep get the error
[DCC Error] dataModuleImportMonetar.pas(20): E2003 Undeclared identifier: 'nr'
Here is my code
unit dataModuleImportMonetar;
interface
uses
SysUtils, Classes, DB, ADODB;
type
TDataModule2 = class(TDataModule)
conn: TADOConnection;
importMonetar: TADOStoredProc;
qMonetare: TADOQuery;
private
{ Private declarations }
//nr : Array[Word] of Integer;
nr : IntegerArray;
public
{ Public declarations }
function nrFisiere ( dataSet : TDataSet) : nr ;
end;
var
DataModule2: TDataModule2;
implementation
{$R *.dfm}
{ TDataModule2 }
function TDataModule2.nrFisiere(dataSet: TDataSet): nr;
var
i : Integer;
begin
dataSet.First;
for i := 0 to dataSet.RecordCount do
begin
Return nr[i] := dataSet.FieldByName('nrMonetare').Value;
end;
end;
end.
What Am I doing wrong? How cand I declare a function that will return an array of Integer
For @TLama
If I do that ( already did before asking )
type
TDataModule2 = class(TDataModule)
conn: TADOConnection;
importMonetar: TADOStoredProc;
TIntArray : array of Integer;
qMonetare: TADOQuery;
I get an othe error [DCC Error] dataModuleImportMonetar.pas(12): E2217 Published field 'TIntArray' not a class or interface type
type, not declare a variable.IntegerArray = array[0..$effffff] of Integer;. Thus the field nr will occupy about 1GB of memory.:instead of=.