From the blog

Quickly Evaluate A Python Expression In Delphi Using Python4Delphi Sample App

Want to know how to evaluate a Python Expression in Delphi using Python4Delphi? Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and C++Builder. They let you easily execute Python scripts, create new Python modules and new Python types. This post will guide you on how to use these components, create a VCL application, run a simple python expression in it, and shows the output message. Python4Delphi Demo2 Sample App shows how to Evaluate a Python Expression by typing the python expression in a Memo, execute and show the message. You can find the Demo2 source on GitHub. Check Demo1 on how to run a simple python script in Delphi. 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 Demo2 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a Singleton class. Some of the key properties for the component listed here. AutoLoad: Enable this property to load the python DLL automatically. It defaults to true. AutoUnload: Enable this property to unload the python DLL automatically. It defaults to true. DllName: By default, it reflects the latest e.g. python39.dll. But you can provide your registered version. DllPath: Physical location of the Python DLL. InitScript: You can provide the python script here to execute implicitly. IO: Associate the TPythonGUIInputOutput component to this property. RegVersion: Registered python version e.g 3.9. UseLastKnownVersion: If you want to use the latest registered Python version installed set this property to True. 2.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. MaxLineLength: Maximum character length per line. MaxLines: Maximum python script lines can be executed using this component. OutPut: Associate the Memo component to show the output. RawOutput: Produce the result as raw output. UniCodeIO: Set true to provide Input and output as Unicode. 3.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. You can find the Python4Delphi Demo2 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo02.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. Memo1, used for providing the Python Expression and Memo2 for showing the output(instead Memo2 used ShowMessage to show the expression result) Buttons to perform the execution, load script from, and save the script to file. On Clicking Execute Button the script expression is executed using the below code. procedure TForm1.Button1Click(Sender: TObject); var Result : PPyObject; begin with PythonEngine1 do begin Result := EvalStrings( Memo1.Lines ); if Assigned(Result) then begin ShowMessage(Format(‘Eval: %s’,[PyObjectAsString(Result)])); Py_DECREF(Result); end else ShowMessage(‘Could not evaluate the script’); end; end; procedure TForm1.Button1Click(Sender: TObject); var   Result : PPyObject; begin   with PythonEngine1 do     begin       Result := EvalStrings( Memo1.Lines );       if Assigned(Result) then         begin           ShowMessage(Format(‘Eval: %s’,[PyObjectAsString(Result)]));           Py_DECREF(Result);         end       else         ShowMessage(‘Could not evaluate the script’);     end; end; EvalStrings will evaluate the Mathematical expression provided in the Memo1 and return the Python Object(PPyObject). We […]

Read More

Learn Game Development With Delphi FireMonkey In This Delphi Bootcamp Session

In this Delphi Bootcamp session, you can learn about how to create cross-platform games with Delphi FireMonkey.  If would like to learn about the industrial game development use case in Delphi FireMonkey, be sure to check out the Rise of Legions game by Broken Games Studio which has over 100,000 subscribers. Overview Four Classic Arcade Games Alien Invasion Mars Rocket Rocket Ship Delta Space Rocks Supports Android/iOS/OSX/Windows Architecture: Putting It All Together TRectangle – As in image container Frames for UI Motion Sensor High Score via SQLite & LiveBindings Object Pooling Sprite Sheet Animation App Tethering Cross-Platform Sound Architecture: Game Loop TTimer with an event every 36ms Process game events like game over and level complete Process player inputs including Accelerometer Process explosions and projectiles Process enemy movements and events Process power-ups Handle collision detection for all entities Handle looping in the music Moreover, you can find epic Delphi Game Engines here:

Read More

Easily Customize Your Delphi VCL Application With Dark And Light Themes According to Windows Mode

Many times we need to override windows default settings or customize our application by code, irrespective of user settings in windows for better user experience. Your application has been built with options to apply certain themes and the user also has the flexibility to change Windows themes for entire windows/apps. In this case, your application user experience should not be affected by user system settings. This post can guide you to set the themes in your Windows VCL application. How to check whether dark mode is enabled? Press Windows + R -> Type Regedit cmd in Run Command window. Navigate to the folder: ComputerHKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionThemesPersonalize. Check AppsUseLightTheme Keyword and if its value is 1 then the windows apps theme is in Light mode and 0 means it’s in Dark mode. How to set the themes in Delphi from project options : In Delphi IDE, Go to -> Project Menu -> options -> appearance -> Select the available themes suitable for your application. Carbon for Dark theme for example. You application theme settings: If you want to give a better user experience explicitly irrespective of (or) according to windows themes selected by the user in the machine, first programmatically check the app theme mode. Navigate to the following location ComputerHKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionThemesPersonalize and get the keyword AppsUseLightTheme value. Accordingly build your logic of setting the VCL theme using the VCL API to set the themes. Note: Platform specific conditional defines need to be included accordingly if it is cross platform application. Check the below Video for the full demonstration of setting the dark/light theme Vice-versa for a VCL application. Check out the latest Delphi 10.4.1 which supports High DPI Styles and VCL per control styling for your applications.

Read More

Powerful Shipping Container Cargo Optimizer Built In Delphi FireMonkey

Dreamsofts Optimization Ltd. has an award winning shipping container cargo optimizer available in the iOS and Mac stores. The application is also available on Windows and is built in Delphi FireMonkey. Both a professional and an enterprise version are available with different feature sets. The application is described as “First container loading and pallet loading on mobile platform. You have found the easiest container/pallet loading optimization application. Simulate loading your cargo in minutes, not hours or days ! Maximize your shipping with boxes and container/truck/pallet and save money and time.” Some of the awards that the app has received are “Winner Retails & Supply Chain Application Thailand ICT Award 2014” and “Merit award Asia Pacific ICT Award 2014”. It really is an amazing looking application and utilizes the full features of FireMonkey to make it happen. Website http://www.cargooptimizer.com/ (Download) App Store https://apps.apple.com/us/app/cargo-optimizer-max-for-ipad/id1292163026 Mac Store https://apps.apple.com/app/id1481054645?mt=12 Screenshot Gallery

Read More

Create Visually Stunning VCL Application With Konopka Signature VCL Controls 6

KSVC – Konopka Signature VCL Controls 6 is a suite of over 200 Windows UI controls and designers for your Delphi and C++ Builder VCL applications. Konopka Signature VCL components provide unmatched attention to detail, ease of use, and versatility. KSVC also supports full VCL Styles, which can deliver custom and stunning modern Windows applications. To utilize the KSVC components, you should install it from GetIt Package Manager. If you need a guide for using GetIt, follow these steps. KSVC components provide many stunning UI controls for your VCL applications, which you cannot get within RAD Studio. Moreover, you can customize components with quick access to an extensive array of component customizations. If you would like to learn more about Konopka Signature VCL Controls 6 be sure to check out these sources: Konopka Signature VCL Controls – Ray Konopka Overview of New Windows 10 VCL Controls with Ray Konopka – CodeRageXI Head over and check out the listing for the Konopka Signature VCL Controls in the latest version of Delphi available via GetIt in the IDE.

Read More

Learn How to Run A Simple Python Script In Delphi Application Using Easy Python4Delphi Sample App

How about combining the strength of Delphi and Python for your applications to provide first-class solutions for your customer needs? Thinking about how to do it? Don’t worry! Python4Delphi does for us. Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and C++Builder. They let you easily execute Python scripts, create new Python modules and new Python types. This post will guide you on how to use these components, create a VCL application, run a simple python script in it, and gets the output. Python4Delphi Demo1 Sample App shows how to run a Python Script by typing the python code in a Memo, execute and populate the result in another Memo. You can find the Demo1 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 Demo1 App: 1.TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. Some of the key properties for the component listed here. AutoLoad: Enable this property to load the python DLL automatically. It defaults to true. AutoUnload: Enable this property to unload the python DLL automatically. It defaults to true. DllName: By default, it reflects the latest e.g. python39.dll. But you can provide your registered version. DllPath: Physical location of the Python DLL. InitScript: You can provide the python script here to execute implicitly. IO: Associate the TPythonGUIInputOutput component to this property. RegVersion: Registered python version e.g 3.9. UseLastKnownVersion: If you want to use the latest registered Python version installed set this property to True. 2.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. MaxLineLength: Maximum character length per line. MaxLines: Maximum python script lines can be executed using this component. OutPut: Associate the Memo component to show the output. RawOutput: Produce the result as raw output. UniCodeIO: Set true to provide Input and output as Unicode. 3.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. You can find the Python4Delphi Demo1 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo01.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. Memo1 used for providing the Python Script and Memo2 for showing the output. Buttons to perform the execution, load script from, and save the script to file. PythonGUIInputOutput1‘s property Output to Memo2. On Clicking Execute Button the script strings are executed using the below code. PythonEngine1.ExecStrings( Memo1.Lines); PythonEngine1.ExecStrings( Memo1.Lines); Load the script to the Memo1 from a file using the code with OpenDialog1 do begin if Execute then Memo1.Lines.LoadFromFile( FileName ); end; with OpenDialog1 do begin   if Execute then     Memo1.Lines.LoadFromFile( FileName ); end; Save the Script to the file using the code, with SaveDialog1 do begin if Execute then Memo1.Lines.SaveToFile( FileName ); end; with SaveDialog1 do […]

Read More

C++ Language Conversation With Bjarne Stroustrup and David Intersimone

C++ is getting many new features and improved code hygiene, which improves your code compile time. In this webinar, you can watch and listen to the conversation with Bjarne Stroustrup and David Intersimone.  Overview C++17 Current Standard C++20 According to Bjarne Stroustrup, C++ is not a simple language, but you can write code simply and that compiles faster once it is done.  Bjarne Stroustrup has written a paper in 1981 saying you need generic programming, and he conjectured that macros was the way to get it. Actually, he was right about the problem. Now, today it has been solved.  C++ Core Guidelines The most interesting view in this session is that Bjarne Stroustrup, saying you can not just simplify the programming language: C++. People want more simple stuff and they say add this and that features and do not break my code. So, the better way is to have good coding guidelines, better teaching, tool support like the static analysis. Be sure to watch the session to learn more about C++ history and its near future!

Read More

Learn How To Implement A Custom Resource EMS Package To Extend RAD Server In Delphi

The CustomLogin sample is a server-client EMS demo, that demonstrates how to implement custom Login and Signup endpoints in a custom resource. It requires InterBase to be installed on the machine to connect to the EMS server. Make sure that the EMS Server is running before you run the client project. Location You can find the CustomLogin sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to either: Object PascalDatabaseEMSCustomLogin CPPDatabaseEMSCustomLogin Subversion Repository: You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. How to Use the Sample Run the EMS CustomLogin Package When you run the CustomLoginPackage project, the EMSDevServer starts automatically. The supported platforms for this sample are: 32-bit and 64-bit Windows. Navigate to one of the locations given above and open: Delphi: CustomLoginPackage.dpk. C++: CustomLoginPackageCpp.cbproj. Press Shift+Ctrl+F9 or choose Run > Run Without Debugging. The EMS Development Server opens.If it is the first time you are using EMS on the machine, you need to run the configuration wizard in order to create the EMS server configuration file. When the Confirm dialog opens, click Yes. Click Next until the installation finishes. The EMS Development Server starts automatically. Run the Client Application The client expects the EMSDevServer to be running at localhost:8080. If you are running the server at a different address, modify the properties of the TEMSProvider component. To run the sample on a different machine that the EMS Server, change the URLHost property of the TEMSProvider component to the IP address from the machine where the EMS Server runs.Note: The TEMSProvider component is placed in the CustomLoginClientU unit. On the Project Manager, right-click on ProjectGroup1. Click Add Existing Project…. Navigate to one of the locations given above and open: Delphi: CustomLoginClient.dproj. C++: CustomLoginClientCpp.cbproj. Press F9 or choose Run > Run. Select Use Custom Resource (CustomLogin) to use your Window credentials to authenticate in the EMS Server. In the Signup or Login tabs, insert a UserName and Password and click the buttons: Use the Signup tab to sign up a new user and log on to the EMS Server with that user. Use the Login tab if you previously created an account. Click the Logout button to log off from the EMS Server. In the User tab you can manage your user data: Click the Delete user to delete the user from the EMS Server. Click the Retrieve Fields button to get the custom description field from the EMS Server. { “description”:”New info” } Click the Update Fields button to modify and update the custom description field in the EMS Server. Note: The custom Login and Signup endpoints validate the UserName and Password against Windows users by calling WinApi.Windows.LogonUser. You need to sign up with valid Windows credentials. Implementation EMS Custom Package The custom login package implements custom Login and Signup endpoints, by matching the signature of the Users.LoginUser and Users.SignupUser and implementing these methods. The custom public endpoints are: CustomSignupUser to sign up a new EMS user. CustomLoginUser to log in an existing EMS user. Client Application The client application has a TEMSProvider component, that: The information is managed with TJSONObject and TJSONArray. Please visit the original Embarcadero post for more information about this samble: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/EMS.CustomLogin_Sample

Read More

Learn About Using C++ rvalue References In The C++Builder BCC32 Compiler

BCC32, which is the classic C++Builder 32 bit compiler, includes the use of rvalue references, which allow creating a reference to temporaries. Also, rvalue references avoid unnecessary copying and make possible perfect forwarding functions. This feature is one of the C++11 features. Rvalue references are a compound type like standard C++ references, which are referred to as lvalue references. An lvalue reference is formed by appending the ampersand character (&) to a type: SomeClass l; SomeClass& lReference = l; //lvalue reference SomeClass l; SomeClass& lReference = l;    //lvalue reference The syntax of an rvalue reference is to add && after a type: SomeClass r; SomeClass&& rReference = r; //rvalue reference  SomeClass r; SomeClass&& rReference = r;    //rvalue reference  An rvalue reference behaves like an lvalue reference, except that you can bind an rvalue reference to a temporary — an rvalue. SomeClass a; a = SomeClass(); SomeClass& lReference = a; //OK-lvalue reference can bind to an lvalue such as “a” SomeClass& lReference2 = SomeClass(); //error-lvalue reference can’t bind to an rvalue SomeClass&& rReference = SomeClass(); //OK for rvalue reference to bind to rvalue // Both references can be used the same way SomeOtherClass value1 = SomeFunc(lReference); SomeOtherClass value2 = SomeFunc(rReference); SomeClass a; a = SomeClass(); SomeClass& lReference = a;         //OK-lvalue reference can bind to an lvalue such as “a” SomeClass& lReference2 = SomeClass();  //error-lvalue reference can’t bind to an rvalue SomeClass&& rReference = SomeClass();  //OK for rvalue reference to bind to rvalue   // Both references can be used the same way SomeOtherClass value1 = SomeFunc(lReference); SomeOtherClass value2 = SomeFunc(rReference); In the example above, SomeClass() is not bound to an identifier, so it is an rvalue and can be bound to an rvalue reference — but not an lvalue reference. Here is the above sample code in C++Builder. Find out more about C++ rvalue References over in the Embarcadero DocWiki.

Read More

Create Delphi Web Applications Blazingly Fast With TMS WEB Core

Embarcadero MVP Marcos Moreira shows you how to use TMS WebCore and Delphi to make the most of your web development. TMS WEB Core: Modern SPA Web Application Model Pure HTML5/CSS3/JavaScript based applications Standard component framework for common UI controls and access to browser features Open to consume other existing JavaScript frameworks & libraries Offers Pascal class wrappers for jQuery controls from the jQWidgets library Easy interfacing to REST Cloud Services including to TMS XData for database Easy Deployment and more! One of the most features in the TMS WEB Core is you can debug in Pascal code via the browser. In this CodeRage session, you can learn how to utilize this feature.  Moreover, Marcos Moreira shows you how to manage JavaScript libraries and how to design your web applications easily with the Bootstrap by modifying the HTML code.  Be sure to watch this session to learn more about the TMS WEB Core and its amazing functionalities! Find out more about TMS Web Core over at TMS Software.

Read More