Type "reference to procedure" as argument

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 ?

And I want to use it at run time (Script source):

var
  AUserInput: string;
  AValues: TStringList;
  AAllowCustomValues:Boolean;
  AValeur:string;
  Resultat:boolean;
  
procedure  MyValidator(AValueIndex: Integer; AValue: string; var AIsValid: Boolean);  
begin
  AIsvalid:= AValue<>'No month';
end;
  
begin
        AValues := TStringList.Create;
        try
    AValues.Add('January');
    AValues.Add('February');
    AValues.Add('March');
    AValues.Add('April');
    AValues.Add('May');
    AValues.Add('June');
    AValues.Add('July');
    AValues.Add('August');
    AValues.Add('September');
    AValues.Add('October');
    AValues.Add('November');
    AValues.Add('December');
    AValues.Add('No month');
    SelectQuery('Choose Month', 'Month:', AValues, AUserInput,'MyValidator');
          if Resultat then
             showmessage('User has selected '+quotedstr(AUserInput))
          else   showmessage('User has clicked on  "Cancel"');
        finally
              AValues.Free;

        end;
end;

Correct, anonymous methods, or even procedure pointers, are not supported in TMS Scripter.