📄 un_functions.~pas
字号:
unit Un_Functions;
interface
uses
Classes, SysUtils,dialogs;
type
TFunctionStrParser=class
private
FFuncKey: string;
FFuncId: string;
FParamValue: string;
function GetIsPlugin: Boolean;
function GetIsTable: Boolean;
public
function DoParse(FuncStr: string): Boolean;
property FuncKey: string read FFuncKey;
property FuncId: string read FFuncId;
property IsPlugin: Boolean read GetIsPlugin;
property IsTable: Boolean read GetIsTable;
property ParamValue: string read FParamValue;
end;
TSytemFunction=class
private
FFunctionStrParser: TFunctionStrParser;
function DoRun(FuncStr: string): Boolean;
public
constructor Create;
destructor Destroy; override;
class function Run(FunctionString: string): Boolean;
end;
implementation
uses
Un_FormFactory, Un_PluginManager;
{ TSytemFunction }
constructor TSytemFunction.Create;
begin
FFunctionStrParser:= TFunctionStrParser.Create;
end;
destructor TSytemFunction.Destroy;
begin
FFunctionStrParser.Free;
inherited;
end;
function TSytemFunction.DoRun(FuncStr: string): Boolean;
begin
Result:= False;
if FFunctionStrParser.DoParse(FuncStr) then begin
if FFunctionStrParser.IsPlugin then
TPluginFactory.Instance.GetPlugin(FFunctionStrParser.FuncId).Execute(FFunctionStrParser.ParamValue)
else if FFunctionStrParser.IsTable then
TEntityFormFactory.Instance.CreateForm(FFunctionStrParser.FuncId);
Result:= True;
end;
end;
class function TSytemFunction.Run(FunctionString: string): Boolean;
begin
with TSytemFunction.Create do begin
try
Result:= DoRun(FunctionString);
finally
Free;
end;
end;
end;
{ TFunctionStrParser }
function TFunctionStrParser.DoParse(FuncStr: string): Boolean;
var
Index: Integer;
TmpStr: string;
begin
Result:= False;
Index:= Pos('::', FuncStr);
if Index>0 then begin
TmpStr:= FuncStr;
Delete(TmpStr, Index, Length(TmpStr));
FFuncKey:= UpperCase(Trim(TmpStr));
TmpStr:= FuncStr;
Delete(TmpStr, 1, Index+1);
FFuncId:= UpperCase(Trim(TmpStr));
if (FFuncId='') or (FFuncKey='') then begin
Result:= False;
FParamValue:= '';
end
else begin
Result:= True;
//showmessage(FFuncId);
Index:= Pos('?',FFuncId);
if Index>0 then begin
TmpStr:= FFuncId;
Delete(FFuncId,index,Length(FFuncId));
Delete(TmpStr,1,index);
FParamValue:= TmpStr;
end
else
FParamValue:= '';
end;
end;
end;
function TFunctionStrParser.GetIsPlugin: Boolean;
begin
Result:= FFuncKey='PLUGIN';
end;
function TFunctionStrParser.GetIsTable: Boolean;
begin
Result:= FFuncKey='TABLE';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -