Quantcast
Channel: TMS Software
Viewing all 1008 articles
Browse latest View live

TMS X-Cloud Todolist with FNC

$
0
0

It's almost three months since we released the first version of the TMS FNC UI Pack, a set of Framework Neutral Components (FNC), and have meanwhile released 2 major updates which include the TTMSFNCTabSet/TTMSFNCPageControl (v1.1), the recently introduced TTMSFNCListBox/TTMSFNCCheckedListBox and significant improvements / new features to the TTMSFNCTreeView such as filtering, sorting, keyboard lookup, clipboard support, ... (v1.2).

As already explained in previous blog posts (http://www.tmssoftware.com/site/blog.asp?post=335 and http://tmssoftware.com/site/blog.asp?post=346), the TMS FNC UI Pack is a set of UI controls that can be used from VCL Windows applications, FireMonkey (FMX) Windows, Mac OS-X, iOS, Android applications and LCL framework based Lazarus applications for Windows, Linux, Mac OS-X, ... . The TMS FNC UI Pack contains highly complex & feature-rich components such as grid, planner, rich editor, treeview, toolbars. So, with a single set of controls, you have the freedom of choice to use Delphi, C++Builder or the free Lazarus to create applications for a myriad of operating systems, you have a single learning curve to these components and as demonstrated here, you can use a single source to create apps for multiple targets.

This blog post will cover the TTMSFNCCheckedListBox, which is one of the new components that are added in the latest release (v1.2) of the TMS FNC UI Pack, show how to use myCloudData.net to store data and demonstrate how easy it is to switch between FMX, VCL and LCL with one shared source code. myCloudData is an easy to use & flexible service to make use of structured storage in the cloud from Windows, web, mobile or IoT apps and is offered by tmssoftware.com. myCloudData is OAUTH/JSON REST based and our TMS Cloud Pack includes a component to access the service and thus your data seamlessly.

Click image for more screenshots.

A single shared source

As with our TV-guide sample we have created a single shared source file that is used in a FMX, VCL and LCL project. The unit starts by defining the business logic class that will be instantiated in our application main form unit.
  TTODOListLogic = class
  private
    FTable: TMyCloudDataTable;
    FListBox: TTMSFNCCheckedListBox;
    FMyCloudDataAccess: TMyCloudDataAccess;
    FOnConnected: TNotifyEvent;
    FBitmapContainer: TTMSFNCBitmapContainer;
  protected
    procedure DoConnected(Sender: TObject);
  public
    destructor Destroy; override;
    procedure InitListBox(AListBox: TTMSFNCCheckedListBox);
    procedure InitMyCloudData;
    procedure Refresh;
    procedure InitializeTable;
    procedure AddNewItem(AText: string; ADate: TDateTime; APriority: TPriority);
    procedure DeleteItem;
    procedure Connect;
    procedure DoBeforeDrawItem(Sender: TObject; AGraphics: TTMSFNCGraphics; ARect: TRectF; AItem: TTMSFNCListBoxItem; var AAllow: Boolean; var ADefaultDraw: Boolean);
    procedure DoItemCheckChanged(Sender: TObject; AItem: TTMSFNCCheckedListBoxItem);
    procedure DoItemCompare(Sender: TObject; Item1, Item2: TTMSFNCListBoxItem; var ACompareResult: Integer);
    property OnConnected: TNotifyEvent read FOnConnected write FOnConnected;
    property BitmapContainer: TTMSFNCBitmapContainer read FBitmapContainer write FBitmapContainer;
  end;
Each framework has its own set of units in order to compile succesfully. We use the conditional defines added to our project to make the difference between each framework.
uses
  Classes, SysUtils, DB
  {$IFDEF VCL}
  ,VCL.TMSFNCListBox, VCL.TMSFNCCheckedListBox, CloudMyCloudData, CloudBase, VCL.TMSFNCUtils,
  CloudCustomMyCloudData, VCL.TMSFNCGraphics, VCL.Dialogs, VCL.TMSFNCTypes, Types, VCL.TMSFNCBitmapContainer;
  {$ENDIF}

  {$IFDEF FMX}
  ,FMX.TMSFNCListBox, FMX.TMSFNCCheckedListBox, FMX.TMSCloudMyCloudData, FMX.TMSCloudBase,
  FMX.TMSFNCUtils, FMX.TMSCloudCustomMyCloudData, FMX.TMSFNCGraphics, FMX.TMSFNCTypes, FMX.Dialogs, Types, FMX.TMSFNCBitmapContainer;
  {$ENDIF}

  {$IFDEF LCL}
  ,LCLTMSFNCListBox, LCLTMSFNCCheckedListBox, LCLTMSCloudMyCloudData, LCLTMSCloudBase,
  LCLTMSFNCUtils, LCLTMSCloudCustomMyCloudData, LCLTMSFNCGraphics, Dialogs, LCLTMSFNCTypes, LCLTMSFNCBitmapContainer;
  {$ENDIF}

myCloudData

As our todolist is storing its todo items in the cloud we take advantage of our own service, that can virtually store anything we want. The initialization is done programmatically.
procedure TTODOListLogic.InitMyCloudData;
begin
  FMyCloudDataAccess := TMyCloudDataAccess.Create(nil);
  FMyCloudDataAccess.PersistTokens.Location := plIniFile;
  {$IFDEF FMX}
  FMyCloudDataAccess.PersistTokens.Key := TTMSFNCUtils.GetDocumentsPath + PthDel + 'myclouddatafmx.ini';
  FMyCloudDataAccess.OnConnected := DoConnected;
  {$ENDIF}
  {$IFDEF VCL}
  FMyCloudDataAccess.PersistTokens.Key := TTMSFNCUtils.GetDocumentsPath + PthDel + 'myclouddatavcl.ini';
  FMyCloudDataAccess.OnConnected := DoConnected;
  {$ENDIF}
  {$IFDEF LCL}
  FMyCloudDataAccess.PersistTokens.Key := TTMSFNCUtils.GetDocumentsPath + PthDel + 'myclouddatalcl.ini';
  FMyCloudDataAccess.OnConnected := @DoConnected;
  {$ENDIF}
  FMyCloudDataAccess.PersistTokens.Section := 'tokens';
  FMyCloudDataAccess.App.Key := MYCLOUDDATAKEY;
  FMyCloudDataAccess.App.Secret := MYCLOUDDATASECRET;
  FMyCloudDataAccess.App.CallBackPort := 8888;
  FMyCloudDataAccess.App.CallBackURL := 'http://127.0.0.1:8888';
end;
You might notice 3 things here. First is the TMyCloudDataAccess class which is common between FMX, VCL and LCL. This is defined earlier in our business logic as the unit names are different for FMX, VCL and LCL.
type
  {$IFDEF VCL}
  TMyCloudDataAccess = class(TAdvMyCloudData);
  {$ENDIF}

  {$IFDEF FMX}
  TMyCloudDataAccess = class(TTMSFMXCloudMyCloudData);
  {$ENDIF}

  {$IFDEF LCL}
  TMyCloudDataAccess = class(TTMSLCLCloudMyCloudData);
  {$ENDIF}
Second, is the event handler assignment, that we also need to wrap with conditional defines because LCL works with an additional @. Third is the ini file that is also created with a framework suffix, as the token and token encryption are unique per application and not shareable. After defining our business logic, it's time to setup our GUI. The form unit is shared between FMX, VCL and LCL and there you will also notice the uses list and the form file is separated with defines. After designing our form (using the TTMSFNCCheckedListBox, some tool bar buttons (TTMSFNCToolBarButton) we are ready to connect to our business logic and create a working todo list that stores its items in the cloud.
procedure TTODOListForm.DoConnected(Sender: TObject);
begin
  Panel1.Enabled := True;
  Panel2.Enabled := True;
  TMSFNCToolBarButton2.Enabled := False;
  TMSFNCCheckedListBox1.Enabled := True;
  TMSFNCToolBarButton4.Enabled := True;
  TMSFNCToolBarButton5.Enabled := True;
  TMSFNCToolBarButton6.Enabled := True;
  TMSFNCToolBarItemPicker1.Enabled := True;
  FTODOListLogic.InitializeTable;
  FTODOListLogic.Refresh;
end;

procedure TTODOListForm.FormCreate(Sender: TObject);
begin
  FTODOListLogic := TTODOListLogic.Create;
  FTODOListLogic.InitListBox(TMSFNCCheckedListBox1);
  FTODOListLogic.InitMyCloudData;
  {$IFDEF LCL}
  FTODOListLogic.OnConnected := @DoConnected;
  {$ELSE}
  FTODOListLogic.OnConnected := DoConnected;
  {$ENDIF}
  TMSFNCCheckedListBox1.BitmapContainer := TMSFNCBitmapContainer1;
  TMSFNCToolBarItemPicker1.BitmapContainer := TMSFNCBitmapContainer1;
  TMSFNCToolBarItemPicker1.Bitmaps.Clear;
  TMSFNCToolBarItemPicker1.Bitmaps.AddBitmapName('low');
  TMSFNCToolBarItemPicker1.DisabledBitmaps.Assign(TMSFNCToolBarItemPicker1.Bitmaps);
  TMSFNCToolBarButton2.DisabledBitmaps.Assign(TMSFNCToolBarButton2.Bitmaps);
  TMSFNCToolBarButton4.DisabledBitmaps.Assign(TMSFNCToolBarButton4.Bitmaps);
  TMSFNCToolBarButton5.DisabledBitmaps.Assign(TMSFNCToolBarButton5.Bitmaps);
  TMSFNCToolBarButton6.DisabledBitmaps.Assign(TMSFNCToolBarButton6.Bitmaps);

  dt := TMyDateTimePicker.Create(Self);
  {$IFDEF FMX}
  dt.Position.X := 5;
  dt.Position.Y := 40;
  {$ELSE}
  dt.Left := 5;
  dt.Top := 40;
  {$ENDIF}
  dt.Date := Now;
  dt.Parent := Panel1;
  dt.Width := 105;
end;

procedure TTODOListForm.FormDestroy(Sender: TObject);
begin
  FTODOListLogic.Free;
end;

procedure TTODOListForm.TMSFNCCheckedListBox1ItemSelected(Sender: TObject;
  AItem: TTMSFNCListBoxItem);
begin
  TMSFNCToolBarButton6.Enabled := True;
end;

procedure TTODOListForm.TMSFNCToolBarButton1Click(Sender: TObject);
begin
  FTODOListLogic.Refresh;
end;

procedure TTODOListForm.TMSFNCToolBarButton2Click(Sender: TObject);
begin
  FTODOListLogic.Connect;
end;

procedure TTODOListForm.TMSFNCToolBarButton3Click(Sender: TObject);
begin
  FTODOListLogic.DeleteItem;
end;

procedure TTODOListForm.TMSFNCToolBarButton4Click(Sender: TObject);
begin
  FTODOListLogic.AddNewItem(Edit1.Text, dt.Date, TPriority(TMSFNCToolBarItemPicker1.SelectedItemIndex));
end;

procedure TTODOListForm.TMSFNCToolBarItemPicker1ItemSelected(Sender: TObject;
  AItemIndex: Integer);
begin
  TMSFNCToolBarItemPicker1.Bitmaps.Clear;
  TMSFNCToolBarItemPicker1.Bitmaps.AddBitmapName(TMSFNCBitmapContainer1.Items[AItemIndex].Name);
  TMSFNCToolBarItemPicker1.DisabledBitmaps.Assign(TMSFNCToolBarItemPicker1.Bitmaps);
end;
When starting the application, and clicking the connect button, our business logic unit will do the work. It will create a table in myCloudData, send a notification to our GUI, which will then allow to add items to our listbox, refresh or delete existing items, and this is done with one source code, available on multiple frameworks, multiple platforms.

The full source code is available for download

Click image for more screenshots.


Windows 10 funnies

$
0
0

This isn't the first funny Windows 10 behavior I encounter that makes a developer scratch his head but I thought to share this particular one.

As it happens, here at TMS software, we quite often deal with grid related code, be it with our VCL TAdvStringGrid or FMX TTMSFMXGrid or FNC TTMSFNCGrid and when doing some testing code for our grid, why not create a new Delphi project Grid.dproj. To my surprise, compiling & running this app from the Delphi 10.1 Berlin IDE shows a funny black notification window for a moment on startup. The notification changes randomly and always informs about some shortcut keys.
My initial thought was that our grid code somehow erratically triggered something in the new Win 10 toast notification code in the Delphi 10.1 Berlin VCL. But no, even after removing our grid component, the notification kept coming. The app reduced to its minimum of an empty form with a single label shows the notification on startup.


Form at design time


Form at runtime

Then we created a new application, called Project1.dproj and surprise,... no such shortcut notification. Next logical step .. compare the grid.dproj file and the project1.dproj file to see if there was some difference in the .dproj file that could trigger this behavior. But no, no suspicious differences found.
Next we suspected a virus and therefore tested the app source on a different Windows 10 machine and the magic notification popped up again.

At that point, Google is your friend and after a quite long search, it leaded to suspect the XBox games Grid and Grid2 where Windows shows a notification of shortcuts for games. Searching the XBox store indeed reveals such game Grid and Grid2.



And yes, renaming the Delphi project to grid2.dproj will also make the notification appear for grid2.exe but not so with grid3.dproj or any other combination.

Being still intrigued by this Windows behavior, we thought that Windows 10 had perhaps some registry key that contains apps for which to show these notifications on startup, but nowhere grid.exe or grid2.exe could be found in the registry. That leaves us with the assumption that somewhere hidden in the Windows 10 source code, there must be a hardcoded reference to grid.exe and grid2.exe.
Conclusion in a nutshell: do not ship Delphi apps named grid.exe or grid2.exe to your customer if you want to avoid your customer asking questions about a weird notification coming up. :)

