Delphi

Data ETL: Adding Custom LiveBindings To Your Apps

In the recent Data ETL focused TCoffeeAndCode episode there was some excellent discussion around the use of FireDAC to extract and manipulate data in various ways. The replay, in case you missed it, the replay video is linked below. Data ETL done the easy way – thanks to a tweet! We also – among many other things – talked about the benefits of LiveBindings. Literally ten minutes before we were due to start the webinar I came across a Tweet from newly-minted Embarcadero MVP David Cornelius where he mentioned that he had been experimenting with RAD Studio’s LiveBindings. I’ve been using Delphi’s LiveBindings more and more lately and think they’re more useful than many people give them credit. I’ve started an open-source library of CustomFormat methods on GitHub: https://t.co/yUds77hYIQ. I’d be interested to hear what people think. — David Cornelius (@delphidave) May 26, 2021 Well, that was perfectly-timed! David goes on in his blog post to describe a little about LiveBindings and his personal journey where he went, not unlike myself, from a feeling of lukewarm complacency toward them to an appreciation of the finer points of their use. LiveBindings are more powerful than they appear When I first heard of LiveBindings they seemed, to me, to be some kind of variation on the old datasource / datafield kind of relationship found in older versions of Delphi and the venerable Visual Basic. They looked like we should link the controls on the screen to a field (or fields) of a database table, albeit with a prettier graphical relationship editor. Once you start to scratch the surface of LiveBindings, if you’re anything like me, LiveBindings will start to gradually reveal themselves and you’ll find there is a LOT more power going on than simple point-this-field to this-control kind of relationships. Linking controls to classes and internal code data structures is one of those Programmer Super Power RAD Studio features I keep telling people is the reason why a fairly lazy coder like myself can actually be scarily productive. It’s not me, it’s RAD Studio and, in my case at least, Delphi. Data ETL with LiveBinding Expressions There are some other great articles around which describe LiveBindings from initial beginnings through to more advanced topics: But David Cornelius embraced the idea of LiveBindings and went a little further! How to extend LiveBindings with custom binding expressions David has produced a set of code, available on GitHub, which adds some custom expressions in the LiveBindings editor. The repository contains a set of units that can be included in your apps which then enhance the available LiveBinding custom expressions to include things like automatically calculating the years since the date contained in the database field (or record or class – it’s a LiveBinding, don’t forget). LiveBindings Custom Expression Here’s a few lines of example code from David’s repo: function MakeMinutesSinceMethod: IInvokable; begin Result := MakeInvokable(function(Args: TArray): IValue var InputDate: TDateTime; RoundDigits: Integer; MinutesSince: Double; begin CheckArgs(Args, InputDate, RoundDigits); MinutesSince := RoundTo(TTimeSpan.Subtract(Now, InputDate).TotalMinutes, RoundDigits); Result := TValueWrapper.Create(MinutesSince); end); end; function MakeMinutesSinceMethod: IInvokable; begin   Result := MakeInvokable(function(Args: TArray<IValue>): IValue       var         InputDate: TDateTime;         RoundDigits: Integer;         MinutesSince: Double;       begin         CheckArgs(Args, InputDate, RoundDigits);         MinutesSince := RoundTo(TTimeSpan.Subtract(Now, InputDate).TotalMinutes, RoundDigits);           Result := TValueWrapper.Create(MinutesSince);       end); end; That code means you can add a LiveBinding custom expression MinutesSince(MyDateTimeDBField, 2) to output the […]

Read More

Developer Stories: Pietro Ruvolo Shares His D.Fence Application

