Knowledge Base Alert September, 2017








TMS TAdvSpreadGrid:

Using the expression parser / evaluator



The expression parser / evaluator of TAdvSpreadGrid, our spreadsheet component , can also be separately used. This expression evaluator is in the unit AdvFormula.

To use it, create an instance of the class TAdvFormula and it can be used in the following way:

var
  Fm : TAdvFormula;
  R: double;
begin
  Fm := TAdvFormula.Create(self);
  try
    Fm.Expression := '1+2';
    if Fm.Calc(r) then
       showmessage(floattostr(r));
  finally
    Fm.Free;
end;
The expression parser / evaluator also has 100 internal variables (V0..V99) and this can be used in the following way:

var
  Fm : TAdvFormula;
  R: double;
begin
  Fm := TAdvFormula.Create(self);
  try
    fm.v[0] := 12;
    fm.v[1] := 25;
    Fm.Expression := 'V0+V1';
    if Fm.Calc(r) then
       showmessage(floattostr(r));
  finally
    Fm.Free;
  end;
end;

TMS TFormSize:

Set the name of the registry for TFormSize programmatically



TFormSize will normally automatically load the persisted settings before the form‘s OnCreate event is triggered, so there is no chance to programmatically change the FormSize properties in code before the settings are loaded.

So, to achieve what you want to do, set FormSize.SavePosition = false & FormSize.SaveSize = false end then, in the form’s OnCreate event, first set FormSize.SaveName and after that, set FormSize.SavePosition = true & FormSize.SaveSize = true and then call FormSize.LoadFormSettings.

TMS FlexCel for VCL & FMX:

Using strict xlsx files



TMS FlexCel v6.17 introduced full support for reading and saving strict xlsx files. Strict xlsx files are a different file format from normal xlsx files, and you can select them when doing a "File Save As..." in Excel:

Now the question is: Should I use normal or strict xlsx files? And the short answer is: Use normal xlsx files unless you have a non negotiable requirement from your customers to use strict xlsx.

The long answer can be found here.

TMS FlexCel for VCL & FMX:

Finding out which FlexCel version you are using



Sometimes you want to know the exact FlexCel version you are using from inside your app, and you might also want to make sure you aren't using a trial. You can use the following code to find out:

  //The FlexCelIsTrial constant in FlexCel.Core is true if this version is a trial
  if FlexCelIsTrial then WriteLn('ERROR: This is a trial version of FlexCel!');

  //The FlexCelVersion constant in FlexCel.Core contains the current version.
  WriteLn(FlexCelVersion);

TTMSFMXRichEditor:

Load RTF via a stream in TTMSFMXRichEditor



The TTMSFMXRichEditorRTFIO allows to load RTF from a file. It is also possible to directly load RTF from a stream though in the following way:

var
  ss: TStringStream;
  s: string;

begin
  ss := TStringStream.Create;
  try
    ss.LoadFromStream(yourstream);
    s := ss.DataString;
    TMSFMXRichEditor.InsertAsRTF(s);
  finally
    ss.Free;
  end;
end;

TMS FMX WebGMaps:

Detect an action that will navigate away from the map on Android or iOS



By using the OnBeforeNavigate event it's possible to detect an action that will navigate away from the map on Android or iOS. If required the action can also be cancelled.

Example:

procedure TForm1.TMSFMXWebGMaps1BeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL = 'https://www.google.com' then
    Params.Cancel := true;
end;

TMS FMX Cloud Pack:

Enable external browser support for Google services



Note that the OAuth requests to Google API services from embedded browsers are no longer allowed. More info can be found here: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html?m=1

From now on authentication for Google API services will happen via an external browser window.
A new property ExternalBrowser was added to activate this feature. On Windows and Mac platforms this will work automatically. On Android and iOS some extra configuration is required.

Android
  • In the Android Libraries section of the Target Platforms list of a project
    • Disable the file “android-support-v4.dex.jar”
    • Add the files “android-support-v13.jar” and “CustomTabs.jar” Both these files are located in the “Android-CustomTabs-Support” subfolder of the installation folder.


iOS
  • Add the SafariServices framework to the SDK Manager by right-clicking the iOSDevice 64 target and clicking "Edit SDK". Click in the frameworks section and add a new framework based on the information below:


A new video has been published:

Introducing TMS FNC TableView beta




A new video has been published about our TMS FNC TableView beta that is included in TMS FNC UI Pack beta v2.1.0.0.

TMS FNC UI Pack beta v2.1.0.0 is available from the 'My products' page for all registered TMS ALL-ACCESS and TMS FNC UI Pack users.



TMS RemoteDB:

Setting SQL Server ApplicationName from client.



When using SQL Server at RemoteDB server side, you might want to make client to set ApplicationName parameter of server connection. You can achieve that by sending the parameter through a HTTP header “db-app-name", and using a middleware at server side to grab that value and set in connection. This approach can be used to set other server-side database connections from client side.

On server side:

threadvar
  ThreadApplicationName: string;

procedure StartServer;
var
  Server: THttpSysServer;
  Module: TRemoteDBModule;
begin
  Server := THttpSysServer.Create;
  try
    Module := TRemoteDBModule.Create('http://localhost:2001/tms/remotedb',
      TDBConnectionFactory.Create(
        function: IDBConnection
        var
          Module: TConnectionModule;
        begin
          Module := TConnectionModule.Create(nil);
          // Use ThreadApplicationName to configure your connection
          if ThreadApplicationName <> '' then
            Module.FDConnection.Params.Values[‘ApplicationName’] := ThreadApplicationName;
          Result := TFireDacConnectionAdapter.Create(Module.FDConnection1, Module);
        end
      )
    );
    Module.AddMiddleware(TAnonymousMiddleware.Create(
      procedure(C: THttpServerContext; Next: THttpServerProc)
      begin
        ThreadApplicationName := C.Request.Headers.Get('db-app-name');
        Next(C);
        ThreadApplicationName := '';
      end
    ));
    Server.AddModule(Module);
    Server.Start;
    WriteLn('RemoteDB server running...');
    ReadLn;
  finally
    Server.Free;
  end;
end;
on client side:

  RemoteDBDatabase1.OnRequestSending := RequestSending;

procedure TfmThreeTierAureliusRemoteDB.RequestSending(Sender: TObject;
  Req: THttpRequest);
begin
  Req.Headers.SetValue('db-app-name', 'My Application');
end;

TMS Analytics & Physics Pack:

Array and Matrix operations with Analytics v2.2



New version 2.2 of TMS Analytics and Physics Pack includes total support of operations with N-element arrays and MxN matrices. The operations realized in the Linear Algebra extension package. Array and matrix operations allow advanced calculations with small, compact formulae.

Read the full blog post here.



As always, we thank all users for the numerous inputs, feedback, comments and suggestions. This is an invaluable help to steer our developments here at TMS software. We continue to look forward to all your further communications to direct our team to provide you better tools and components for your needs.

Kind regards,
TMS software team
Email: info@tmssoftware.com
Web: http://www.tmssoftware.com
Support, FAQ & Manuals: http://www.tmssoftware.com/site/support.asp


Follow latest developments at tmssoftware.com




NOTICE: If you wish to unsubscribe from the TMS software Newsletter, please click here.