Delphi Cookbook 2ed for TMS FixInsight Customers

$
0
0



Delphi Cookbook 2ed by Daniele Teti is finally available. It is a best seller for PacktPub in its category, you can find more information about the book on its author blog.

I am honored to be the reviewer of the second edition. It was an exciting adventure to take a look behind the curtains of book publishing. And I have to say that Daniel did a great job.

Like any cookbook, this book is a collection of recipes. It is exactly what a "cookbook" should be. Recipes are very different - from the use of VCL styles to the drawing on a FMX ListView component, and from examples of functional programming in Delphi to importing a Java-library interface in Android. Over 60 recipes, according to the cover :)

Personally for me, the most interesting part of this book is not the essence of the recipes themselves, but the fact that the author uses all Delphi innovations when it's possible. This was very interesting to watch. Delphi has been developing very quick in recent years, and we are not always aware of how much is new in the recent versions.

I therefore recommend Delphi Cookbook primarily for those who still works with older versions of Delphi and wants to take a closer look at the innovations. Although those who work with the latest version will definetely find something to expand their horizons too. And it particularly useful as a reference book.

PacktPub was so kind to offer 50% discount on the ebook for FixInsight customers. If you order a FixInsight license in July you will get a discount coupon for the book on PacktPub website.


Introducing tag based search on TMS software website

