adding FileExists function to RAP
Is this the correct way to add the FileExists to the code toolbox? I can't
get it to compile so I think I'm missing something. Is there a better way
to see if a file exists before loading it into an image?
unit rapEx;
interface
uses
Forms, raFunc, ppRTTI,sysUtils;
type
TmyFilenameFunction = class(TraSystemFunction)
public
class function Category: String; override;
end;
TmyApplicationFilenameFunction = class (TmyFilenameFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
class function HasParams: Boolean; override;
end;
implementation
class function TmyFilenameFunction.Category: String;
begin
result := 'FileUtils';
end;
procedure TmyApplicationFilenameFunction.ExecuteFunction(aParams:
TraParamList);
var
lsResult: Boolean;
filePath : String;
begin
getParamValue(0,filePath);
lsResult := FileExists(filePath);
SetParamValue(1, lsResult);
end;
class function TmyApplicationFilenameFunction.GetSignature: String;
begin
result := 'function FileExists(aString : string) : boolean;';
end;
class function TmyApplicationFilenameFunction.HasParams: Boolean;
begin
result := False;
end;
Initialization
raRegisterFunction('FileExists', TmyApplicationFilenameFunction);
end.
Thanks,
Karen
get it to compile so I think I'm missing something. Is there a better way
to see if a file exists before loading it into an image?
unit rapEx;
interface
uses
Forms, raFunc, ppRTTI,sysUtils;
type
TmyFilenameFunction = class(TraSystemFunction)
public
class function Category: String; override;
end;
TmyApplicationFilenameFunction = class (TmyFilenameFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
class function HasParams: Boolean; override;
end;
implementation
class function TmyFilenameFunction.Category: String;
begin
result := 'FileUtils';
end;
procedure TmyApplicationFilenameFunction.ExecuteFunction(aParams:
TraParamList);
var
lsResult: Boolean;
filePath : String;
begin
getParamValue(0,filePath);
lsResult := FileExists(filePath);
SetParamValue(1, lsResult);
end;
class function TmyApplicationFilenameFunction.GetSignature: String;
begin
result := 'function FileExists(aString : string) : boolean;';
end;
class function TmyApplicationFilenameFunction.HasParams: Boolean;
begin
result := False;
end;
Initialization
raRegisterFunction('FileExists', TmyApplicationFilenameFunction);
end.
Thanks,
Karen
This discussion has been closed.
Comments
it compiles fine here.
Method 'HasParams' should return 'True'!
regards,
Chris Ueberall;