C++ Builder

Learn To Use Python Objects Inside Your Delphi Source Code With This Windows Sample App

Sometimes we may need to use Python objects like COM automation objects, inside your Delphi source code. Thinking about how to do it? Don’t worry. Python4Delphi has an excellent library unit that does for us. Using this we just create python objects by passing values as a variant that will return the python type as Delphi variant type. Also, the library has extensive helper routines to validate the type as well. This post guide you to understand better using the Python4Delphi sample app. You can also use Python4Delphi with C++Builder. Python4Delphi Demo25 Sample App shows how to create a python variable type (i.e. Integer, Float, String, Dates, Mappings, Object types) in Delphi by just passing values as variant type parameters. You can find the Demo25 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 Demo25 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. TPythonGUIInputOutput: Inherited from TPythonInputOutput (which works as a console for python outputs) Using this component Output property you can associate the Memo component to show the Output. TMemo: A multiline text editing control, providing text scrolling. The text in the memo control can be edited as a whole or line by line. VarPyth.pas – set of classes and helper routines to create python types and return variant types in Delphi. You can assert whether the type is Python type, Kind of python types(e.g. IsInteger, IsBool, IsFloat), etc. Also, you can use BuiltinModule routines to manipulate variant values. You can find the Python4Delphi Demo25 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo25.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. PythonGUIInputOutput1 provides a conduit for routing input and output between the Graphical User Interface (GUI) and the currentlyexecuting Python script. In this sample app, We have Buttons which unit tests different python types in Delphi. This is achieved by routines in VarPyth.pas. some e.g mentioned below. VarPythonCreate – Create a python type in Delphi bypassing variant values as a parameter. Internally the python object type is created based on the value in the parameter and returns the variant. Using this in Delphi we can perform python arithmetic operations, string manipulations, sequence operations, etc with the help of VarPyth helper routines. Memo2, used for providing the Python Script to execute, and Memo1 for showing the output.  On Clicking Execute Button the python script is executed. On Clicking Run Selected tests once it will validate each type created and manipulates some arithmetic, string manipulations, etc. procedure TMain.btnTestIntegersClick(Sender: TObject); var a, b, c : Variant; big : Int64; begin // initialize the operands a := VarPythonCreate(2); Assert(VarIsPython(a)); Assert(VarIsPythonNumber(a)); Assert(VarIsPythonInteger(a)); Assert(Integer(a) = 2); b := VarPythonCreate(3); Assert(VarIsPython(b)); Assert(VarIsPythonNumber(b)); Assert(VarIsPythonInteger(b)); Assert(Integer(b) = 3); end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 procedure TMain.btnTestIntegersClick(Sender: TObject); var   a, b, c : Variant;   big : Int64; begin   // initialize the operands   a := VarPythonCreate(2);   Assert(VarIsPython(a));   Assert(VarIsPythonNumber(a));   Assert(VarIsPythonInteger(a));   Assert(Integer(a) = 2);     b := VarPythonCreate(3);   Assert(VarIsPython(b));   Assert(VarIsPythonNumber(b));   Assert(VarIsPythonInteger(b));   Assert(Integer(b) = 3); end; Note : The […]

Read More

Learn To Build A Python GUI For Working with HTTP Requests With Requests Library In A Delphi Windows App