$
0
0

Since 1995, the year Delphi was born, TMS software has been creating components and tools for developers for 21 years now and in all these years, our offerings have grown significantly. From the beginning, we have focused on VCL UI controls but soon controls for IntraWeb and .NET were added. As soon as Embarcadero introduced the cross-platform FireMonkey (FMX) framework, we started to create UI controls for this framework as well. Around the same time, a product line to help you with your business logic, the TMS Business Subscription set of products was created. Then the explosion of cloud services came and we jumped on that bandwagon with our series of cloud components to make it dead-easy to connect & consume these cloud services. Recently, our newest line of UI controls, the FNC (Framework Neutral Components) was launched where the focus is on offering you one set of components, one learning-curve and the freedom to use the controls (simultaneously or not with a single source base) for VCL Windows applications, FMX cross platform applications with Delphi or C++Builder or take a different route with the free Lazarus IDE/FPC compiler and the LCL framework to target Windows, Linux, macOS, ...

We have long lost count of the number of components we have on offer and we have been wrestling a lot with trying to present our products as logically structured, easy to find and to discover as possible. With the introduction of our new website v5.0 end of May this year, a strong focus was on organisation per technology/framework with color coding of technologies for easy recognition. In the product popup accessible from the top menu, the organisation is more semantically, grouping by themes like grids, charts, cloud, ...

But long on our todolist was also a system to tag our components and make tag based search possible this way. Well, today, I'm happy to introduce our tag based search on our website. Our tag based search is not replacing regular text based search or navigation mechanisms per technology/framework or theme. It is just one more way, one more tool to help you find what you are looking for.

Note that from now on, our products display their tags at the bottom of the product page and tag based search can be started from clicking on these tags but is also possible from the product popup or regular search started from the top right corner.

To see the tag search in action, here is a sample where a search for a treeview control is done. The word treeview can be typed or picked from the tag list. The search returns the different products, nicely color coded per technology in what products we offer a treeview control:



We hope this additional tool on our website will help you finding what you need faster. As time evolves and with your feedback, we'll further fine-tune & extend the tags. Let us know what you think about it and how you like it!

From the team with love: the new TMS Component Pack 8.3

$
0
0

We're excited to present the newest edition of the TMS Component Pack v8.3, our pack of over 400 VCL UI controls to make powerful, feature-rich Windows applications with Delphi & C++Builder.

The TMS Component Pack first version dates back from 1998 when our customers started asking for a bundle of our grid component and growing number of additional VCL UI controls developed by then.

TMS Component Pack is as such 18 years in the making and it's a relentless job to keep fine-tuning existing controls to changing needs, changing UI requirements, new UI paradigms & themes, new feature requests and add create brand new controls. Both surprising and exciting is that during all these 18 years, almost on a weekly basis, new ideas come in from you and from our team for component features and new components. A lot of our customers using TMS Component Pack UI controls are as passionate as our team about getting exactly the right look & feel, behavior and capabilities from the controls.

With this new version v8.3 we have added the usual list of new features, improvements and fixes. You can always consult this list here. One especially bigger extension was drag & drop support, sorting & filtering in our supercharged multicolumn treeview control. But in this blog, I wanted to draw your attention to new controls added in this release.

First of all, there is the new TAdvSearchList / TAdvSearchEdit.

The design of this component is inspired by new paradigms in search controls featured mostly on websites. Websites like Amazon, AliExpress, Google, Facebook, Booking.com, Trivago, ... all help the user in search by filtered suggestion lists as you type. TAdvSearchList is the basis for such list and offers a multicolumn list with optional categorized items, pictures, text and description with items, a place to show a number of search results and various criteria to find a match from first character, anywhere in a word, in text only or text and description etc...

Where the list control can be easily hooked up to a separat edit control and perform its search & filtering, the TAdvSearchEdit has the list embedded in a dropdown and it features additional optional buttons for directly filtering per categories when categories are used. It can as such be configured as a simple list to more complex and attractive looking lookup lists like this example:



Second new control added as is TAdvResponsiveList (preview).

The TAdvResponsiveList is a VCL UI control inspired by responsive design techniques and bringing this paradigm to Windows controls.As is the case with browsers, where we want to offer the best experience regardless of the browser client area size, Windows applications can also benefit from adapting the control's look & feel and behavior to the control's size to ensure the experience with your application is optimal regardless of the size of the screen of the user or regardless of a user running your application in a small window just in a corner of his desktop.



In a nutshell, TAdvResponsiveList offers a variable number of conditions that can be set for rendering its content depending on the size of the control. This can range from the number of columns depending on the width, the number or rows depending on the height, the absolute or relative size of cells when the control is resizing etc... As each cell offers rendering of HTML formatted text and this HTML formatted text can be the result of a template and in the conditions, variable templates can be set depending on the condition, i.e. size of the control. This way, more or less detail can be shown in the control item depending on its size.
But the sheer flexibility of this control becomes apparent when TAdvResponsiveList instances can be used as a child control in a TAdvResponsiveList and both parent and child can have their set of conditions. Or when you can create your own control descending from TAdvResponsiveList that can have fully custom drawn items.
A first developers guide to TAdvResponsiveList is available now. With TMS Component Pack 8.3, you can explore and start using the control from today in your applications. It is for now still marked as being in preview as this is all new to VCL application developers and we're eager to learn about your thoughts, comments, feedback, ideas & suggestions for next iterations of TAdvResponsiveList.

September ... a busy 'event' month at tmssoftware

$
0
0

We're pleased that in the month September we have again the chance to meet our customers, to show our products, to meet new developers who wishes to learn about our components & tools, ... on several upcoming events in Europe.

Bruno Fierens has also been invited as speaker, Bruno will talk about the challenges of creating cross-framework Pascal components. He will bring a session that discusses the differences between Pascal UI frameworks, how to build UI controls that can be used in the different UI frameworks and an introduction to the complex TMS FNC UI Controls that we have released so far. We will also show a sneak preview of a few brand new FNC UI controls that are currently in development.
An overview of the events:

SDN event - 2 September

Achmea Conference Center
Handelsweg 2, 3707 NH ZEIST
The Netherlands



Delphi Congrès 2016 - 15 September

FIAP
30 rue Cabanis, 75014 Paris
France



Delphi-Tage 2016 - 17 September

Mercure Hotel
Friesenstrasse 44-48, 50670 Köln
Germany



Pascal Delphi Festival 2016 - 20 September

Congrescentrum
Blokhoeve 1, 3438 LC Nieuwegein
The Netherlands



We're looking forward to see you at one of these events!

TMS FNC UI Pack beta v1.5 available now for all TMS ALL-ACCESS customers!

$
0
0

We're pleased to inform TMS FNC UI Pack beta v1.5 is available now for all TMS ALL-ACCESS customers. In this beta version we've added no less than 10 NEW components! With TMS FNC UI Pack you only need to use 1 UI control set to master application development in VCL, FMX + LCL and target 5+ different operating systems.

What's new in the TMS FNC UI Pack beta release:

  • New: TTMSFNCGridDatabaseAdapter: adapter to connect the TTMSFNCGrid to any database
  • New: TTMSFNCToolBarPopup: popup version of the TTMSFNCToolBar
  • New: TTMSFNCRichEditorEditToolBarPopup & TTMSFNCRichEditorFormatToolBarPopup: popup version of the rich editor format and edit toolbar
  • New: TTMSFNCScrollBar: fully configurable scrollbar
  • New: TTMSFNCResponsiveList: responsive design list control
  • New: TTMSFNCSearchList: multi-column list with optional categorized items, pictures and text
  • New: TTMSFNCSearchEdit: editable version of the TTMSFNCSearchList
  • New: TTMSFNCHint: application / form wide HTML formatted hints
  • New: TTMSFNCURLBitmapContainer: bitmap container with the ability to download images from an URL
  • Comes with several new demos that demonstrate various features of the 10 new components we have added in this beta version.


We're eager to hear your experiences with the beta version!

A link from where the TMS FNC UI Pack beta 1.5 version can be downloaded has been added on the 'My products' page for all TMS ALL-ACCESS users. We welcome all comments, feedback & suggestions via email.

With TMS FNC UI Pack, you can target 3 frameworks and 5+ operating systems. Therefore we hope to receive as much feedback as possible about the use of these components on several platforms (VCL Win32/Win64, FMX Win32/Win64, MacOS-X, iOS, Android, LCL Win32/Win64, Mac OS-X, iOS, Android, Raspbian, ... ) and several IDE's (Delphi XE7, XE8, 10 Seattle, 10.1 Berlin, C++Builder XE7, XE8, 10 Seattle, 10.1 Berlin, Lazarus 1.4.4 or 1.6 with FPC 2.6.4 or FPC 3.0).

We look forward to all your feedback!

TMS VCL Cloud Pack v3.7 introduces new level of seamlessness to access cloud data

$
0
0

In TMS VCL Cloud Pack v3.7, new components TAdvmyCloudDataConnection and TAdvmyCloudDataDataSet have been added. With these 2 components, access to structured data on the cloud via the myCloudData service becomes easier than ever.

TAdvmyCloudDataConnection
TAdvmyCloudDataConnection is a non-visual component that manages access to myCloudData. It works as the intermediator for the authentication and authorization to access myCloudData for one or multiple TAdvmyCloudDataDataSet instances. This means that via the TAdvmyCloudDataConnection at least a one-time authentication and authorization is done with myCloudData to obtain the access token and the TAdvmyCloudDataDataSet can then work through TAdvmyCloudDataConnection to use this access token. To let the TAdvmyCloudDataDataSet use the connection is as simple as assigning the TAdvmyCloudDataConnection instance to TAdvmyCloudDataDataSet.Connection, just like we are used to assign a TADOConnection to a TADOTable for example.


TAdvmyCloudDataDataSet
TAdvmyCloudDataDataSet is a wrapper as a dataset of a table in the myCloudData service. When a connection is provided, set either the name of the table via the Table property or the unique ID of the table via the TableID property. When a connection has been made (i.e. access token was obtained), setting the property TAdvmyCloudDataDataSet.Active to true will fetch the table data from the myCloudData table and present it as a TDataSet through a TDataSource to any DB-aware component in VCL or via LiveBindings in FireMonkey applications. Note that this approach works both at run-time and design-time, so we can work with the cloud data at design-time to configure our DB-aware controls connected to it.


Dataset filter
An easy way is provided to perform basic dataset filtering. The TAdvmyCloudDataDataSet has a filter property which is presented as a collection of filter conditions. The filter condition consists of a field name, filter value, a filter condition logical operator and a filter comparison operator. The filter condition can be easily set at design-time where the dataset field can be picked and the values set.



From here we can work with the cloud data in much the same way from our code on the dataset as Delphi developers have been doing all the time with datasets, i.e. insert, delete, update records.

Rich metadata
But with the updated myCloudData service, there is much more than this possible as myCloudData now offers rich metadata for its structured data. This rich metadata can be programmatically accessed, created and updated but also easily configured via the myCloudData web interface. We'll cover this in a follow-up blog focused on how we can benefit from this rich metadata, but here you can already glance over the web interface you can access from your myCloudData account:


You can explore all this with a free myCloudData account. Create a new table via this account and you can use our TAdvmyCloudDataDataSetDemo application included in TMS VCL Cloud Pack to explore this.

Stay tuned for more!


Delphi and iPhone helping vision impaired people

$
0
0

We released earlier this week a major update of the TMS FMX Cloud Pack. This new version adds a lot of new components covering seamless access to all kinds of interesting cloud services. Among the new services covered, two services from Microsoft stand out and open up new ways to enrich our Delphi applications with cool features. In this blog, I wanted to present the Microsoft Computer Vision and Microsoft Bing speech service. Our new components TTMSFMXCloudMSComputerVision and TTMSFMXCloudMSBingSpeech offer instant and dead-easy access to these services. Powered with these components, the idea came up to create a small iPhone app that let's vision impaired people take a picture of their environment or a document and have the Microsoft services analyze the picture taken and let Microsoft Bing speech read the result.

So, roll up your sleeves and in 15 minutes you can assemble this cool iPhone app powered with Delphi 10.1 Berlin and the TMS FMX Cloud Pack!
To get started, the code is added to allow taking pictures from the iPhone. This is a snippet of code that comes right from the Delphi docs. From a button's OnClick event, the camera is started:

  if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService,
    Service) then
  begin
    Params.Editable := True;
    // Specifies whether to save a picture to device Photo Library
    Params.NeedSaveToAlbum := false;
    Params.RequiredResolution := TSize.Create(640, 640);
    Params.OnDidFinishTaking := DoDidFinish;
    Service.TakePhoto(Button1, Params);
  end
When the picture is taken with the camera, the DoDidFinish() method is called, so we need to add the code there to deal with the image taken. We'll cover that in a moment. Let's first setup now the TMS FMX Cloud Pack components TTMSFMXCloudMSComputerVision and TTMSFMXCloudMSBingSpeech to consume the needed cloud services. You can download the components from the TMS FMX Cloud Pack page. After installing, over 60 new cloud service components will be added to your tool palette. It will be needed to get an API key to be allowed using these Microsoft services. Go to https://www.microsoft.com/cognitive-services/ and signup for free for the computer vision API and Bing speech API and you'll receive an API key for each. In the app, two constants are used and the component's app key property is initialized when the app starts:

procedure TForm1.FormShow(Sender: TObject);
begin
  TMSFMXCloudMSBingSpeech1.App.Key := MSBingSpeechAppkey;
  TMSFMXCLoudMSComputerVision1.App.Key := MSComputerVisionAppkey;
end;
Now that these components are also ready to be used, let's complete the DoDidFinish() method that is triggered when the picture is taken. This method returns the image taken. This image is saved locally and will be submitted to the Microsoft computer vision API for analysis. In the app, we added via a radiobutton the choice between regular image analysis or OCR.


So, a TTask is used to start this analysis with the call TMSFMXCLoudMSComputerVision1.ProcessFile(s, cv). A TTask is used to avoid that the UI is locked during this analysis, after-all, the image must be submitted to Microsoft, processed and the result returned and parsed, so this can take 1 or 2 seconds. Depending on the analysis type, the result is captured as text in a memo control. After this, we connect to the Bing speech service.

procedure TForm1.DoDidFinish(Image: TBitmap);
var
  aTask: ITask;
  s: string;
  cv: TMSComputerVisionType;
begin
  CaptureImage.Bitmap.Assign(Image);

  // take local copy of the file for processing
  s := TPath.GetDocumentsPath + PathDelim + 'photo.jpg';
  Image.SaveToFile(s);

  // asynchronously start image analysis
  aTask := TTask.Create (procedure ()
    var
      i: integer;
    begin
      if btnAn0.IsChecked then
        cv := ctAnalysis;
      if btnAn1.IsChecked then
        cv := ctOCR;

      if TMSFMXCLoudMSComputerVision1.ProcessFile(s, cv) then
      begin
        Description := '';

        if cv = ctAnalysis then
        begin
          // concatenate the image description returned from Microsoft Computer Vision API
          for I := 0 to TMSFMXCLoudMSComputerVision1.Analysis.Descriptions.Count - 1 do
          begin
            Description := Description + TMSFMXCLoudMSComputerVision1.Analysis.Descriptions[I] + #13#10;
          end;
        end
        else
        begin
          Description := TMSFMXCLoudMSComputerVision1.OCR.Text.Text;
        end;

        // update UI in main UI thread
        TThread.Queue(TThread.CurrentThread,
          procedure ()
          begin
            if Assigned(AnalysisResult) then
              AnalysisResult.Lines.Text := Description;
          end
          );
        TMSFMXCloudMSBingSpeech1.Connect;
      end
      else
      begin
        // update UI in main UI thread
        TThread.Queue(TThread.CurrentThread,
          procedure ()
          begin
            AnalysisResult.Lines.Add('Sorry, could not process image.');
          end
          );
      end;
    end
    );

  aTask.Start;
end;
In the TMSFMXCloudMSBingSpeech.OnConnected event, we can then send the text for speech synthesis to the Microsoft service and as a result we retrieve an audio stream that is then played through the device.

procedure TForm1.TMSFMXCloudMSBingSpeech1Connected(Sender: TObject);
var
  st: TMemoryStream;
  s: string;
begin
  st := TMemoryStream.Create;
  s := AnalysisResult.Lines.Text;
  try
    TMSFMXCloudMSBingSpeech1.Synthesize(s, st);
    TMSFMXCloudMSBingSpeech1.PlaySound(st);
  finally
    st.Free;
  end;
end;
So, it doesn't take much more than this to enhance the life of vision impaired people a little and let the iPhone read out what is around them or help with reading documents.

Now, let's try out the app in the real world. Here are a few examples we tested.

Using the app on the road to read road signs and capture car license plates

Trying to figure out what we see in a showroom

First the app analyzed correctly this is a bottle of wine in the cellar and is then pretty good at reading the wine bottle label.

You can download the full source code of the app here and have fun discovering these new capabilities.
Enjoy!

TMS Aurelius Free Edition now available for download!

$
0
0

We're happy to announce that TMS Aurelius, our highly regarded ORM (Object Relational Mapping) framework for Delphi, has now a Free Edition.

And the best part is that TMS Aurelius Free Edition has all the features that are available in the paid registered license. Not only that, but it also allows you to use it in commercial applications. So in the sense of features and usage, there is absolutely no difference in what you can use and what you can do with it compared with paid version.

The only differences are that Free Edition is only available for Delphi 10.1 Berlin, in binary format. The paid license is available for earlier versions of Delphi, comes with full source code and, of course, includes what we consider the biggest "feature" of all: it gives you high priority to our top-notch and fast support.

You can register for downloading TMS Aurelius Free Edition right now! The linked page also includes the FAQ and full table comparing the free and paid version. We hope you enjoy it!

Rich metadata helps auto-generated Delphi forms for entry of data in the cloud

$
0
0

The myCloudData.net service offers easy to use structured cloud data storage. The foundation of the service is of course a REST API. But meanwhile, we added several components for Delphi users to consume this service with an absolute minimum amount of effort. The first step was to create the component TAdvmyCloudData that is part of the TMS VCL Cloud Pack, TMS FMX Cloud Pack, TMS LCL Cloud Pack (and soon also in TMS .NET Cloud Pack). The TAdvmyCloudData component enables using object oriented programming techniques for using the myCloudData.net service. In a second step, we introduced the TAdvmyCloudDataDataSet and TAdvmyCloudDataDataConnection. With these components, controls can be bound directly to the data in the cloud, be it via DB-aware controls or livebindings.

But now, we are excited to introduce the next level of automation: bound DB forms auto generated with the help of rich metadata. Two new components are available for this: TAdvmyCloudDataFormPanel and TAdvmyCloudDataFormBox. These components are similar but the TAdvmyCloudDataFormBox offers a possible scrolling area when this is needed and a header from where editing in the DB form can be started, stopped or cancelled.

When the TAdvmyCloudDataFormPanel or TAdvmyCloudDataFormBox is connected to a TAdvmyCloudDataSet via a TDataSource, it retrieves the DB field information exposed by the TDBField type in the dataset but in addition, it retrieves the rich metadata that myCloudData.net offers. The meta data that can be set include: label, min/max values, edit mask, field lookup relation, typed values, visible, enabled ...

In this screenshot, you can see how the integer field STATUS is defined as a typed field. For typed fields, the DB form will use a combobox and this combobox will automatically map the integer data value for the selected displayed value.


The best experience is offered for the default mapping of DB field types to TMS Component Pack controls. TMS Component Pack includes a DB-aware Date+Time input control (i.e. combined date and time entry in a single control), a DB-aware combobox with a separate display and value list with binding to the value part, edit controls with built-in features to limit what can be entered etc...

The default mapping to TMS controls as such is:

boolean field: TDBCheckBox
string field: TDBAdvEdit or TDBAdvMaskEdit
integer field: TDBAdvSpinEdit
floating point field: TDBAdvSpinEdit
typed field: TAdvDBFormComboBox or TDBRadioGroup
blob picture field: TDBAdvGDIPPicture
blob rich text field: TDBRichEdit
date field: TAdvDBDateTimePicker
time field: TAdvDBDateTimePicker
date/time field: TAdvDBDateTimePicker
lookup field: TDBLookupComboBox
disabled field: TDBAdvLabel

Note that via TAdvmyCloudDataFormPanel.Layouter there is access to the class mapper and thus, a custom mapping of a field type to a different control can be done.

This is not all, not only does the metadata control how the DB form is rendered, there are also many parameters that control the behavior of the layout engine for the DB form. This includes control widths, what control types to use for what DB field types, number of columns to use, position of control labels, how to render DB field descriptions, padding, spacing, margins, fonts, what to do with readonly fields and more ...



It can also be used to change layouting on the fly. In the demo, this technique is used to let the layout switch between DB field descriptions rendered as extra labels or rendered as hints for the DB control hints:

begin
  AdvmyCloudDataDataSet1.DisableControls;

  AdvmyCloudDataFormPanel1.Layout.BeginUpdate;

  if ckDescr.Checked then
  begin
    AdvmyCloudDataFormPanel1.Layout.Descriptions.Kind := dkHint;
    ckDescr.Caption := 'Description as label';
  end
  else
  begin
    AdvmyCloudDataFormPanel1.Layout.Descriptions.Kind := dkLabel;
    ckDescr.Caption := 'Description as hint';
  end;

  AdvmyCloudDataFormPanel1.Layout.EndUpdate;

  AdvmyCloudDataDataSet1.EnableControls;
end;
When the myCloudData table and its metadata is combined with the parameters for the layout engine, the result of the generated DB form in a Delphi VCL application is:


The only code needed here is to make the connection to the cloud service, i.e. setup the application key & secret, the persistence config for the access token and a single line of code to make the connection active. If we would now make an update to the database schema or its metadata and reconnect, the DB form will be automatically adapted to the new settings without having to write any code or without needing to deploy a new application executable.

Getting started

You can signup for a free subscription to the myCloudData.net service. Then, our two products TMS Cloud Pack and TMS Component Pack will get you started. TMS Cloud Pack comes with the TAdvmyCloudDataDataSet and TAdvmyCloudDataDataConnection components. The latest version of the TMS Component Pack includes TAdvmyCloudDataFormPanel and TAdvmyCloudDataFormBox as well as a demo app. We are eager to learn how you enjoy new levels of automation in your apps but even more about all your feedback & suggestions to make this technology even more powerful.

Introducing Sergey Gladkiy and TMS Analytics & Physics Pack

$
0
0

It's always a privilege and honour to be able to work with very smart people who are not only expert in Delphi but also expert in a specific domain. Earlier this year, Bernard Roussely and Marion Candau joined tmssoftware.com and focus so far on advanced cryptography algorithms with the highest security levels in TMS Cryptography Pack. More tools that will use this underlying strong technology are already in the pipeline. Around the same time, also Roman Yankovsky joined tmssoftware.com and the static code analysis tool TMS FixInsight is the result. With TMS FixInsight, you can bring your Delphi code to a higher quality & safer level with numerous code hints and suggestions it gives.
Today, I'm proud to announce Sergey Gladkiy joins the TMS team for working on products with a strong mathematical background. The first result is the TMS Analytics & Physics Pack. This pack offers a set of (non-visual) platform independent classes to work with mathematical expressions and units of measurements. In TMS Analytics & Physics Pack, you can do evaluation of complex multiparameter mathematical expressions, including expressions with complex numbers. You can do physical measurement conversions of all kinds. But perhaps the most amazing part is symbolic derivative calculations. In this respect, TMS Analytics & Physics Pack brings a math wizard in the form of classes that can be used in VCL and FMX apps. You can discover the power of this library via the included demo but I wanted to share some examples of symbolic derivative calculations that will boggle your mind:

Task: calculate the derivative function of:
1/(x-1)+(2*x-1)/(x+1)^2

Result:
(-(1)/(x-1)^2)+(2*(x+1)^2-(2*(x+1)^(2-1))*(2*x-1))/((x+1)^2)^2

The code to achieve this is as simple as:

var
   f,df: string;

   f := '1/(x-1)+(2*x-1)/(x+1)^2';

   try
      if Translator.CheckSyntax(f) then
      begin
        df:=Translator.Derivative(f,'x');
        ShowMessage('Derivative function :' + df);
      end;
   except
      ShowMessage('Error');
   end;
Let's take another example with some trigonometric mathematical functions:

Task: calculate the derivative function of:
(sin(x)+cos(x))/x

Result:
((cos(x)+(-sin(x)))*x-(sin(x)+cos(x)))/x^2

The resulting derivative expression can then be evaluated, for example against x=2:
var
   df: string;
   v: TValue;

   df := '((cos(x)+(-sin(x)))*x-(sin(x)+cos(x)))/x^2';

   try
      Translater.Add('x', 2.0); 
      if Translator.CheckSyntax(df) then
      begin
        v :=Translator.Calculate(df);
        ShowMessage('Result :' + s:=TUtilities.SafeToString(v));
      end;
   except
      ShowMessage('Error');
   end;
The result of this calculation is: -0,786009779256047.

I kindly invite you to explore our new TMS Analytics & Physics Pack. A fully functional trial version is available and the registered versions comes with full source code. We're eager to learn in what kind of exciting and cool applications these powerful classes will find a place!

TEncryptedIniFile: easy to use class for handling app settings with encryption

$
0
0

What's wrong with the KIS principle to store application settings in an INI file? The risk that someone is tampering with the INI file is an often heard reason for not using them. Not being able to store private or secret information another one.
Both issues are solved with the introduced TEncryptedIniFile class. It descends from TMemIniFile and is as such a drop-in replacement and will deal only in app memory with decrypted data. In the file itself, the data is at all times encrypted. To build TEncryptedIniFile, we internally use AES 256bit encryption offered by the TAESEncryption class in TMS Cryptography Pack.

The code to use TEncryptedIniFile becomes something like:

const
  aeskey = 'anijd54dee1c3e87e1de1d6e4d4e1de3';
var
  mi: TEncryptedIniFile;
begin
  try
    mi := TEncryptedIniFile.Create('.settings.cfg', aeskey);
    try
      FTPUserNameEdit.Text := mi.ReadString('FTP','USER','');
      FTPPasswordNameEdit.Text := mi.ReadString('FTP','PWD','');
      FTPPortSpin.Value := mi.ReadInteger('FTP','PORT',21);
      mi.WriteDateTime('SETTINGS','LASTUSE',Now);
      mi.UpdateFile;
   finally
      mi.Free;
   end;
  except
    ShowMessage('Error in encrypted file. Someone tampered with the file?');
  end;
end;
Of course, the weakness now is that the AES key is in the EXE file and as such, it won't stop seasoned hackers to extract it from the EXE and use it directly to decrypt/encrypt the settings file and tamper with it this way. Extra steps could be taken to use an AES key that is a combination of a unique machine ID and a part that is encrypted with a Ed25519 generated public key and decrypt the encrypted part of the AES key on the fly in the app with the Ed25519 private key and then use it in combination with the machine ID to encrypt/decrypt the INI file. That should make the effort to hack the settings file already a lot more difficult.

To start using this TEncryptedIniFile you can get TMS Cryptography Pack and you can download the TEncryptedIniFile class source here.


TMS online videos presented at CodeRage XI

$
0
0

During CodeRage XI, the online event from Embarcadero, Bruno Fierens (founder TMS software and Embarcadero MVP), Wagner Landgraf (TMS Business product manager) & Roman Yankovsky (TMS FixInsight product manager and Embarcadero MVP) brought sessions covering our latest technologies FNC, myCloudData, Aurelius, FixInsight developed at TMS software.

If you missed one of these sessions, you can now watch them via our Youtube channel.

New video's published at tmssoftwareTV:
Cross Framework UI Controls - by Bruno Fierens: This session explains the differences between the VCL and FMX framework that are relevant for custom user interface control development. Given these differences, an abstraction layer, FNC is presented that enables creating custom user interface controls starting from a single source code base that can be used for both VCL, FMX (and LCL) applications. In the last part of the session, several complex FNC UI controls that are in the TMS FNC UI Pack product are demonstrated that can be used in VCL, FMX, LCL applications and target this way Windows, iOS, Android, macOS and Linux.



Metadata assisted automatic DB form generation for cloud data - by Bruno Fierens: The myCloudData.net service offers easy to use structured cloud data storage. The foundation of the service is a REST API. For our Delphi users, we added several components to consume this service with an absolute minimum amount of effort. The TAdvmyCloudData component enables using object oriented programming techniques for using the myCloudData.net service. With TAdvmyCloudDataDataSet and TAdvmyCloudDataDataConnection, controls can be bound directly to the data in the cloud, be it via DB-aware controls or livebindings. For the next level of automation: bound DB forms auto generated with the help of rich metadata, two components are available, TAdvmyCloudDataFormPanel and TAdvmyCloudDataFormBox.



