[fpc-devel] Does FreePascal support named parameters?

Anthony Walter sysrpl at gmail.com
Thu Apr 4 07:56:21 CEST 2013


Frank,


The Javascript in Delphi code depends on active script engine. and
component of Windows. So no, the example I provided does not run on Linux.

But, and dynamic methods and properties (as well as named optional
arguments) are supported in Free Pascal, as long as you use a Variant (or
OleVariant) type which references an IDispatch instance. You can your your
own implementation of IDispatch on any platform, and the example I provided
does that. See TScriptlet which converts a TComponent derived instance into
an IDispatch and is thus compatible with dynamic and properties methods
when addressed via a Variant.

Example: MyVariant := TYourDispatchImplemention.Create as IDispatch; { and
later } MyVariant.SomeMethod(12.5, 'ParamOne' := EditControl.Text); { Calls
TYourDispatchImplemention GetIDsOfNames() passing 'SomeMethod', then
Invoke() with the dispid from the prior method and arguments packed into a
variant array }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130404/ba53da4e/attachment.html>


More information about the fpc-devel mailing list