Delphi

Learn How To Use Connection Pooling With A Multi-threaded Environment In Delphi

This sample implements a multithreaded application, where each thread uses the IFDPhysConnection interface to establish a connection. The multiple connection establishments may lead to performance degradation across the whole system. To avoid this, you can enable the Pooled property to use the connection pooling. Location You can find the Pooling sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesPhys LayerIFDPhysConnectionPooling Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. How to Use the Sample Navigate to the location given above and open IFDPhys_Pooling.dproj. Press F9 or choose Run > Run. Interact with the sample: Select an option from the Use Connection Definition combo box. Click the Run button and see the execution time. Select the Run Pooled check box, click the Run button and see the execution time. Compare both execution times. Files File in Delphi Contains IFDPhys_Pooling.dprojIFDPhys_Pooling.dpr The project itself. fPooling.pasfPooling.fmx The main form. Implementation When you run the application, you can interact with the sample using the following objects: A TComboBox object labeled as Use Connection Definition.Click the Use Connection Definition combo box and select an option in order to define a connection to a database. The menu shows all the persistent connections defined on the file C:UsersPublicDocumentsEmbarcaderoStudioFireDACFDConnectionDefs.ini. Once you select a connection definition, the sample enables the Run button and the Run Pooled check box. A TButton object labeled as Run.If you click the Run button, the sample launches 10 threads. Each thread uses the CreateConnection method of IFDPhysManager to create a connection to the database. Moreover, each thread uses the CreateCommand method of IFDPhysConnection to create a command for each connection. Finally, each thread uses the Prepare method of IFDPhysCommand to execute 50 SQL queries. The executed SQL query is the following SELECT command: ‘select count(*) from {id Region}’. Therefore, in this case, each thread creates and uses a dedicated connection object working with the database. A TCheckBox object labeled as Run Pooled.If you select this check box, the Pooled property of the connection setting is set to True. The database connection pooling is a method used to keep database connections open so they can be reused by others. Therefore, if you select the option, the threads can reuse the current opened connection.Note: The connection pooling can be enabled only for a persistent or private connection definition. A TMemo object.The sample uses the memo object to display the type of connection. If you select the Pooled property, the memo displays the following message: ‘Run pooled…’. On the other hand, if you uncheck the Pooled property, the memo displays the following message: ‘Run non pooled…’. Through the link below you can visit the original post about this sample: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.IFDPhysConnection.Pooling_Sample

Read More

Quickly Log Python Script Output To The Delphi Debug Log In Your Windows Apps