Pietro Ruvolo has been programming ever since 1988. He has a showcase entry (D.Fence) at the Delphi 26th Showcase Challenge and we talked to him about his programming journey over the years. Check out his website on D.Fence. When did you start using RAD Studio Delphi and how long have you been using it? I started programming in 1988 at the time of MS Dos, dBase III, and Clipper. Then at the release of Delphi, I switched to OOP programming and since then I have followed the evolution of the product. I started converting my old programs in Delphi for 26 years. I created my first software company in Rome, Italy dedicated to the development under the “new” MS Windows. What was it like building software before you had RAD Studio Delphi? It was the time of MS Dos and procedural programming, where programs generated sources of infinite size and where debugging, with languages like Clipper, Fortran, basic was a real nightmare. I started to learn OOP and Delphi RAD allowed me to create more and more lean and easily maintainable programs, as well as to create classes of objects reusable between projects, gaining a lot in development time. With the advent of Firemonkey there was a further leap in quality, introducing the possibility to maintain the same code for different platforms (macOS, Windows, Android, iOS and Linux) expanding my market to a new type of user. How did RAD Studio Delphi help you create your showcase application? In 2015, I used Delphi to create a distributed risk management platform for a client (using REST Technology). Two years later I moved to MALTA to continue the development and maintenance of the platform of that client. This activity lasted until December 2020 when I opened my own software company in Malta and started again to create products in RAD Studio. The first product we decided to develop was dictated by the pandemic situation in which we found ourselves and it is D-Fence, a product for social distancing and contact tracing. Being composed of a software platform and having to interact with the BLE sectors mounted on wearables, and with APP of different operating systems, Delphi and Firemonkey were the best and most effective solution for the realization of the entire software suite. What made RAD Studio Delphi stand out from other options? As mentioned before, the use of Firemonkey made possible the realization of this project in a short time and without the need to have different teams of programmers for each operating system, ensuring cross-platform development. The server platform uses REST technology, the apps use native compiler for IOS and ANDROID and access to the wristbands is via Bluetooth Low Energy. Finally, it is very important to maintain a single version of the source code so that any changes made becomes automatically available on all platforms. What made you happiest about working with RAD Studio Delphi? Surely the ease of reusing already used source codes is one of the most pleasant aspects of Delphi together with a powerful debugging engine that helps to develop important software in a limited time. I am also happy to have been able to reopen in Malta my original activity as a software developer. What have you been able to achieve through using RAD Studio […]

Read More

Have You Made Your Application Server HTTP/2 Ready?

In early 2015, HTTP/2 was introduced as the new standard by IESG. This standard makes your application faster, simpler, and more robust. In this article we take you through the differences between HTTP/1 and HTTP/2, the benefits and some key terms. Why should I use HTTP/2? Converting from using HTTP/1 to HTTP/2 brings the following benefits: HTTP/2 reduces latency by enabling full request and response multiplexing. Efficient compression of HTTP header fields. Support for request prioritization. Multiple concurrent exchanges on the same connections. An unsolicited push of representations from servers to clients. What is SPDY? SPDY was an experimental protocol, developed at Google and announced in mid-2009. The primary goal with SPDY was to try to reduce the load latency of web pages by addressing some of the well-known performance limitations of HTTP/1.1. Since 2012 the new experimental protocol was supported by the Chrome, Firefox, and Opera web browsers. A rapidly growing number of sites, both large and small, were deploying SPDY within their infrastructure. In effect, SPDY was on track to become a de facto standard through growing industry adoption. After a lot of discussion within the working group, the SPDY specification was adopted as a starting point for the new HTTP/2 protocol. If you want to read more about this click here for the full story  What are the key differences between HTTP/1.x and HTTP/2? The most significant changes between HTTP/1.x and HTTP/2 are : There is a new binary framing layer which dictates how the HTTP messages are encapsulated and transferred between the client and server. The HTTP semantics, such as verbs, methods, and headers, are unaffected, but the way they are encoded while in transit is different. Unlike the newline delimited plaintext HTTP/1.x protocol, all HTTP/2 communication is split into smaller messages and frames, each of which is encoded in binary format. All communication is performed over a single TCP connection. For the official “RFC” document describing HTTP/2 you can go to the following link: https://datatracker.ietf.org/doc/html/rfc7540#section-4 What are the performance differences between HTTP/1.x and HTTP/2? The really great thing about Delphi is we can already use the latest technology so that server applications with the HTTP/2 protocol can be implemented by developers. One of the Embarcadero Technology Partners, namely ESEGECE, has created a HTTP server component which implements the HTTP/2 protocol. Let’s compare the performance difference between the HTTP/1 and HTTP/2 using ESEGECE’s components. You can download a trial version here: https://www.esegece.com/websockets/download Here’s a video taking you through the demo: As you can see HTTP/2 has a speed of at least 50% more than HTTP/1.x RAD Studio Delphi gets your applications from idea to reality with maximum speed and efficiency. Why not try it for yourself today?