TMS Aurelius Free Edition, an overview - by Wagner Landgraf: An overview of the well-regarded Aurelius ORM framework for Delphi, which now has a free edition for commercial use, available for Delphi 10.1 Berlin.



FixInsight: Finding Bugs with Static Code Analysis - by Roman Yankovsky: Roman Yankovsky shows you how to use FixInsight's static code analysis in Delphi to find bugs in your code before your customers do. Roman Yankovsky is an Embarcadero MVP and the author of FixInsight static analysis tool for Delphi.



My Top 10 Aurelius Features - Introduction

$
0
0

After the release of TMS Aurelius Free Edition, the free version of our ORM framework, I've been thinking to do some blog posts about some key TMS Aurelius features. However I spent some time deciding what features to show: would they be in chronological order? Separated by categories? In order of "importance" - and what would be the criteria of "importance"?

Well, finally, as you can tell from the title of this post, I decided to do that in a "top 10 list" format - who knows, maybe this series will appear at Buzzfeed... But most important of all: this is my personal list of favorite features. So no objective criteria here - just some features I consider cool, features that I have "respect" for because were hard to implement or simply features that I use a lot.

So let's go for the list. Starting with #10, I will keep adding new blog posts over time until I reach feature #1. Hope you enjoy it:

#10 - Automapping
#9 - Plain Old Delphi Objects
#8 - Lazy Loading



My Top 10 Aurelius Features - #10 Automapping

$
0
0

This is the #10 feature of My Top 10 Aurelius Features. Follow the link for the full list!

Using the automapping feature is easy: you just need to add the [Automapping] attribute to your class:

type
  [Entity, Automapping]
  TCustomer = class
  private
    FId: Integer;
    FName: string;
  public
    property Id: Integer read FId write FId;
    property Name: string read FName write Name;
  end;

and it will automatically map the class to the database using some conventions. This prevents you from having to manually use the mapping attributes like Column, Table, Id, etc., to tell Aurelius exactly how the database schema will be.

If you already have an existing database, this is not very useful since the convention used by it will probably not match your existing database. But when you do the code-first approach (my favorite) - where you start your application creating the classes, not the tables - this is very handy.

Besides the obvious fact that Automapping speeds up the development process (prototyping is really fast with it), what I really like about Automapping is how it makes you forget about the database and think only about classes: you just don't remember you have a table or a column somewhere in the database - let Aurelius chooses whatever it needs for the underlying database, and focus on your code.

Another interesting thing is that it's not an all-or-nothing feature: you can have use the Automapping attribute but still override it with specific mapping attributes - so you get the best of both worlds: convention with flexibility:
type
  [Entity, Automapping]
  TCustomer = class
  private
    FId: Integer;
    [Column('CUSTOMER_NAME', [TColumnProp.Required], 120)]
    FName: string;
  public
    property Id: Integer read FId write FId;
    property Name: string read FName write Name;
  end;

And to conclude, here is a small video (~4 min) showing Automapping usage:



Weekend fun with Delphi, math and FNC

$
0
0

Mathematics is fascinating, Delphi is cool, cross-platform is awesome, cross-framework is the icing on the cake. So, what's better than spending some time with all four on a weekend day?

For some time, we offer our TMS Analytics & Physics package that can do formula evaluation, complex number calculation and most interestingly also expression based derivative function calculation. Also since beginning of 2016, we offer our TMS FNC Chart, which is a chart package that offers a chart UI component that can be used in VCL applications, FMX applications and also LCL (Lazarus/FPC based) applications. This means that with the TMS FNC Chart, we can target Win32, Win64, macOS, iOS, Android, Linux, Raspbian operating systems.

So, I set out this weekend to spend some time creating a simple mathematical formula plotting application (cross platform & cross framework) that could not only display a function but also calculate its derivative function and plot it. This way, we can visually see the effect of calculating a derivative function.
The setup of this application turns out to be amazingly simple with some help of TMS FNC Chart and TMS Analytics & Physics Pack.

The core code is a model class that does chart initialization & formula calculation + derivative calculation by means of two class methods. This model can be used by the VCL, FMX or LCL application as apart from unit references, all code is framework independent. In this model, calculation is central and is nothing more than performing parsing of a mathematical formula and calculating it's derivative and Y-values for a range of X-values and display this in a chart. To do this, we initialize the TTranslator class (part of TMS Analytics) and specify the X is the main variable of the functions we can write and then we check the syntax, calculate the derivative and calculate values for both function and derivative function:

  FTransMain := TTranslator.Create;
  FTransDeriv :=  TTranslator.Create;

  vName := 'x';
  vValue := 1.0;
  FTransMain.Add(vName, vValue);
  FTransDeriv.Add(vName, vValue);

  try
    if FTransMain.CheckSyntax(f) then
    begin
      df := FTransMain.Derivative(f,'x');

      if FTransDeriv.CheckSyntax(df) then
      begin
        for i := -xrange to +xrange do
        begin
          // get Y value of the function for a given X value
          FTransMain.Variables['x'].Value := i;
          v := FTransMain.Calculate(f);
          // add the Y point to the XY chart series 1
          AChart.Series[0].AddXYPoint(i,v.AsExtended);

          // get Y value of the derivative function for a given X value
          FTransDeriv.Variables['x'].Value := i;
          v := FTransDeriv.Calculate(df);
          // add the Y point to the XY chart series 2
          AChart.Series[1].AddXYPoint(i,v.AsExtended);
        end;
      end;
    end;
  finally
    FTransMain.Free;
    FTransDeriv.Free;
  end;
This is the core code responsible for coming to a result for a function like sin(x)+1/4*cos(x*10) that you can think of as mathematical basis for modulation techniques.

FMX version of the Math Explorer app running on macOS

Of course, the intention of the math exploring application is that you can enter any other mathematical function of X and not only see the derivative function but also plot it in the chart. Download & install TMS Analytics & Physics and TMS FNC Chart and then compile and run the VCL or FMX version of the math explorer application you can download with full source code.

My Top 10 Aurelius Features - #9 Plain Old Delphi Objects

$
0
0

My number 9 feature of My Top 10 Aurelius Features refers to PODO - Plain Old Delphi Objects. Or in other words, the fact that Aurelius entities are simple, clean Delphi classes.

When Aurelius project started back in mid 2011, there were some object persistent frameworks available for Delphi. At that time I was wondering why such existing ones did not catch up strongly.

There were some people using it, but I didn't feel it was something that people were embracing. And one of the reasons (in my opinion) was that to make classes to become persistent the developer needed to do some many workarounds that the class end up being cluttered with unneeded things, and coding with that class was not very pleasant.

Imagine writing business code with the class below:

