Hello,
I want to handle these kind ot like this:
type
TInputQueryValidationProc = reference to procedure (ValueIndex: Integer; const Value: string; var IsValid: Boolean);
function SelectQuery(const ACaption: string; const APrompt: string; AValues: TStrings; var AValue: string;
AAllowCustomValues: Boolean = False; AValidationProc: TInputQueryValidationProc = nil): Boolean;
I have tried with this:
procedure TatInputDialogsLibrary.__SelectQuery(AMachine: TatVirtualMachine);
var
Param2: string;
AResult: variant;
AValue: string;
begin
with AMachine do
begin
AValue:= GetInputArgAsString(3);
case InputArgCount of
3: AResult := SelectQuery(VarToStr(GetInputArg(0)),VarToStr(GetInputArg(1)), Tstrings(VarToObject(GetInputArg(2))),AValue );
4: AResult :=SelectQuery(VarToStr(GetInputArg(0)),VarToStr(GetInputArg(1)), Tstrings(VarToObject(GetInputArg(2))),AValue,GetInputArg(3) );
5: AResult := SelectQuery(VarToStr(GetInputArg(0)),VarToStr(GetInputArg(1)), Tstrings(VarToObject(GetInputArg(2))),AValue,GetInputArg(3),TInputQueryValidationProc(VarToObject(GetInputArg(4))) );
end;
ReturnOutputArg(AResult);
SetInputArg(3,AValue);
end;
end;
procedure TatInputDialogsLibrary.Init;
begin
With Scripter.DefineClass(ClassType) do
begin
DefineMethod('SelectQuery',6,tkVariant,nil,__SelectQuery,false,2,'const ACaption: string; const APrompt: string; AValues: TStrings; var AValue: string; AAllowCustomValues: Boolean = False; AValidationProc: TInputQueryValidationProc = nil').SetVarArgs([3,4]);
end;
end;
But of course this doesn't compile:
[dcc32 Erreur] ap_InputDialogs.pas(83): E2010 Types incompatibles : 'TInputQueryValidationProc' et 'TObject'
I think that I have read somewhere that it is not possible to declare procedure as argument ?