Read More

Example WebSockets Server And Client Chat Application

WebSockets are gaining more and more strength with the implementation in most browsers, including for mobile devices. This article introduces briefly, the concept of WebSockets, and creates a chat app using a websockets component for Delphi, by Delphi component provider Esegece. What are Websockets? The WebSockets protocol allows the creation of a client-server communication channel with bidirectional transmission where both sides (client and server) can transmit data simultaneously. WebSockets came to fill the shortcomings of the HTTP protocol for this purpose, which by the way, is unidirectional (transmission occurs only from one end to the other). The most common uses for WebSockets are, among other things: home brokers (where quotes are updated all the time), social network feeds, chat apps, collaborative tools, and even multi-player games What are the differences between HTTP and WebSockets? WebSockets are a great choice if there is a need for a connection to remain open for a long time for constant data exchange. In summary, the benefits over HTTP are Low Latency, Persistent Connection and Full-Duplex (bidirectional transition). A WebSockets Delphi component To create our chat app we will use the WebSockets component. Here we are using the eSeGeCe Delphi WebSocket component. You can check its benefits here. Also, you can check some implementations here and the documentation here. To start the work, you need to download the eSeGeCe Delphi WebSocket Components and the Indy Components. These two and a video of how to install them, you can check here. How to create a WebSockets Delphi client for a chat application Let’s start with the client-side. After installing the components, get a TsgcWebSocketClient component along with two TEdit a TMemo, and a TButton. The two TEdit controls will be used as name and message fields. The TMemo control will be the field that displays all messages. In the TsgcWebSocketClient properties, you need to change just the host and port. Add ‘localhost’ to the host and 5416 to the port. Looking at the code, there are two main parts. The connection and the messages. For connection and disconnection, you can add the following in the OnShow and OnClose methods of the form: procedure TFrmClient.FormShow(Sender: TObject); begin sgcWsClient.Active := True; end; procedure TFrmClient.FormClose(Sender: TObject; var Action: TCloseAction); begin sgcWsClient.Active := False; end; procedure TFrmClient.FormShow(Sender: TObject); begin   sgcWsClient.Active := True; end;   procedure TFrmClient.FormClose(Sender: TObject; var Action: TCloseAction); begin   sgcWsClient.Active := False; end; To receive a message is very simple. The OnMessage event of the TsgcWebSocketClient, already comes with the text sended by the server. You just need to get it and put on the TMemo component: procedure TFrmClient.sgcWsClientMessage(Connection: TsgcWSConnection; const Text: string); begin mmLog.Lines.Add(Text); end; procedure TFrmClient.sgcWsClientMessage(Connection: TsgcWSConnection;   const Text: string); begin   mmLog.Lines.Add(Text); end; Sending a message over a WebSockets connection using Delphi To send a message is also, very simple. You can use the OnClick event of the button: sgcWsClient.WriteData(edtName.Text + ‘: ‘ + edtMessage.Text); sgcWsClient.WriteData(edtName.Text + ‘: ‘ + edtMessage.Text); Creating a WebSocket Delphi Server for a Chat Application For this WebSocket Delphi Server Example, we will need the TsgcWebSocketHTTPServer component, and at least, a TMemo. In the sgcWebSocketHTTPServer properties Options, mark the HTML files. Also in Fallback/ServerSentEvents/Retry, set to 3 and set the port to 5416. Here we also have two main parts, when looking in the code: the connection, and the messages. You […]

Read More

Developer Stories: Georgi Todorov Gerasimov Talks Us Through His Sophisticated File Encryption App

Georgi Todorov Gerasimov has been using Delphi for many years. He has a showcase entry submission (FPS-SE) at the Delphi 26th Showcase Challenge and we got to talk to him about his great Delphi experiences throughout the years. You can purchase and download his application over at File Protect System website. When did you start using RAD Studio Delphi and have long have you been using it? We have been using RAD Studio/Delphi for years. The moment Delphi XE entered the market, we started to work on a project for post quantum encryption of sensitive to critical information, which we named File Protect System – FPS. What was it like building software before you had RAD Studio/Delphi? Before the advent of RAD Studio/Delphi we faced many problems in the development of specialized REST servers. Another serious problem that our team has faced in that time was testing the end-user applications, which were utilizing web based interface. How did RAD Studio Delphi help you create your showcase application? With the advent of RAD Studio XE7/Delphi all R&D processes passed to a qualitatively new level. The technical abilities that provided us technologies like Datasnap, Tethering, Indy, FastReport, FireMonkey, etc. allowed us to speed up development processes and to raise the efficiency and reliability of our software products. At the moment we are reorganizing our working processes in order to start working with RAD Studio 10.4 Sydney. What made RAD Studio Delphi stand out from other options? One of the main advantages of RAD/Studio Delphi is the presence of unique instruments that allow quick implementation of attractive by its nature interface solutions. Another significant advantage is the high quality of the visual components and the exceptionally good compilers. What made you happiest about working with RAD Studio Delphi? It is a pleasure to work with RAD Studio/Delphi because this is an IDE that allows the developers to get a view of the project as a whole. When we get the result, every member of our team is satisfied, and that gives us the ambition to continue our development and grow. What have you been able to achieve through using RAD Studio Delphi to create your showcase application? RAD Studio XE7/Delphi helped us to finalize successfully the first versions of the File Protect System – FPS. We were able to create application that provides the end user with the ability to protect its own files and electronic messages. Something more, the application we developed allows the user to transform every single electronic device (including mobile ones) into high performance encryption system What are some future plans for your showcase application? File Protect System will continue to evolve in the future. At the moment our team is working on the integration of server-based solutions for post quantum protection of corporate structures that are using DB systems like Oracle, MS, MySQL, and DB2. Along with this we are working on our mobile solutions and DLP (Data Loss Prevention) modules that expand the functionality of File Protect System (FPS). Something more, we are continuously evolving our integrated mail client BS Mail, which is becoming popular as a stand-alone application for critical information transfer. Thank you for taking the time to talk to us Georgi. Take a look at his entry showcase below and see what kind of […]

Read More

Powerful Advanced Scientific Computing – it’s easy!

What is Scientific Computing? According to Golub and Ortega in 1992, Scientific Computing is the collection of tools, techniques, and theories required to solve mathematical models of problems in Science and Engineering. A majority of these tools, techniques, and theories are originally developed in Mathematics, which are many of them having their genesis long before the advent of electronic computers. Computation becomes crucially important in situations such as: The problem at hand cannot be solved by traditional experimental or theoretical means, such as attempting to predict climate change Experimentation may be dangerous, e.g., characterization of toxic materials The problem would be too expensive or time-consuming to try to solve by other avenues, e.g. determination of the structure of proteins Nowadays, Scientific Computing is acknowledged as the “third pillar of science”, standing right next to theoretical analysis and experiments for scientific discovery. Why use Python for Scientific Computing? Here are the 6 reasons to use Python for Scientific Computing: Python has built-in support for Scientific Computing. Python is a highly extensible language. Python has very good input/output (I/O) options. Python has strong support for task automation. Python has bridges to MATLAB or Octave. Python can use a web front end. Delphi adds Powerful GUI Features and Functionalities to Python In this tutorial, we’ll build Windows Apps with extensive Scientific Computing capabilities by integrating Python’s Scientific Computing libraries with Embarcadero’s Delphi, using Python4Delphi (P4D). P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python Web Scraping applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials. We’re going to cover the following… How to use NumPy, SciPy, SymPy, scikit-learn, Theano, and Cirq Python libraries to perform Scientific Computing tasks All of them would be integrated with Python4Delphi to create Windows Apps with Scientific Computing capabilities. Prerequisites Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth. Time to get Started! First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link. Open Demo01.dproj. 1. How do I enable NumPy inside Python4Delphi in Windows? NumPy is a popular Python library used for scientific computing applications. NumPy is an acronym for “Numerical Python”. NumPy is the fundamental package for array computing with Python. NumPy’s operations are divided into three main categories: Fourier Transform and Shape Manipulation, Mathematical and Logical Operations, and Linear Algebra and Random Number Generation. To make it as fast as possible, NumPy is written in C and Python. Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data. Arbitrary data-types can be defined. This allows NumPy to seamlessly and speedily integrate with […]

