I am stuck on something that I'm pretty sure is a basic concept...
I'm using Delphi 7 and I want to pass the resulting value of a function from one Delphi file in a project to another file in the same project. In the code below (OPCDEFS.PAS) I call the function OPCMaxTrend, to establish the maximum limit that the OPC server should look for.
In the piece of code below from another file (DEVICE_OPC.PAS) I want to use the value that the function OPCMaxTrend returns where now there is a constant (99).
If I change the 99 to OPCMaxTrend it doesn't work and gives me an error (Undeclared identifier: 'OPCMaxTrend') when it compiles. There's a good chance I'm either trying to do something that can't be done or I'm missing a very basic concept. I'm very new to programming of any sort and would appreciate any help. If this is the wrong place to be posting a message like this, please just let me know and if you do know where I can ask basic questions like this, I'd appreciate you letting me know.
I'm using Delphi 7 and I want to pass the resulting value of a function from one Delphi file in a project to another file in the same project. In the code below (OPCDEFS.PAS) I call the function OPCMaxTrend, to establish the maximum limit that the OPC server should look for.
Code:
unit OpcDefs;
interface
const
Opc_Device1 = 1002;
Opc_Device2 = 1005;
Opc_Device3 = 1006;
Opc_Device4 = 1010;
{Attempt to make each device configurable for trend tag limits}
OPC_Device1_MaxTrend = 99;
OPC_Device2_MaxTrend = 79;
OPC_Device3_MaxTrend = 39;
OPC_Device4_MaxTrend = 19;
{.PA}
(**)
(**)
implementation
(**)
(**)
uses
SysUtils;
{Attempt to make a variable that is for the maximum trend address}
function OPCMaxTrend(const Device : integer) : integer;
begin
Result := 0;
case Device of
Opc_Device1 : Result := OPC_Device1_MaxTrend;
Opc_Device2 : Result := OPC_Device2_MaxTrend;
OPC_Device3 : Result := OPC_Device3_MaxTrend;
Opc_Device4 : Result := OPC_Device4_MaxTrend;
else
if (Device <> 0) then Result := 99;
end;
end;
end.
In the piece of code below from another file (DEVICE_OPC.PAS) I want to use the value that the function OPCMaxTrend returns where now there is a constant (99).
Code:
procedure TDeviceOpcTnd.AddTrendTags;
var
Reg : integer;
begin
if not Assigned(OpcGroup) then Exit;
for Reg := 0 to 99 do {<--- Need to make the 99 a variable that changes based on OPCMaxTrend value}
try
OpcGroup.OPCItems.AddItem(OpcTopicStr + ':' + IntToStr(Reg)); //Device Type
except
end;
end;
If I change the 99 to OPCMaxTrend it doesn't work and gives me an error (Undeclared identifier: 'OPCMaxTrend') when it compiles. There's a good chance I'm either trying to do something that can't be done or I'm missing a very basic concept. I'm very new to programming of any sort and would appreciate any help. If this is the wrong place to be posting a message like this, please just let me know and if you do know where I can ask basic questions like this, I'd appreciate you letting me know.