Sometimes developers need to log the output messages in Delphi for debugging purposes. You might aware this can be achieved by the windows API OutputDebugStringA . How about direct your python output messages to the Delphi Events Log Window? Yes, Python4Delphi has a flexible component PythonInputOutput to redirect your python output to the Delphi Events Log window with less code. You can also use Python4Delphi with C++Builder. Python4Delphi Demo23 Sample App shows how to create a Python script in Delphi Application which demonstrates creating thread and output the result in the Delphi Event log window. You can find the Demo23 source on GitHub. Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi. Components used in Python4Delphi Demo23 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. TPythonInputOutput: Inherited from TPythonInputOutput (which works as a console for python outputs) Using this component event you can direct your Python Output to the Delphi Event log window. You can find the Python4Delphi Demo23 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo23.dproj. Open this project in RAD Studio 10.4.1 and run the application. Implementation Details: PythonEngine1 provides the connection to Python or rather the Python API. This project uses Python3.9 which can be seen in TPythonEngine DllName property. It uses a Python Script file threading_test.py where the below list of modules was used. threading: This module constructs higher-level threading interfaces on top of the lower level _thread module.  collections: This module implements specialized container datatypes providing alternatives to Python’s general-purpose built-in containers, dict, list, set, and tuple. In this sample, deque is used. time: This module provides various time-related functions. threading_test.py contains, ProducerThread, ConsumerThread, BoundedQueue class within the function _test. Memo1, used for providing the Python Script to execute. On Clicking Execute Button the below code executes the python script. procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; procedure TForm1.Button1Click(Sender: TObject); begin   PythonEngine1.ExecStrings( Memo1.Lines ); end; The script below is executed which will opens a window console, create threads put in a queue and execute one after other. import threading_test import sys # the following is needed to use the newly allocated console! sys.stdout = sys.stderr= open(‘CONOUT$’, ‘wt’) try: count = int(sys.argv[1]) except: count = 3 for i in range(count): print (“**** Pass”, i) threading_test._test() print (“**** Done.”) import threading_test   import sys # the following is needed to use the newly allocated console! sys.stdout = sys.stderr= open(‘CONOUT$’, ‘wt’)   try:   count = int(sys.argv[1]) except:   count = 3   for i in range(count):   print (“**** Pass”, i)   threading_test._test() print (“**** Done.”) PythonInputOutput1 provides a conduit for routing input and output between the Graphical User Interface (GUI) and the currentlyexecuting Python script. The OnSendData event helps to send the python output data to the Delphi Event log window using the below code. procedure TForm1.PythonInputOutput1SendData(Sender: TObject; const Data: AnsiString); begin {$IFDEF MSWINDOWS} OutputDebugStringA( PAnsiChar(Data) ); {$ENDIF} {$IFDEF LINUX} WriteLn( ErrOutput, Data ); {$ENDIF} end; procedure TForm1.PythonInputOutput1SendData(Sender: TObject;   const Data: AnsiString); begin {$IFDEF MSWINDOWS}   OutputDebugStringA( PAnsiChar(Data) ); {$ENDIF} {$IFDEF LINUX}   WriteLn( ErrOutput, Data ); {$ENDIF} end; Python4Delphi Demo23 You can customize your Events Debug Output messages background and foreground colors easily to differentiate your output messages with Delphi IDE. Right-click in the Events Tab -> Properties->Event Log->Colors -> Output Debug String-> Select Foreground and Background.

Read More

Powerful Petroleum And Mining Software For Surface And Subsurface Data Visualization Is Built In Delphi

Over the past three decades, Golden, Colorado-based RockWare, Inc. has established itself as a leader in the highly specialized geological mapping and modeling sector. Its flagship product, RockWorks, creates 3-dimensional geological models of the earth’s subsurface for customers in environmental (toxic cleanup, contamination audits), hydrogeology (surface and sub-surface water), and industrial minerals (e.g. gypsum, sand gravel) segments and it is built in Delphi. One of the key benefits of Delphi according to Jim Reed, Director R&D is that “It allows us to put in millions of lines of code and do it in an efficient way without maxing out memory. Because of that, we can have a monster program that does 50 zillion different things, but can be downloaded comfortably in a reasonable amount of time. Given that 65% of our business is outside of North America, executable files have to be small enough so that someone in Sudan can download data over a lousy connection.” He attributes this capability to the overlay features in Delphi, which allow for exceptional memory management. “Delphi allows you to easily load and unload things in memory so our software can run on any basic machine. In fact with a low-end PC you could have our application up and running in an hour. We couldn’t live without that.” Case Study https://www.embarcadero.com/case-study/rockware-inc-case-study Website https://www.rockware.com/ Screenshot Gallery

Read More

New Major Release for Delphi Code Analyzer v2.4 with Free Download