Read More

Photomate Automation Supercharges Your Inventory Workflow

The workflow behind the selling and buying of vehicle parts is convoluted and tricky to navigate. It typically involves lots of photos of metallic objects so that the buyer – or seller – can more easily identify whether or not the part is the right one. Photomate works in conjunction with the Car-Part.com website and their Checkmate inventory management system to ease the process of taking those identifying photos and uploading them to the correct places to create online listings. The app greatly simplifies that entire workflow process. RAD Studio Delphi powers Photomate Photomate is written using RAD Studio Delphi where it uses the power of the Firemonkey FMX cross-platform framework to integrate with the mobile device’s built-in camera and sensors to perform its magic. What does the Photomate developer say about their app? According the developer, “The photos you take in Photomate are sent to the Checkmate inventory management system, and then uploaded to online listings. When you include photos in your online listings, you help your customers feel more comfortable browsing and purchasing parts from you. With Photomate, you have the opportunity to select which parts of your inventory need photos to ensure that all of your online listings have images.” Unique features listed for the app include Select specific parts in your inventory that need photos, and assign these parts to Photomate Assign specific parts to specific employees, creating individual “to do” lists Communicate between managers, employees, and coworkers with comment fields Take photos or use images already in your device’s photo gallery Select the best image to serve as the part’s thumbnail for online listings Set any image to be “private” (sent to Checkmate, but not posted online) Send images to Checkmate to be included in inventory details and uploaded to online listings on Car-Part.com, Car-Part Pro, Trading Partners, eBay, mobile searches, and individual recycler websites Google Play Photomate Screenshot Gallery

Read More

Photomate Automation Supercharges Your Inventory Worflow

The workflow behind the selling and buying of vehicle parts is convoluted and tricky to navigate. It typically involves lots of photos of metallic objects so that the buyer – or seller – can more easily identify whether or not the part is the right one. Photomate works in conjunction with the Car-Part.com website and their Checkmate inventory management system to ease the process of taking those identifying photos and uploading them to the correct places to create online listings. The app greatly simplifies that entire workflow process. RAD Studio Delphi powers Photomate Photomate is written using RAD Studio Delphi where it uses the power of the Firemonkey FMX cross-platform framework to integrate with the mobile device’s built-in camera and sensors to perform its magic. What does the Photomate developer say about their app? According the developer, “The photos you take in Photomate are sent to the Checkmate inventory management system, and then uploaded to online listings. When you include photos in your online listings, you help your customers feel more comfortable browsing and purchasing parts from you. With Photomate, you have the opportunity to select which parts of your inventory need photos to ensure that all of your online listings have images.” Unique features listed for the app include Select specific parts in your inventory that need photos, and assign these parts to Photomate Assign specific parts to specific employees, creating individual “to do” lists Communicate between managers, employees, and coworkers with comment fields Take photos or use images already in your device’s photo gallery Select the best image to serve as the part’s thumbnail for online listings Set any image to be “private” (sent to Checkmate, but not posted online) Send images to Checkmate to be included in inventory details and uploaded to online listings on Car-Part.com, Car-Part Pro, Trading Partners, eBay, mobile searches, and individual recycler websites Google Play Photomate Screenshot Gallery

