AArhin / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Function Parameters #301

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
good day
I am writing a function call from the script.
DWS Function:

function Validate (var Msg: string): TModalResult;
begin
   if edtName.Text ='' then
   begin
     Msg: = 'Enter a name, please';
     Result: = mrNone;
   end
   else
     Result: = mrOk;
end;

function call from Delphi is:
var
   mInfo: IInfo;
begin
...
  mInfo: = aExec.Info.Func [fOnValidate];
  if mInfo <> nil then
  begin
    mInfo.Parameter ['Msg']. Value: = mMsg;
    mResult: = mInfo.Call;
    if mResult <> nil then
    begin
      aMsg: = mInfo.Parameter ['Msg']. ValueAsString;
      Result: = TModalResult (mResult.ValueAsInteger);
    end;
  end; 
...
end;

The code is works. But what if the user to declare a function like this:
function Validate (var aMessage: string): TModalResult;
In terms of syntax, no error, but the setting will not be received.
Is it possible to access the parameter by its index?

Original issue reported on code.google.com by sergpa...@gmail.com on 11 Oct 2012 at 4:40

GoogleCodeExporter commented 9 years ago
For read access, you've got a set of ParamAsXxx properties which take the 
parameter index.

You can also look at the TFuncSymbol.Params property, which can be used to find 
out the name of parameters (if you start from an IInfo, you can use the TypeSym 
property to obtain the underlying symbol).

Original comment by zar...@gmail.com on 17 Oct 2012 at 3:27