Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Automate Coding Tasks With Duck Typing In Delphi XE8 Firemonkey On Android And IOS

Delphi XE8 Firemonkey Duck Typing On Android And IOSDeveloper Jason S. created a duck typing library for Delphi Firemonkey called Duck Duck Delphi. What duck typing appears to do is automatically test if an object has a property or method and if it does then it can execute code based on that property or method. You should be able to use this library in Delphi XE8 Firemonkey on Android, IOS, OSX and Windows to save you coding time. In practice this allows you to greatly reduce the code that you have to write to accomplish certain tasks. It’s like ‘in code’ automation. For example, you can write a few lines of code to clear all of the edit fields on a form. Here is an example where it tests to see if all of the objects have a SelectAll procedure if and if they do then it uses an anonymous procedure to clear those controls:

The alternative to this code would be to manually clear each field one line at a time or to use a for loop to loop through all of the components on the form, test to see if they are of the correct type (like a TEdit), and then run the procedures. Another example from the demo shows how you can set all the controls on a form to Visible False with a single line of code ( Self.Duck.all.has(‘Visible’).setTo(false); ). The library is free with source code and should also work in Appmethod.

Head over and download the full source code to the Duck Duck Delphi library and try it out.

Mirror: Download the Duck Duck Delphi library directly.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

AndroidC++BuilderDelphiFiremonkeyIOSLiveBindingsOSXWindows

Top Tips And Tricks To Speed Up Development With Delphi 10.4 FireMonkey On Android and IOS

Sign up for our Newsletter and
stay informed

Leave a Reply