Read More

This AI API Makes Your App A “Fast Style” Artistic Genius

The AI API “Fast Style” is a form of graphical style transfer which uses a neural network to combine the artistic styles of one image with another to render a new unique image. You can think if it like taking a photograph and combining it with a Manet painting to produce a unique photo after the style of Manet. To make art, we will use the help of DeepAi.org a platform that you can use to make a lot of artificial intelligence projects. One of them is “fast style transfer”. We will connect with their API using Delphi. REST and Delphi makes the API easy to use Delphi has a tool called REST Debugger that makes it easy to connect with a REST API. After using it and successfully make the connection, you can copy the components into your Delphi application. Let’s dive into the DeepAi API and see how to build a desktop application to make art. How to connect with DeepAi API? DeepAi has good documentation around their API, which you can check here. First of all, you will need to make an account on DeepAi.org and take your API key. You are gonna need it later. From the Fast Style documentation, you can see that you will need to send three parameters to the API endpoint. Two links or files with images (where one is the image to render and the other, the style you want to apply), and your API key. How do I use Delphi to Connect with DeepAi API REST endpoints ? First of all, let’s use the REST Debugger found in RAD Studio Delphi. The REST Debugger is a visual tool to connect with any API, make a call, and get a response. In your Delphi IDE,. To use it, in the IDE menu, go to Tools > REST Debugger. Change the Method to POST and insert the API Endpoint ( https://api.deepai.org/api/fast-style ) in the URL field. Then, go to the Parameters Tab. To add the image links, click on the Add button. If you want to send a link directly from a web link, on Kind, select BODY. If you want to send a file of your hard drive, select FILE instead. In the name, write ‘content’ and put the link of the image in the value. For your style image, just change the name to ‘style’. Lastly, click on add again e now, select HEADER on Kind and, on name, write api-key and on value, put your API key value. Sending a REST request to the DeepAI API Now, click on Send Request and after some time, you should receive a 200 response and, on Tabular Data Tab, you will see the output_url, with the link of the image that the artificial intelligence created: Congrats, now you can send and get data from an Artificial Intelligence API and use it as you want. How do I build a Windows desktop application to send and get images from the DeepAi API? The application we are gonna build here will get the images from your computer, show and send them to the deepAi API. Also, it will show the image that the API returns and save it into the application folder. So, with a form already created, paste the components copied from the […]

Read More

Powered by Delphi: The Ultimate App For Tinnitus Sufferers

It’s often overlooked that writing a Delphi application can make a real difference to people’s lives in a very meaningful and profound way. Tinnitus Help by US Developer Mango Chutney may just be one of those game-changing Delphi mobile apps. According to the US Center For Disease control and the American Tinnitus Association, around 15% of all Americans, around fifty MILLION people, suffer from some level of tinnitus. Those percentages are dwarfed by the numbers of people worldwide who also suffer what can be a debilitating condition. It’s a subject brought to light recently by the hit Amazon movie “The Sound Of Metal” which documents the journey into hearing loss of a rock drummer – played by actor Riz Ahmed. Your Delphi programs could make a positive difference to people’s lives Given the numbers of people who live every day with the difficulties brought about by tinnitus German developer IND (Ingenieurbüro für Nachrichten und Datentechnik) are well-placed to really touch user’s lives in a positive and possibly transformative way. ‘Tinnitus Help’ is eight programs in one. As stated by the developer, “The ultimate application for tinnitus sufferers. Only naturally produced sounds of musical instruments and sounds of Mother Nature – no synthesizers! Developed by an expert software engineer in the field of frequency analysis and a leading music psychologist, music therapist and hearing therapist with more than 20 years’ experience in the treatment of tinnitus sufferers. Used very successfully in the treatment of tinnitus.” Google Play Tinnitus Help Screenshot Gallery Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

Read More