The following code works perfectly if I use 2 different PROCEDURE names and no OVERLOADing.
When I attempt the OVERLOAD, I get the error,
"There is no overloaded version of 'AssignPcode' that can be called with these arguments."
Here is the code:
[tt]
unit U_overload;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
IntMatrix = array[0..10,0..4] of Integer;
TForm1 = class (TForm)
PROCEDURE FormCreate (Sender : TObject);
private
public
end;
VAR
Form1: TForm1;
gPcode : Integer;
gP : Array[0..4] of Integer;
allPcode : Array[0..4] of Integer;
allP : IntMatrix;
PROCEDURE AssignPcode ( code:Integer ;
VAR P:Array of Integer ); OVERLOAD;
PROCEDURE AssignPcode ( Pcode:Array of Integer ;
VAR Q:IntMatrix ;
n:Integer ); OVERLOAD;
implementation
{$R *.DFM}
//_________________________________________________________
PROCEDURE TForm1.FormCreate(Sender: TObject);
VAR
n : Integer;
BEGIN
gPcode := 10000;
allPcode [0] := 11111;
allPcode [1] := 2;
allPcode [2] := 30000;
n :=3;
AssignPcode ( gPcode, gP );
AssignPcode ( allPcode, allP, n );
ShowMessage (inttostr( gP[ 0])+#13+inttostr( gP[ 4]));
ShowMessage (inttostr(allP[0,0])+#13+inttostr(allP[3,0]));
END;
//_________________________________________________________
PROCEDURE AssignPcode ( code : Integer ;
VAR P: Array of Integer ); OVERLOAD;
BEGIN
P[0] := (code mod 100000) div 10000;
P[4] := (code mod 10 ) div 1 ;
END;
//_________________________________________________________
PROCEDURE AssignPcodf (Pcode : Array of Integer ;
VAR Q : IntMatrix ;
n : Integer );OVERLOAD;
VAR
i : Integer;
BEGIN
FOR i := 0 TO n-1 DO BEGIN
Q[i,0] := (Pcode mod 100000) div 10000;
Q[i,4] := (Pcode mod 10 ) div 1 ;
END;
END;
END.
[/tt]
When I attempt the OVERLOAD, I get the error,
"There is no overloaded version of 'AssignPcode' that can be called with these arguments."
Here is the code:
[tt]
unit U_overload;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
IntMatrix = array[0..10,0..4] of Integer;
TForm1 = class (TForm)
PROCEDURE FormCreate (Sender : TObject);
private
public
end;
VAR
Form1: TForm1;
gPcode : Integer;
gP : Array[0..4] of Integer;
allPcode : Array[0..4] of Integer;
allP : IntMatrix;
PROCEDURE AssignPcode ( code:Integer ;
VAR P:Array of Integer ); OVERLOAD;
PROCEDURE AssignPcode ( Pcode:Array of Integer ;
VAR Q:IntMatrix ;
n:Integer ); OVERLOAD;
implementation
{$R *.DFM}
//_________________________________________________________
PROCEDURE TForm1.FormCreate(Sender: TObject);
VAR
n : Integer;
BEGIN
gPcode := 10000;
allPcode [0] := 11111;
allPcode [1] := 2;
allPcode [2] := 30000;
n :=3;
AssignPcode ( gPcode, gP );
AssignPcode ( allPcode, allP, n );
ShowMessage (inttostr( gP[ 0])+#13+inttostr( gP[ 4]));
ShowMessage (inttostr(allP[0,0])+#13+inttostr(allP[3,0]));
END;
//_________________________________________________________
PROCEDURE AssignPcode ( code : Integer ;
VAR P: Array of Integer ); OVERLOAD;
BEGIN
P[0] := (code mod 100000) div 10000;
P[4] := (code mod 10 ) div 1 ;
END;
//_________________________________________________________
PROCEDURE AssignPcodf (Pcode : Array of Integer ;
VAR Q : IntMatrix ;
n : Integer );OVERLOAD;
VAR
i : Integer;
BEGIN
FOR i := 0 TO n-1 DO BEGIN
Q[i,0] := (Pcode mod 100000) div 10000;
Q[i,4] := (Pcode mod 10 ) div 1 ;
END;
END;
END.
[/tt]