Noutați

Easy Steps To Connect To A MS Access Database With FireDAC In This Windows Sample App

Do you want your Delphi and C++ Builder Applications to connect with Access Database ? Do you need to manage some of the Access Database services such as creating, compacting database? How to start ? Don’t worry, FireDAC components offers robust components to connect with Access Database. FireDAC.Access Sample app demonstrates how to use FireDAC to work with access Database. You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. Components used in the Sample App: TFDQuery : To execute SQL queries, browse the result sets, and edit the result set records. TFDPhysMSAccessDriverLink: To link the Microsoft Access driver to an application and set it up. In general, it is enough to only include the FireDAC.Phys.MSAcc unit into your application uses clause. It is used to specify access ODBC driver name and access the ODBC driver connection parameter common for all connections. TFDConnection : To establish a connection to a DBMS and to manage associated datasets. TFDAccessService: Class Implementing Microsoft Access database for creating, dropping, compacting, and repairing services. And some of the UI components, like TDBGrid,TDBComboBox, TFDGUIxWaitCursor1,TFDGUIxLoginDialog1,TFDGUIxErrorDialog1 Implementation Details: The simplest way to configure connection to MS Access database at run time is to build a temporary connection definition: In the sample, the temporary definition is created when the  item is selected in the Connection combo box.  Open the following database: C:UsersPublicDocumentsEmbarcaderoStudio20.0SamplesdataFDDemo.mdb. In the demo database, the Categories and Products tables have one-to-many relation by CategoryID field. Mention the query to the qryCategories.SQL property and qryProducts.SQL property. Finally, qryProducts.MasterSource property is set to dsCategories, while the MasterFields property is set to CategoryID. This creates a master-details relationship between the datasets. Simple queries execution is demonstrated via the ExecSQL method of TFDConnection. The management of databases, such as: creating, dropping, compacting/repairing, and setting a password is done using TFDMSAccessService component. This demo demonstrates how to create and compact the user database.  Check out the full article in the DocWiki about the FireDAC.Access Sample. FireDAC.Access Sample App Check out the full source code for the FireDAC.Access projects for Delphi and C++Builder over on GitHub.

Read More

Black Friday 2020

And we are back with our best deals for Black Friday 2020!Buy one product and get a second same or lower priced product at 50% discount! (new licenses only) Enjoy this super deal this Friday, all day long! Purchase your first product and just contact our team at sales@tmssoftware.com for your coupon code for the second license. Don’t wait and take advantage now! Share your excitement:

Read More

Flexible Brotli Compression Library For Your Windows Delphi/C++ Builder VCL And FMX Apps

Most of Delphi and C++ Builder developers utilize preinstalled components and libraries to compress and decompress files. For instance, the System.Zlib which supports gzip and deflate, the System.Zip is also helpful to handle .zip archive files. Moreover, Indy’s TIdCompressorZLib which is based on Zlib.  But that is not it. There are more different libraries based on different compression algorithms and more modern techniques, for instance, the Brotli – Brotli is similar in speed with deflate but offers more impenetrable compression. Brotli is open-sourced under the MIT License by Google. Brotli compressed files have .br extension. To connect your Delphi or C++ Builder VCL and FMX application with the Brotli library we can rely on Brotli Compress library from WINSOFT which offers to use the Brotli library easily. Brotli itself is free to use and distribute, but the Brotli Compress by WINSOFT is a commercial library and if you would like to use that library you should get a license! Uses Brotli library Supports Windows 32 and Windows 64 Available for Delphi/C++ Builder 6 – 10.4 After downloading the Brotli from WINSOFT you should configure the library into your RAD Studio. You can follow the tutorial here that shows the steps to configure without errors. Since the Brotli itself is a whole compression library your application should have brotlilib.dll – Dynamic-link library. You will get those files within the Brotli Compressor by WINSOFT in a Library Folder. Brotli Compressor Library has two main classes: TBrotliEncoder  TBrotliDecoder As you can observe the TBrotliEncoder encodes and TBrotliDecoder decodes the files with the given parameters. Furthermore, the OnProgress event provides the decompression and compression progress info. Additionally, you can set encoding quality with the Quality property. Here is the Brotli library demonstration video that shows the demo application in action.  These are demo projects’ UI: DEMO UI This is how you can encode with Brotli: InputStream := TFileStream.Create(EditFileName.Text, 0); try OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.br’), fmCreate); try with TBrotliEncoder.Create do try if RadioButtonGeneric.IsChecked then Mode := emGeneric else if RadioButtonText.IsChecked then Mode := emText else Mode := emFont; Quality := Round(TrackBarQuality.Value); OnProgress := Self.OnProgress; Compress(InputStream, OutputStream); finally Free; end; finally OutputStream.Free; end; finally InputStream.Free; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 InputStream := TFileStream.Create(EditFileName.Text, 0);     try       OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.br’), fmCreate);       try         with TBrotliEncoder.Create do         try           if RadioButtonGeneric.IsChecked then             Mode := emGeneric           else if RadioButtonText.IsChecked then             Mode := emText           else             Mode := emFont;           Quality := Round(TrackBarQuality.Value);           OnProgress := Self.OnProgress;           Compress(InputStream, OutputStream);         finally           Free;         end;       finally         OutputStream.Free;       end;     finally       InputStream.Free;     end; Here is how you can decode with the Brotli: InputStream := TFileStream.Create(EditFileName.Text, 0); try if CheckBoxCheckIntegrity.IsChecked then OutputStream := nil else OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.uncompressed’), fmCreate); try with TBrotliDecoder.Create do try OnProgress := Self.OnProgress; Decompress(InputStream, OutputStream); finally Free; end; finally OutputStream.Free; end; finally InputStream.Free; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 InputStream := TFileStream.Create(EditFileName.Text, 0);     try       if CheckBoxCheckIntegrity.IsChecked then         OutputStream := nil       else         OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.uncompressed’), fmCreate);       try         with TBrotliDecoder.Create do         try           OnProgress := Self.OnProgress;           Decompress(InputStream, OutputStream);         finally           Free;         end;       finally         OutputStream.Free;       end;     finally       InputStream.Free;     end; As you can see this is uncomplicated and you just need to implement the file selection […]

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