Delphi Parser has a new major release … Download Free The New & Powerful Delphi Parser Static Code Analyzer 2.4 & Get Your Delphi Code Analyzed in Minutes! This is an exciting year for Delphi programmers with one of the more significant new RAD Studio releases. With multiple new features and quality improvements, the time to upgrade your Delphi projects has never been better. Delphi Parser is the premier tool to support a wide range of Upgrade needs from simple projects to ones with millions of lines of code. We built it and improved it based on multiple projects. RAD Studio 10.4 allows developers to create amazing modern applications and Delphi Parser is the tool to get you there faster and cheaper. The Delphi Parser Analyzer 2.4 is the Newest Most Valuable Tool For Delphi Developers. It is built & aimed for dealing with huge legacy Delphi projects with hundreds of applications, thousands of unit files & libraries with millions of lines of code & decades of development & developers. It is a must-have tool in every development team through all the development life cycle. No Hard Work. You just need to provide the Delphi Parser Analyzer 2.4 the project source or code base folder you want to analyze, and the search path for the libraries & the Analyzer wizard will do the rest. The Delphi Parser’s Analyzer 2.4 is an automatic code analyzing wizard. It scans & analyzes an entire code base against all available Delphi’s system units, 3rd party components, libraries & even DCUs (using a special De-Compiler). Delphi Parser 2.4 – A Full Blown Independent Parser & Linker. The Analyzer 2.4 is built on the all new Delphi Parser 2.4 framework that has the ability to read millions of lines of code & parse the code into a unified run-time object mode. Multi Pass Parser – The Delphi Parser runs in several phases in order to remove all unnecessary compiler directives while stepping over syntax errors & bridging all Delphi versions differences, from Delphi 2 to 10.4 Sydney In order to build a unifying structured code in an object model in run-time memory. Built-in Linker & Semantic Objects Tree. As the New Delphi Parser v2.4 core technology reads all the code, it links between objects, find source declaration, links implementation code to objects & methods, checks for code dependencies, count references & usage, discover missing objects, and provides the developer an ability to review & drill down into the parsing & linking process in run-time like never been done before (as well as in any other language compilers). The Delphi Parser Analyzer 2.4 Wizard is available for all Delphi versions, as Express & Enterprise edition & also in an open-source edition based on the Delphi Parser 2.4 Developer’s Framework. The Delphi Parser Analyzer 2.4 helps your development team maintain a cleaned project’s codebase. Run it whenever you wish to release a new version update & removes unnecessary files & libraries from code before it is deployed. Take Control Over Your Code. Every software project contains many components that may become unnecessary or obsolete over the development process & stay there untouched, cause no one knows what to do with them & the fear of taking them out leaves them there for eternity. Today, with the Delphi Parser Analyzer 2.4 you can easily & quickly analyze your code on any given Delphi version, from the Legacy Borland to the Newest Embarcadero’s Delphi 10.4 Sydney – and get a true insight into what is going on in your code & […]

Read More

Combine Front End, Back End, And Business Logic In Modern Full-Stack Development With Delphi

Many application developers are building a web version of their services to get more users. For instance, you do not always have the same phone or same laptop to utilize the application, if the application has a web version everything is done.  In this webinar, you can see what is new with TMS Software and how you can use their full range of components to modernize your Windows 10 application and building web apps with Delphi.  New challenges today: Development for multiple platforms Desktop Client Applications need to interact with servers. Less RAD, more OOP Loosely-coupled Software Building Blocks Front-End – TMS VCL, FMX, FNC UI Pack & TMS Web Core Business Logic – TMS Aurelius, FlexCel, ANalytics, and more Back-End – TMS RemoteDB, Sparkle, XData If you are interested in building backend services with Delphi and TMS, you can utilize TMS XData to write custom services. TMS XData has several major features which you should know: Can be autogenerated from an existing database Open for any desktop, web, or mobile app Standardized REST protocol using JSON for data transport Fully documented REST API with SwaggerUI Be sure to watch the session Q&A learn more about the specific information. Head over and check out all of the different components available from TMS Software!

Read More

Quickly Share Data Between Datasets Using CloneCursor In This Native Windows Sample For Delphi

