procedure TForm1.BitBtn5Click(Sender: TObject);
var
MyForm:TForm;
FormClass:TFormClass;
begin
FormClass:=TFormClass(FindClass('TForm1'));
if FormClass<>nil then
MyForm:=FormClass.Create(nil);
try
MyForm.ShowModal;
finally
MyForm.Free;
end;
end;
type
TVar = class
public
Name: string;
Value: Variant;
end;
TVarNameSpace = class
private
fVarList: TStringList;
public
Name: string;
function IsDefine(const aVarName: string): Boolean;
function GetVar(const aVarName: string): TVar;
end;
TGlobalVarList = class
private
fNULLNameSpace: TVarNameSpace;
fNameSpaceList: TStringList;
public
function IsDefined(const aVarName: string; const aNameSpace: string = ''): Boolean;
function DefineVar(const aVarName: string; const aNameSpace: string = ''): TVar;
function GetVar(const aVarName: string; const aNameSpace: stirng = ''): TVar;
end;
var
GlobalVarList: TGlobalVarList;
function DefineVar(const aVarName: string): TVar;
function GetVar(const aVarName: string): TVar;
implementation
function DefineVar(const aVarName: string): TVar;
begin
Result := GlobalVarList.DefineVar(aVarName, '');
end;
function GetVar(const aVarName: string): TVar;
begin
Result := GlobalVarList.GetVar(aVarName, '');
end;
...
end.
usage:
===============
uses
NamingVariable;
......
Variable := DefineVar('Code');
....
GetVar('Code').Value := 100;
or
Variable.Value := 100;