Learn To Build A Python GUI For Solving Complex Tasks With Powerful OpenCV Library In A Delphi Windows App

Are you looking for a powerful machine learning library? Try OpenCV library for Python. You can run it with Python for Delphi (P4D). P4D is a free and simple with which you can run Python scripts as well as create new Python modules and types in Delphi. Use Delphi and C++Builder and Python4Delphi to run Python scripts in  Python GUI apps for Windows. First, run Demo1 project for executing Python script in Python for Delphi. Then load script in text field and press Execute button to see the result. Go to GitHub to download Demo1 source. procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; OpenCV is an open-source library for computer vision and machine learning that supports various programming languages including Python. With this library, you can do a lot of difficult operations, such as image processing, video analysis, feature detection, machine learning, computational photography, object detection. K-Nearest Neighbour In this example, we will consider solving the problem of finding nearest neighbors using OpenCV library. First, let’s randomly create 20 red points (family 0) and 20 green points (family 1). Then add 5 blue points. Using function train(), we will train the neural network. Function findNearest() returns k nearest neighbours (in our example k=3) for each blue point. It also calculates the distance to each found neighbor and determines the family of points from which more neighbors are found. import cv2 import numpy as np import matplotlib.pyplot as plt # Feature set containing (x,y) values of 20 training data trainData = np.random.randint(0,100,(20,2)).astype(np.float32) # Labels each one either Red or Green with numbers 0 and 1 responses = np.random.randint(0,2,(20,1)).astype(np.float32) # Take Red points and plot them red = trainData[responses.ravel()==0] plt.scatter(red[:,0],red[:,1],50,’r’,’s’) # Take Green points and plot them green = trainData[responses.ravel()==1] plt.scatter(green[:,0],green[:,1],50,’g’,’^’) # 5 new points newpoints = np.random.randint(0,100,(5,2)).astype(np.float32) plt.scatter(newpoints[:,0],newpoints[:,1],50,’b’,’o’) knn = cv2.ml.KNearest_create() knn.train(trainData,cv2.ml.ROW_SAMPLE,responses) ret, results,neighbours,dist = knn.findNearest(newpoints, 3) print(“result: “, results,”n”) print(“neighbours: “, neighbours,”n”) plt.show() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import cv2 import numpy as np import matplotlib.pyplot as plt   # Feature set containing (x,y) values of 20 training data trainData = np.random.randint(0,100,(20,2)).astype(np.float32)   # Labels each one either Red or Green with numbers 0 and 1 responses = np.random.randint(0,2,(20,1)).astype(np.float32)   # Take Red points and plot them red = trainData[responses.ravel()==0] plt.scatter(red[:,0],red[:,1],50,‘r’,‘s’)   # Take Green points and plot them green = trainData[responses.ravel()==1] plt.scatter(green[:,0],green[:,1],50,‘g’,‘^’)   # 5 new points newpoints = np.random.randint(0,100,(5,2)).astype(np.float32) plt.scatter(newpoints[:,0],newpoints[:,1],50,‘b’,‘o’) knn = cv2.ml.KNearest_create() knn.train(trainData,cv2.ml.ROW_SAMPLE,responses) ret, results,neighbours,dist = knn.findNearest(newpoints, 3)   print(“result: “, results,“n”) print(“neighbours: “, neighbours,“n”)   plt.show() Perspective Transformation of an Image To perform perspective transformation with an image use warpPerspective() function. The parameters of this function are the original image, the transformation matrix, and the size of the output image. Use getPerspectiveTransform() function to get the transformation matrix. You need to pass four points of the input image and the corresponding four points of the output image to this function. It is important, that three of the four points should not be on the same straight line. import cv2 import numpy as np import matplotlib.pyplot as plt image_path = “E:faces.JPEG” img = cv2.imread(image_path) pts1 = np.float32([[900,100],[1200,100],[900,400],[1200,400]]) pts2 = np.float32([[0,0],[400,0],[0,400],[400,400]]) M = cv2.getPerspectiveTransform(pts1,pts2) dst = […]

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