The CloneCursor sample shows you how to clone a dataset. To this end, the sample uses the CloneCursor method of the TFDDataSet class. Moreover, the sample uses other methods to determine whether the current record is within a specified range. Location You can find the CloneCursor sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesComp LayerTFDMemTableCloneCursor Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. How to Use the Sample Navigate to the location given above and open CDS_CachedUpdates.dproj. Press F9 or choose Run > Run. Click on the Use Connection Definition combo box and select an option. Click on the CloneCursor button to clone the dataset. Modify the Start range (OrderID) and End range (OrderID) labels. Click on the CheckRange button. Files File in Delphi Contains CDS_CachedUpdates.dprojCDS_CachedUpdates.dpr The project itself. fCachedUpdates.pasfCachedUpdates.fmx The main form. Implementation This sample uses three main components: When you run the application, click on the Use Connection Definition combo box and select an option in order to define a connection. When you select an item of the combo box, the Active property of the cdsOrders table is set to True in order to open the dataset and read data from the database. Then, the sample displays a table using a TDBGrid component. Once the TDBGrid is filled, you can interact with the sample. Each of the following buttons implements an OnClick event to do what is described below: When you click on the CloneCursor button, the sample clones the cdsOrders table using the CloneCursor method and sets the Active property of the cdsClone table to True in order to populate the table with the cloned data. When you click on the CheckRange button, the sample uses the Start range (OrderID) and End range (OrderID) labels as the starting and ending values of the SetRange method. Then the sample applies the range to the cdsClone table using the GotoCurrent method. When you click on the CancelRange button, the sample uses the CancelRange to remove the current range. Please refer to the next links for the source code of this Sample: https://github.com/Embarcadero/RADStudio10.4Demos/tree/master/Object%20Pascal/Database/FireDAC/Samples/Comp%20Layer/TFDMemTable/CloneCursor

Read More

Learn About Delphi Continuous Integration With SVN, Jenkins, And DUnitX

In this tutorial, you learn how to configure a Jenkins server to build and run a DUnitX test application using MSBuild, to be triggered by commit to a subversion repository, and to notify by email when the test fails. Brief Introduction to Version Control Version Control allows you to maintain multiple versions (revisions) of your source code on a remote server Version Control assists in the maintenance of source code with multiple authors What is Continuous Integration? Continuous Integration is a team problem. Continuous Integration is all about preventing the main branch from being broken so, your team is not stuck. That’s it. It is not about having all your tests green all the time and the main branch deployable to production at every commit. Continuous Integration is independent of any tool. You can verify manually that the merge of your branch and the main branch works locally. Be sure to watch the whole session to learn all the concepts related to Continuous Integration with Delphi

Read More

Quickly Work With A COMPort On Linux With Delphi Using A WINSOFT library

For you who works with COM Port Applications on linux, this is the most easy and fast way to connect, write and read info. Using  COMPORT for linux you can do it within literally few minutes, you just need to download the library and add it on your project, and this is it. First of all you need to prepare your linux machine to deploy your Console application from a Windows. On this example I’m using a Windows host running VM VirtualBox with Ubuntu. Installing Development Packages To install the development packages on Ubuntu: Right-click your desktop and select Open Terminal. To upgrade the packages you have already installed , type sudo apt update && sudo apt upgrade && sudo apt dist-upgrade in the terminal. Type your user password and press Enter Wait until prompted to agree to the package upgrade operation. Type Y and press Enter Wait until the package upgrade operation is complete. It may take a few minutes to complete. To add the development packages, type sudo apt install joe wget p7zip-full curl openssh-server build-essential zlib1g-dev libcurl4-gnutls-dev libncurses5 in the terminal. Type your user password and press Enter Wait until prompted to agree to the package installation operation. Type Y and press Enter Wait until the pacjage installation operation is complete. It may take a few minutes to complete. Preparing Your Linux Machine To create Linux applications, you need to add a virtual machine PAServer: Find the LinuxPAServer21.0.tar.gz file in the following location: C:Program Files (x86)EmbarcaderoStudio21.0PAServerLinuxPAServer21.0.tar.gz Unpack the LinuxPAServer21.0.tar.gz file. If needed Install the zlib library to your Ubuntu machine with the following command: sudo apt-get install zlib1g-dev Open the current dir on terminal and run it using ./paserver Now that the Linux Machine is ready lets download and use the COMPORT Library. Preparing Your Delphi application Creating a Connection Profile On the Tools > Options > Environment Options > Connection Profile Manager page, click the Add button. The Create a Connection Profile wizard opens On the Profile information page, enter the following: In the Profile name field, enter the needed name. In the Platform field, click the 64-bit Linux platform. Click Next. On the Remote machine information page, enter the following: In the Remote machine field, enter the IP address or Machine name. Click Test Connection to check if the values are valid. Adding the Installed SDK to RAD Studio On the Tools > Options > Environment Options > SDK Manager page, click the Add button. In the Add a New SDK dialog, enter the following: In the Select a platform field, click 64-bit Linux. In the Select a profile to connect, select a created profile from the drop-down list. In the Select an SDK version field, the name of the SDK that you just installed will automatically appear. If you have not installed SDK previously, you can do it on this step. If you have already installed SDK, move on to the next step. Download the package from WINSOFT, unzip it and open the demo application with Delphi, after that just add the library path on the project properties. The entire Tutorial for this process is here (available for Red Hat too).