type
  TContact = class(TORMBaseClass)
  private
    FId: TORMInteger;
    FName: TORMString;
    FCountry: TORMRelationship;
    function GetId: TORMInteger;
    procedure SetId(const Value: TORMInteger);
    function GetName: TORMString;
    procedure SetName(const Value: TORMName);
    function GetCountry: TORMRelationship;
    procedure SetCountry(const Value: TORMRelationship;
  public
    constructor Create(SpecificParams: TORMINit); override;
    destructor Destroy;
    procedure Save(Context: TORMContext); override;
    procedure Update(Context: TORMContext); override;
    procedure Delete(Context: TORMContext); override;
  published
    property Id: TORMInteger read GetId write SetId;
    property Name: TORMString read GetName write SetName;
    property Country: TORMRelationship read GetCountry write SetCountry;
  end;

And compare to using this class when writing your code:
type
  TContact = class
  private
    FId: integer;
    FName: string;
    FCountry: TCountry;
  public
    property Id: integer read FId write FId;
    property Name: string read FName write FName;
    property Country: TCountry read FCountry write FCountry;
  end;

The first code is not specific to any other persistent framework. Actually, it's really fake, it's just a combination of ideas and solutions used by several frameworks I've seen over the years. The fact that you have to inherit from a base class, override base methods in it, have a constructor implemented that initialize mappings manually, use framework-specific types instead of primitive Delphi types, and the list goes on.

Finally, having clean, pure Delphi classes allow you to extend them, like creating non-persistent properties, using pure object references to represent associations, etc. The following video gives slightly more details about that.




Introducing the myCloudData REST Client for Delphi & C++Builder

$
0
0

We are very excited to announce the launch of our new open-source myCloudData.net REST client for Delphi & C++Builder. The myCloudData REST Client is completely free and open-source and hosted on Github, this means that you can freely use or customize the code for your commercial or hobby projects.

Our goal was to provide you with an easy way of using the myCloudData.net service in all your applications, without having to worry about all the difficulties that come with integrating with a complex REST service.

The myCloudData REST Client takes care of handling the HTTP requests, the parsing of the JSON responses and the OAUTH2 authentication. All you have to do is drag the component on to your form and you can start using your cloud databases as they were local databases.

The library is developed from the ground up and is based on the REST technology that is included in RAD Studio 10.1 Berlin. It can be used with your Delphi, C++Builder, RAD Studio 10.1 Berlin IDE as-is, no need to install extra commercial libraries. There is a REST client for VCL applications (for Win32/Win64) and FMX applications (for Win32/Win64/iOS/macOS/Android)

To get you started, here are some highlights of commonly used patterns in consuming structured cloud data storage via myCloudData.net.

Some simple code examples

Creating a table

Typically, at the startup of your application, you'll want to check if the table you want to work with already exists on the current myCloudData account. The code example below does just that, it looks for the table on the Tables property of the myCloudData component and if it isn't found it will create the table with all the necessary fields.
var 
LContactsTable : TmyCloudDataTable;
begin
    // Search for an existing table
    LContactsTable := MyCloudData.Tables.GetTableByName('MyApplication_Contacts');

    if LTableName = nil then
    begin
        // Create the table
        LContactsTable := MyCloudData.Tables.CreateTable('MyApplication_Contacts');

        // Start adding your fields:
        LContactsTable.Fields.Add('ID', ftInteger);
        LContactsTable.Fields.Add('Name', ftWideString, 30);
        LContactsTable.Fields.Add('EmailAddress', ftWideString, 50);
        LContactsTable.Fields.Add('CountryCode', ftWideString, 2);

        // Save the fields to the myCloudData.net service
        LContactsTable.Fields.Save();
    end;

    // You can start working with the table here.

end;

Working with the entities

Once you have your table, let's add some data to it. The next example shows how you can insert a new entity and populate its fields.
var
LContact : TmyCloudDataEntity;
begin
    // Create the new entity on the table
    LContact := LContactsTable.Entities.CreateEntity();

    // Populate the fields on the entity
    LContact.SetValue('ID', 285);
    LContact.SetValue('Name', 'John Doe');
    LContact.SetValue('EmailAddress', 'johndoe@gmail.com');
    LContact.SetValue('CountryCode', 'USA');

    // Save the entity to the myCloudData.net service
    LContactsTable.Entities.Save;
end;

The following code shows you how to query the table and retrieve existing entities.
// Optionaly set the page size and index
LContactsTable.PageSize = 20;
LContactsTable.PageIndex = 0;

// Optionaly add one or more filter conditions
LContactsTable.Filters.Add('Name', coLike, 'John'); 
LContactsTable.Filters.Add('Email', coEndsWith, 'gmail.com', loAnd); 

// Optionaly add one or more sorting statements
LContactsTable.Sorting.Add('Company', soAscending); 
LContactsTable.Sorting.Add('Name', soDescending); 

// execute the query
LContactsTable.Query();

// now you can use the result of that query by accessing the Entities property
for LContact in LContactsTable.Entities do
begin
    ContactsListBox.items.Add(LContact.GetValue('Name'));
end;

Blobs

All the above examples work for both the free and the subscription accounts on myCloudData.net.
However, working with blob fields requires you to be connected with a subscription account.
To avoid unexpected behaviour, you'll always want to check if the current user can use the blob feature before actually creating or using a blob field.

This example shows how you can create a blob field in a table.
// Check if the current user can use blob fields
if MyCloudData.CurrentUser.CanUseBlobFields; then
begin
    // Add the field to the table
    LContactsTable.Fields.AddOrUpdate('Picture', ftBlob);
end;

Saving a new file to the blob field can be done as follows.
var
LPictureField : TmyCloudDataBlob;
begin
    // Fetch the Entities on the table
    LContactsTable.Query();

    // Get an entity by its ID
    LContact := LContactsTable.Entities.GetEntity(LEntityId);

    // Get the blob field 
    LPictureField := LContact.GetBlobField('Picture');

    // Save a new image
    LPictureField.FromFile('c:path	oyourimage.jpg');
end;


We invite you to start experimenting with these new free REST client components and we are very eager to learn how these will be used to build your creative & amazing apps with myCloudData.net and RAD Studio 10.1 Berlin.
Please take a look at the Github repository and let us know what you think!

Live Now: Intensive Delphi 2016 - The biggest online Delphi event in Brazil, for free!

$
0
0

(Este link em português)

Intensive Delphi 2016 is happening right now. It's the biggest online Delphi event in Brazil, and it's free for everyone! Already started on Monday, 19th and going on until 24th, it's six days full of sessions about the most different topics: Mobile development, Rest/JSON servers, Firemonkey, VCL, Beacons, Arduino, best practices, and many many more.

To access the conference, use the follow link: Intensive Delphi 2016 Official Link



Each day starts as early as 8 am local brazilian time, and goes on until up to 10 pm at night. Outside the official schedule for session streaming, sessions replays are provided in those alternative schedules. The chat windows is available for you to interact with speakers at specific session times, specially at night (brazilian time).

There will be sessions available in both Portuguese (most of them) and English.

More than 25 speakers and counting will be present at conference, including Marco Cantu, Jim Mckeeth and, from TMS Software, Wagner Landgraf with a session about TMS Business product line. The TMS Business session schedule is Thursday, 22th, 8 pm brazilian time (UTC-02:00) and Wagner will chat with attendees. Here is the full list of speakers in alphabetical order:

Adriano Santos
Alan Glei
Alan Victor (Bruto do Delphi)
Alister Christie
Amarildo Lacerda
Boian Mitov
Carlos Agnes (Tatu)
Emanoel Deivison
Jackson Gomes
Jim Mckeeth
Jonatan Souza
Jorge Eduardo
Kelver Merlotti
Kleberson Toro
Laercio Guerco
Landerson Gomes
Marco Cantu
Marcos Moreira
Marcus Vinicius
Mauricio Abreu
Newton Oliveira
Regys Silveira
Ricardo Boaro
Rodrigo Mourao
Samuel "Muka" David
Thulio Bittencourt
Wagner Landgraf (TMS Software)


Viewing all 1008 articles
Browse latest View live