Python for Delphi (Python4Delphi , P4D) with Requests library allow you to execute Http requests in Python GUI for Windows. Python4Delphi is a free tool that can run Python scripts, work with new Python types and modules in Delphi. In this post, we will learn at how to run Requests library in Python for Delphi. Build your own Python GUI apps for Windows with Delphi and C++Builder and Python4Delphi using various Python libraries. Open and run project Demo1, then select Python script that you want execute in Python for Delphi. Use text fields for inserting Python script and for viewing results. Click Execute button for running Python script. Go to GitHub and 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; Requests is a simple Python library that allows you to execute standard HTTP requests. Using this library, you can pass parameters to requests, add headers, receive and process responses, execute authenticated requests. Let’s look at some examples. Make GET Request It is very easy to call GET request. Just use method get() and pass URL to this method. From response object you can get a lot of useful information. This example shows how to get content, status and list of response headers. You also can get other properties. import requests r = requests.get(‘https://example.com’) print(r.text) print(r.headers) print(r.status_code) import requests r = requests.get(‘https://example.com’) print(r.text) print(r.headers) print(r.status_code) POST Request with payload and timeout With Requests library, you can perform post requests by calling post() method. It is also possible to pass input data to the parameter payload. Different types of input data are possible. For example, dictionaries, tuples, lists import requests payload1 = {‘key1’: ‘value1’, ‘key2’: ‘value2’} r = requests.post(“https://httpbin.org/post”, data=payload1) print(r.text) payload2 = [(‘key1’, ‘value1’), (‘key1’, ‘value2’)] r1 = requests.post(‘https://httpbin.org/post’, data=payload2) print(r1.text) payload3 = {‘key1’: [‘value1’, ‘value2’]} r2 = requests.post(‘https://httpbin.org/post’, data=payload3) print(r2.text) import requests payload1 = {‘key1’: ‘value1’, ‘key2’: ‘value2’} r = requests.post(“https://httpbin.org/post”, data=payload1) print(r.text)   payload2 = [(‘key1’, ‘value1’), (‘key1’, ‘value2’)] r1 = requests.post(‘https://httpbin.org/post’, data=payload2) print(r1.text)   payload3 = {‘key1’: [‘value1’, ‘value2’]} r2 = requests.post(‘https://httpbin.org/post’, data=payload3) print(r2.text) Authenticated Request In this example we will take a look at how to execute authenticated requests. It is very easy, just pass the username and the password in the auth parameter. If authorization is successful, then we will receive a response status code 200, otherwise there should be non-authorization error 404. import requests from getpass import getpass r=requests.get(‘https://test.org’, auth=(‘username’, getpass())) print(r.status_code) import requests from getpass import getpass r=requests.get(‘https://test.org’, auth=(‘username’, getpass())) print(r.status_code) Check out the Requests library for Python a use it in your own projects. Check out Python4Delphi which can build Python GUIs for Windows using Delphi.

Read More

Achieve High Performance By Using The string_view C++17 Feature In C++Builder

In this tutorial, you will learn another modern C++17 feature to work with strings. This feature is a std::string_view. The purpose of any kinds of string reference proposals is to bypass copying data that already owned someplace and of which only a non-mutating representation is required. The std::string_view is one such proposal. There was an earlier one named string_ref. The std::string_view is a picture of the string and cannot​ be utilized to alter the original string value. When a std::string_view is constructed, there’s no need to replicate the data. Besides, the std::string_view is smaller than std::string on the heap. How can you use std::string_view with C++ Builder? string_view lives in the header file Benefits of the string_view string_view is useful when you want to avoid unnecessary duplicates The creation of string_view from literals does not need a dynamic allocation. The following code illustrates how string_view supports save memory by restricting unnecessary dynamic allocations: #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif #include #include #include #include #include // string_view // Unified way to view a string (memory and length) – without owning it // No allocation std::size_t parse(std::string_view str) { return std::count(str.begin(), str.end(), ‘e’); } int _tmain(int argc, _TCHAR *argv[]) { const std::string str = “hello world”; const char* c = “Rio de Janeiro”; std::cout 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 30 #ifdef _WIN32 #include #else typedef char _TCHAR; #define _tmain main #endif   #include #include #include #include #include   // string_view // Unified way to view a string (memory and length) – without owning it // No allocation std::size_t parse(std::string_view str) {     return std::count(str.begin(), str.end(), ‘e’); }   int _tmain(int argc, _TCHAR *argv[]) {     const std::string str = “hello world”;     const char* c = “Rio de Janeiro”;       std::cout “Occurrences of letter ‘e’: “ parse(std::string_view(str.data(), str.length())) std::endl;     std::cout “Occurrences of letter ‘e’: “ parse(std::string_view(c, strlen(c))) std::endl;     system(“pause”);     return 0; } So, std::string_view is an extraordinary utility for great performance. But, the programmer must assure that std::string_view does not outlive the pointed-to character array. Additional functions provided by std::string_view can be found here, on the official documentation. Head over and check out the Windows string_view demo for C++Builder on GitHub.

Read More

Boost C++Builder Compile Speed with TwineCompile – Deep Dive Webinar

TwineCompile is an advanced compile system that uses multi-threading technology and caching techniques to make your C++Builder compiles 50x faster! This IDE Plugin is included free with an active Update Subscription for all C++Builder and RAD Studio customers via the GetIt Package Manager. Install TwineCompile today from GetIt, before the webinar, so you can easily follow along as Jonathan demos the power of TwineCompile. Deep Dive Webinar: Boost C++Builder Compile Speed with TwineCompile Dec 14th, 2020 at 11 AM CST/1700 UTC [Register] with Jonathan Benedicto of JomiTech, creator of TwineCompile From an elevated RAD Studio Command prompt, you can install it with the command: getitcmd -i=TwineCompile-5.2.1 getitcmd –i=TwineCompile–5.2.1 Other TwineCompile features: Automatic background compiling engine ensures that files are compiled as fast as they are saved! A highly tuned, pre-compiled header handling system automatically maximizes simultaneous use of pre-compiled headers between multiple threads! Seamless integration into the C++Builder 10.4 Sydney IDE Theme support for all IDE themes providing a unified workspace! Full support for 32-bit and 64-bit compilers! Register now for the deep-dive webinar to maximize your C++Builder productivity and rocket your compilation speeds to new heights. TwineCompile performing an automatic background compile (SORTA) in C++Builder 10.4 Sydney. TwineCompile building a project in C++Builder 10.4 Sydney using the Dark Theme.

Read More

Get Free Responsive Cross-Platform Login Screen Templates For Android And iOS

This FireMonkey UI template designs for implementing a login screen in a multi-device application. And shows how to utilize FireMonkey designing guidelines. As you can see, this FireMonkey UI template is responsive and ready to utilize in any kind of project that requires a login screen like this! The templates should be cross-platform and work on Android, iOS, macOS, Windows, and Linux with a single UI and single codebase. From this demo project, you can learn: How to utilize ScrollBox Utilizing Layouts Making a blurred background image Changes to the layout should be made inside of the TFrame itself. Once changes are made to the TFrame you can delete it from the TForm and re-add it. Set its Align property to Client. Optionally, it’s ClipChildren property can be set to True if there are any overlapping background images. You can get this FireMonkey UI template from GetIt Package Manager Head over and get more information for the templates from GetIt and then download them in the Delphi IDE.

Read More

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

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

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

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

Learn About Using Right Angle Brackets In This C++11 Feature For Windows Development

In the Clang-enhanced C++ compilers, two consecutive right angle brackets no longer generate an error, and these constructions are treated according to the C++11 standard. C++03’s parser defines “>>” as the right shift operator or stream extraction operator in all cases. However, with nested template declarations, there is a tendency for the programmer to neglect to place a space between the two right angle brackets, thus causing a compiler syntax error. C++11 improves the specification of the parser so that multiple right angle brackets will be interpreted as closing the template argument list where it is reasonable. Right angle brackets example #pragma hdrstop #pragma argsused #include #include #include typedef std::vector > Table; // OK typedef std::vector> Flags; // OK int _tmain(int argc, _TCHAR* argv[]) { return 0; } #pragma hdrstop #pragma argsused   #include #include   #include typedef std::vector<std::vector<int> > Table;  // OK typedef std::vector<std::vector<bool>> Flags;  // OK   int _tmain(int argc, _TCHAR* argv[]) {           return 0; } Head over and find all of the different C++ language features now available in C++Builder. 

Read More