Read More

Powerful Optical Barcode Recognition Component For Delphi Firemonkey By Winsoft

Introduction OBR (Optical Barcode recognition) component for Firemonkey supports Windows, macOS, iOS and Android. Its main purpose is to decode QR code and Barcode images. In the below video you can check the steps to install the firemonkey component for OBR. The installation steps differs to the one for the OBR firemonkey library, it is actually easier. 2. Components in the Demo and what they do There are two panels. One is at the top, containing the button for the picture choise. In the middle there is a Scroll box component (for scrolling) and a Timage component inside it for the chosen picture. At the bottom there is another panel again, containing the TMemo component . All combined they create the windows that shows up with button, image and text at the bottom.     Clicking on the button executes the TOpenPictureDialog component which opens a dialog for selecting a picture. The selected picture is loaded in an TImage component and shown on the main empty window. Clicking on the button executes the TOpenPictureDialog component which opens a dialog for selecting a picture. The selected picture is loaded in an TImage component and shown on the main empty window. with OpenDialog do if Execute then begin Memo.Lines.Clear; ImageControl.Bitmap.LoadFromFile(FileName); with OpenDialog do     if Execute then     begin       Memo.Lines.Clear;       ImageControl.Bitmap.LoadFromFile(FileName); Then the selected picture is decoded using the TBarcodeDecoder  object (the ‘scanner’) and the results is filled into the TDecodeResults list as it follows: with TBarcodeDecoder.Create do try Barcodes := Decode(ImageControl.Bitmap); with TBarcodeDecoder.Create do       try         Barcodes := Decode(ImageControl.Bitmap); If code is detected by the TBarcodeDecoder  object, the result is stored in the TDecodeResults list, named as Barcodes. With FOR cycle we check the list and its items of what they have stored before. The item of the TDecodeResults list contains FormatName and Text (which is the doceded text). You can see in the below code: for I := 0 to Length(Barcodes) – 1 do Memo.Lines.Append(Barcodes[I].FormatName + ‘: ‘ + Barcodes[I].Text); for I := 0 to Length(Barcodes) – 1 do             Memo.Lines.Append(Barcodes[I].FormatName + ‘: ‘ + Barcodes[I].Text); You can download the Demo with the component from the link below: https://winsoft.sk/fobr.htm

Read More

Wildly Popular Inno Setup Is A Free Installer For Windows Built In Delphi

Inno Setup is a free installer for Windows that is fast, free, and built in Delphi. Introduced in 1997, Inno Setup is brought you by Jordan Russell and Martijn Laan. Full source code is available over on GitHub but copyright of the software is maintained by the authors. Inno Setup is used world wide by a huge number of software developers and companies including powerhouses like Microsoft for their Visual Studio Code IDE on Windows. There are a number of third party add-ons for Inno Setup which really take it to the next level like Inno Script Studio by Kymoto Solutions and VCL styled installers by Rodrigo Ruz. The built in Inno Setup Compiler application supports a light and dark mode. The Inno Script Studio third party companion solution has an install script wizard which makes it super simple to create an installer file for Inno Setup with all the professional features you need. Website https://jrsoftware.org/isinfo.php GitHub https://github.com/jrsoftware/issrc Screenshot Gallery Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.Start Free Trial   Learn More About Upgrading

Read More