I have a unit that does not contain a form, dedicated to global functions and variables. I'm trying to access it from a Unit that contains a form.
The functions share nicely but I can't seem to get the right location/syntax in the global unit to "globalize" a TStringList variable. When I try to call the variable in the target unit from the Form unit, the compile complains with: "Error: Identifier not found "StrLst." The variable I'm trying to make global, StrLst is denoted below by a string of ///////////////. I've tried every combination of public/private declarations I can think of and they either leave me with a cryptic, "Expected ;..." or other.
Please be kind. It's been a couple decades now since I last used any flavor of Pascal. I've apparently gotten sloppy at declaring things pretty much where I want to use them.
Thanks in advance.
unit DevCommonUnit;
{$mode objfpc}{$H+}
interface
function OpenDevices(VAR iNumDevices : integer) : boolean;
function GetSerialNumbers(SpecNumber : integer) : String;
implementation
uses
Classes, SysUtils, Dialogs;
type
DeviceTypes = (OO, Undefined);
const
DONE : Integer = 1;
//ERROR_NO_DEVICE : Integer = 2;
EPROM_RETURN : Integer = 17;
var
ActiveDevice : STypes = OO;
StrLst : TStringList;//////////////////////////////////////////////////////////////////
function get_formatted (iSpecNumber:Integer; errorcode:PInteger; VAR buffer:Double; buffer_length:Integer):Integer;
cdecl; external 'C:\windows\system32\devicedriver.dll';
function get_formatted_length(iSpecNumber : Integer; errorcode:PInteger):Integer; cdecl;
external 'C:\windows\system32\devicedriver.dll';
function open_Device(iWorking:Integer; errorcode:PInteger):Integer; cdecl;
external 'C:\windows\system32\devicedriver.dll';
function get_serial_number(index : Integer; errorcode : PInteger; VAR buf : array of byte; buffer_length : integer) : Integer;
cdecl; external 'C:\windows\system32\devicedriver.dll';
function OpenDevices(VAR iNumDevices : integer) : boolean;
var
DoneOrNot : integer = 0;
iWorking : integer = 0;
errorCode : integer = 0;
i : integer = 0;
strSerial : String = '';
begin // OpenDevices
try
try
case ActiveDevice of
OO:
while true do
begin
DoneOrNot := open_Device(iWorking, @errorCode);
If (DoneOrNot = DONE) Then
Break
Else
Begin
iWorking := iWorking + 1;
end;
end;
Undefined: ;
end;
except
On E :Exception do begin
ShowMessage(E.Message);
end;
end;
finally
end;
iNumDevices := iWorking;
OpenDevices := TRUE;
StrLst := TStringList.Create;
for i := 1 to iNumDevices do
begin
strSerial := GetSerialNumbers(i);
StrLst.Add(strSerial);
end;
end; // OpenDevices
...