Learn To Build A Python GUI For Working With The Numpy Library In A Delphi Windows App

If you need to perform complex transformations or mathematical calculations with matrices or arrays, then Python Numpy library is exactly what you need. You can easy run this library with Python4Delphi (P4D). Python4Delphi is a free tool with which you can work with Python scripts and objects in the Windows GUI. In this post, we will look at how to run Numpy library with P4D. Now you can build Python GUI apps for Windows using a lot of Python libraries with Delphi and C++Builder and Python4Delphi. Just open and run Demo1 project. Then paste the Python script into the text field, press Execute button and get the result. Go to GitHub to download Demo1. procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; Numpy library allows you to create multidimensional arrays and matrices and work with their properties. It also contains various functions for processing arrays and matrices. Let’s look at some simple examples of working with Numpy. If you have trouble compiling the Python you may need to have Numpy 1.19.3 installed. Create a matrix and get some properties This example shows how to create a 3-dimensional array and fill it with numbers from 0 to 29. Then, using the properties of this array, we can find out its shape, dimension, data type, number of elements. import numpy as np a = np.arange(30).reshape(2, 3, 5) print(a) print(a.shape) print(a.ndim) print(a.dtype.name) print(a.itemsize) print(a.size) import numpy as np a = np.arange(30).reshape(2, 3, 5) print(a) print(a.shape) print(a.ndim) print(a.dtype.name) print(a.itemsize) print(a.size) Basic operations with arrays Let’s take a look at the simplest conversions you can perform on arrays. Using concatenate() function, you can combine the values of two arrays into one. With function sort() you can sort ascending the values in an array. Function reshape() allows you to change the dimension of the array. import numpy as np arr = np.array([7, 10, 3, 11, 29, 15, 18]) print(np.sort(arr)) a = np.array([1, 2, 3, 4, 5, 6]) b = np.array([7, 8, 9, 10, 11, 12]) print(np.concatenate((a, b))) c = a.reshape(3, 2) print(c) import numpy as np arr = np.array([7, 10, 3, 11, 29, 15, 18]) print(np.sort(arr)) a = np.array([1, 2, 3, 4, 5, 6]) b = np.array([7, 8, 9, 10, 11, 12]) print(np.concatenate((a, b))) c = a.reshape(3, 2) print(c) Mathematical operations with matrix Function default_rng()  allows you to fill a matrix with random values. You can use integer or real numbers. In this example, we fill the matrix with integer values. Then we find the maximum and minimum element, the sum of all the elements in the matrix. It is also shown how you can multiply a matrix by a number and sum two matrices with the same dimension. import numpy as np from numpy.random import default_rng rng = default_rng() arr=rng.integers(20, size=(2, 4)) print(arr) print(arr.max()) print(arr.min()) print(arr.sum()) print(arr*2) arr2=rng.integers(5, size=(2, 4)) print(arr2) print(arr+arr2) import numpy as np from numpy.random import default_rng rng = default_rng() arr=rng.integers(20, size=(2, 4)) print(arr) print(arr.max()) print(arr.min()) print(arr.sum()) print(arr*2) arr2=rng.integers(5, size=(2, 4)) print(arr2) print(arr+arr2) And this is only a small part of what Numpy library allows you to do. Download Numpy and check how many possibilities it opens for your applications. Install Python4Delphi for building Python GUIs for Windows using Delphi easily.

Read More