Watch, Follow, &
Connect with Us

Stephen Ball

Using Azure Translator Services with Delphi

Often when building IoT applications there is benefit in linking to 3rd party services. e.g. Heating control systems may link to weather services to help detect external influences that may effect their operation. Typically these services are exposed via JSON and REST providing multi-platform access.

Microsoft Azure data services offer access to a wide range of datasets and services and in this blog post I will take you over my journey connecting to the Azure translator data service and achieving translation of text on Windows, Mac OS X, iOS and Android thanks to the REST components and helper classes in RAD Studio XE8.

About Microsoft Azure Translator Data

Microsoft Translator is a WEB API that enables Automatic Translation (Machine Translation) of text between any of the 50 supported languages

The Azure Translator data is used by Microsoft Office, Visual Studio, Bing and many more Microsoft products. It works over REST using a mix of JSON and XML to provide a number of services including translation and text to audio.

To use the Azure Translator data service you must be registered to use the market place and have an app registered to get the required credentials.

Once registered it uses 2 step authentication to provide a token (valid for 10 minutes from issue) that is then used for API calls. It does this with separate URLS’s for the security and the data services.

A great link to steps and URL’s (incase any change) is the Getting Started using Translator API page

Step 1) – Signing up with Microsoft Translator

As with most services, you need to be registered to use them. Documentation of signing up for Translator is found in steps 1 and 2 of this blog post.
http://blogs.msdn.com/b/translation/p/gettingstarted1.aspx 

Once registered, Ensure you sign Up for the $0.00 per month option to get your free translation credits.

Step 2) Registering an App

Now you are signed up, you need to register your application. (ok we don’t have one yet, so we will just make one up for testing). To register your application for use with the Translation service visit https://datamarket.azure.com/developer/applications and choose Register.

On the registration screen you need to enter in a Client ID (no longer than 20 characters or it will not work from my experience) and also enter a name for your application and a description (anything will do as you can change it later) Finally a redirect URL (your website home page will do, its not used with the REST component setup, but is required)

Azure_Translator_Register_Delphi

 

At this point you will need to copy down the two parts of data I have highlighted on the reg form. The Red part is what you have typed in (Client ID) and the blue part (Client Secret) which is  generated for you by Azure. These two are used to get your session token later on that allows you to talk to the API’s. – Don’t worry if you hit create before you make a note of them as you can open it back up from the applications page at a later point.

Step 3) Building the app using Azure Translation Service in Delphi

Click here for the API documentation for Azure Translator that I’ll be referencing to.

To use a REST service you first need to know what API’s the service exposes, the parameters it requires and then the response to expect. So lets start there…

With REST the API comes in the form of a URL base that then has methods (resources) appended. Each resource has parameters to define the data exchanged, but there are a few ways of passing parameters. The most typical is a URL Segment, but there are also Body and Header parameters. You achieve this easily in Delphi use the parameter property of the TRESTRequest component. (I will get to this shortly).

3.1 – Getting the access token

It is common practice with REST that there is an authorisation step that provides you a session token for subsequent calls. The first stop to using Translator is obtaining an Access Token to use with your API calls.  From reading the documentation and scanning the C# example I was able to locate the Base URL,

 https://datamarket.accesscontrol.windows.net/v2

and the resource for authentication

OAuth2-13

For the resource there are a number of parameters, all of them URL segment parameters and as described in the document this is a HTTP post method.

Parameter Description
client_id Required. The client ID that you specified when you registered your application with Azure DataMarket.
client_secret Required. The client secret value that you obtained when you registered your application with Azure DataMarket.
scope Required. Use the URL http://api.microsofttranslator.com as the scope value for the Microsoft Translator API.
grant_type Required. Use “client_credentials” as the grant_type value for the Microsoft Translator API.

The first two are linked to the data that we generated when registering the application in Step 2 above while the other two always have the same, but required, values.

So now we know what to call, how do we setup the components to call this?

We are going to use 3 components.

TRESTClient – To define where the Base URL is.
TRESTRequest – To define the resource we want to use and the parameters we are passing
TRESTResponse – To collect and store the reply

Compoents for REST call

Adding the three components to your data module or application form should link them all together.

On the REST Client I set the base URL (see above for value) and on the REST Request I set the resource to OAuth2-13 and checked to make sure that the method was a rmPOST. Opening the Params property on the TRESTRequest I also added in the 4 parameters.

RESTAuthParams

You can either set the Client ID and Client Secret in the parameter at design time, or you can define that in code using the TRESTRequest.Params.ParamByName(‘name’).value property e.g.

RequestAuthToken.Params.ParameterByName(’client_secret’).Value := ‘MyClientSecret’;

RequestAuthToken.Params.ParameterByName(’client_id’).Value := ‘MyAppID’;

If you set the values at design time you should be able to right click on the Request and Execute to populate the Response.content. Alternatively, call the Request.Execute at runtime.

3.2 – Finding and extracting the Token

So now we know how to ask for the token, how do we extract it and work with it? What comes back?

The documentation defines the response properties that are returned. These can be queried or using the TRESTResponse instance GetSimpleValue method.

Property Description
access_token The access token that you can use to authenticate you access to the Microsoft Translator API.
token_type The format of the access token. Currently, Azure DataMarket returns http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0 , which indicates that a Simple Web Token (SWT) token will be returned.
expires_in The number of seconds for which the access token is valid.
scope The domain for which this token is valid. For the Microsoft Translator API, the domain is http://api.microsofttranslator.com.

AuthCode

In the code example above (click to make bigger), you can see the

Client secret and Client ID get set at run time.
The request is executed by calling .Execute;
The response is checked for the access_token return parameter.
The request components that I will use to call the API’s (RESTRequestTranslate and RESTRequestPlay) now I am authorised have the returned access token set as the value for use.  – I’ll cover the setup of these shortly)

New – System.TNetEncoding

The final two lines use TNetEncoding (a really useful class with class functions) to show a decoded Token. No value other than curiosity, but it does show how to decode a URL value (there is also HTML and Base64 decoding helper methods) .

I wouldn’t recommend that for a live application.

3.3 – Calling the Translate API with the Token

To recap. I have used the TRESTClient to point to the BaseURL of the service. Used the TRESTRequest to define the resource and parameters that need to be passed, set the parameters and fetched and retrieved the token, which has been set into the Authorization parameter of another TRESTRequest that I have called RESTRequestTranslate.

So there are a few things to cover here still.

The setup of RESTRequestTranslate and its associated components, especially the parameters
And what comes back from the Translate API

3.3.1 Component Setup to call the API with the Access token.

In a very similar way to getting the Access token, we use the same components to call the live API. Using the same process as before its possible to identify the Base URL and parameters – full list of methods here https://msdn.microsoft.com/en-us/library/ff512419.aspx

Base URL

http://api.microsofttranslator.com/v2/Http.svc

and resources I have used

Translate

to convert text from one language to another and

Speak

to create an audio file based on text passed in.

Both have separate parameter lists so I’m just going to concentrate on translate for this post, however the sample has both in there.

Because all the resources share the same base URL, the TRESTRequests can share the same TRESTClient instance.  (see the green section in the diagram below.

In the documentation for the Translate API method, it defines the parameters that are required, but also the type of parameter required.

Most are segment URL values, but the authorization token must be a HTMLHeader defined as ‘bearer ‘+token.

To create the parameters for URL Segments its easy to define them as part of the resource.  – see image below.

TranslateAPI_Delphi_Component_Setup

Translate?text={text}&from={from}&to={to}

The {brackets} define a parameter name when part of the resource. They automatically get added as URL segment. (or you can add them manually yourself)

Finally. Add in the Authorization token by clicking on the Add icon on the Parameters editor. Making sure to select Kind pkHTTPHEADER.

Typically Parameters are encoded automatically for us so we don’t need to mess around with encoding values, however because the token returned is already encoded, we need to set the option to DoNotEncode on the Authorization token.

Authorization Delphi REST Param HTTPHeader

So we are now all set up with the components.

In code now, we just need to set the language from and to (these are specified in the documentation or can be collected from another API call) and the text to translate. (see below – The Text is set using LiveBindings however – see further down for that setup or just do it in code)

SettingParams_Delphi_Rest_in_code

3.3.2 – What comes out?

So here is that application at run time. I’ve selected Auth already and now choose Translate

LiveBindings_Setting_Params_Delphi_Rest

You will see that the Response Content is actually an XML data packet. For that you can use the XML Document interfaces to extract the value, (I’ll cover that in another post) but there we have it! Translated text :-)

Now as this is a FMX (FireMonkey) application, I can now go and use this on iOS, Android or Mac OS X as well as my local windows machine.

Translator Code Example – Download

The code I cover in this blog is available for download. however I have made it even easier to use…

Must have – BONUS DOWNLOAD

Included in the download is a set of classes I have created to

Encapsulate fetching and managing the token (inc lifespan)
Manage setting the parameters
Conversion of return data from XML to text.

see Project TranslateCompsExample in the project group – enabling code like…

procedure TForm15.btnTranslateClick(Sender: TObject);
var
Translator : TAzureTranslator;
Str : string;
begin
Translator := TAzureTranslator.Create(Self);
try
Translator.SourceLanguage := ‘en’;
Translator.TargetLanguage := ‘da’;
Translator.AccessToken := TokenManager;
Str := Translator.Translate(‘Delphi Rocks!’);
memo1.Lines.Text := Str;
finally
Translator.Free;
end;
end;

Get the code now, and start adding translation and playback of audio into your applications! http://bit.ly/ccAzureTranslatorDelphi

Happy Coding!

The post Using Azure Translator Services with Delphi appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on June 30th, 2015 under Uncategorized | Comment now »


InterBase XE7 – Update 3

InterBase XE7 – Update 3

InterBase XE7 update 3 is now available for general release.

What’s new in InterBase XE7 – Update 3?

In my post about InterBase XE7 Update 2 I mentioned about the new reserve words that are used by Change Views and how to work with reserved words by using “quotes”.

CHANGE,
CHANGED,
INSERTED,
UPDATED
DELETED

With update 3, InterBase XE7 only adds these words to the reserved list once Change Views are active in the database. This will make it easier for users to migrate to InterBase XE7 and take advantage of the other cool features like partial data dumps, improved index handling etc.

What’s fixed in InterBase XE7 update 3?

The resolved defects are documented on the InterBase XE7 DocWiki resolved defects page .

 

Downloading InterBase XE7 update 3

Embarcadero CodeCentral “Registered Users” can download the patch binaries (Server/Desktop/Developer/Trial) for Windows and Linux, and, ToGo Edition. You can find the downloads at http://cc.embarcadero.com/reg/interbase

For new users, the trial and developer editions are available for free at http://www.embarcadero.com/products/interbase/downloads

The post InterBase XE7 – Update 3 appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on June 24th, 2015 under Uncategorized | Comment now »


Linking object/TValue to a control, VCL to FireMonkey

In this post, Tag properties and using Rtti.TValue data property as an alternative in FireMonkey / FMX.

Click / Select… now what?

One common challenge we face as developers is that the user clicks on something, we now need to find the object that is required to do the next task based on the item selected.

Sometimes this is from a dataset linked to the control and it may be taken care of for us, other times, we may need to find a specific object that then has the data we need.

Most of us have done it at some time….

Yes… that naughty little trick of using the tag property of a TComponent to store a pointer to an instance of an object that you want a quick way of reaching.

I remember doing this in a POS system where buttons that represented different stock items were linked to dynamically created screens. I also remember often using the TListView and thankfully, the TListViewItem in VCL had a Data property (of type Pointer) that you can set at runtime to an instance of an object. This was a little less naughty when moving to 64bit coding when Integer and Pointer all of a sudden became different sizes, (and if it wasn’t for some insight from the Delphi team to swap tag to NativeInt – lots of code would have broken).

The problem with a pointer property (or using a NativeInt to achieve the same goal) is that it leaves a lot of typecasting in your code, which never sat easy with me.

Avoiding tag / pointer properties….

A number of years ago, (probably when I was still using Delphi 5) I started to avoid using the tag property as a pointer holder by replacing the components I was creating with a new class that descended from the original component. e.g.

TMyButton = class(TButton)
strict private
FFoo : TFoo;
public
property Foo : TFoo read FFoo write FFoo;
end;

This approach reduced errors from typecasting, I had exactly what I was looking for and could write nicer code with less typecasting. I also often added the object to the constructor to make it easier and less lines of code.

Problems?

I also had times that I needed access to a number of objects, so would end up with multiple objects listed, when in reality I only needed to get to one or two properties of each objects.

I also had times that I had objects of different type (something a pointer is fine for), but it was always to get the ID value or something that was common.

FireMonkey Tag, TagObject, Data

FireMonkey components have not only a Tag property (that mimics the VCL, but it also provides 3 extra Tag’s

Tag Properties

Tag
TagObject
TagFloat
TagString

This can be easier to use, but there are sometime other values you want to pass and this is where the Data property comes into its own.

Data Property

Data is a TValue (from System.Rtti) and can be used to store pretty much anything. There are a load of helper classes for working with it, and some components even provide Data as an array with a string name.. (e.g. see the TListViewItem).

An example of using this is as follows

type
TMyEnum = (Foo, Fee);
procedure TForm14.FormCreate(Sender: TObject);
var
I: TListViewItem;
begin
I := ListView1.Items.Add;
I.Data['Foo'] := TValue.From(‘Hello’);
I.Data['MyEnum'] := TValue.From(TMyEnum.Fee);
end;
procedure TForm14.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem);
var
Value : TMyEnum;
begin
ShowMessage(AItem.Data['Foo'].ToString);
Value := AItem.Data['MyEnum'].AsType<TMyEnum>;
ShowMessage(TRttiEnumerationType.GetName<TMyEnum>(Value));
end;

You can see that even Enums can be passed using the Data property.

Using RTTI and the Data.TValue option provides a lot of flexibility in FMX for linking to objects or data.  Sometimes you may not need to create an instance of an object just to store the one or two lines of data that you required which can be useful and provides less memory to manage.

Summary

Thinking back to my POS screen, just having a string tag would have reduced a class that I needed to write test and manage the memory for.

Personally, for me, the data property is much more useful that an old style pointer – the TListViewItem with an array of TValues is also very useful.

The post Linking object/TValue to a control, VCL to FireMonkey appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on June 24th, 2015 under Uncategorized | Comment now »


Using Generics & RTTI to get enum string name or enum value

Overview

This blog post looks at Enums and how multi-platform generics and RTTI (or what C# guys call reflection) make this really simple using common code on Windows, Mac OS X, iOS and Android using Delphi.

Starting with what an Enum is, the post then explores how you would traditionally have seen it written in code, before looking at the clean X-platform approach RTTI and Generics provide.

If your experienced in working with enums and want to find out how RTTI makes it easier, you may want to skip the first part of this post and get to the section about RTTI further down.

Enumerated Types to and from strings

An Enum, or Enumerated Type is a data type with a set of named values.

Enums are a great way to define a set of constants that are specific for a type and work with them in context, ensuring only one, or an array of allowed values is set.

OK, I’m going to use an example that maybe should have more values listed, but you get the point. It is the points of a compass – North, South, East or West.

type
TCompass = (North, South, East, West);

var
D : TCompass; // short version for Direction
begin
D := TCompass.North;
case D of
North : ShowMessage(‘North’);
South : ShowMessage(‘South’);
East : ShowMessage(‘East’);
West : ShowMessage(‘West’);
raise Exception.Create(‘Unknown Direction’);
end;
end;

This provides one way to convert a Enum to a string using a case statement, but every time you make a change to your Enum types, you need to add in extra code… Call me lazy, but thats too much work!

Enum to string – GetEnumName

In Delphi it has been possible for a long time to convert an Enum to a string. This has traditionally been done using the GetEnumName method in System.typInfo.

function GetEnumName(TypeInfo: PTypeInfo;
Value: Integer): string;

Rewriting the previous example using GetEnumName makes code simpler and more robust.

type
TCompass = (North, South, East, West);

var
D : TCompass; // D = Direction
S : string;
begin
D := TCompass.North;
S := GetENumName(TypeInfo(TCompass),D);
ShowMessage(S);
end;

This is great as I no longer need to worry about changes to the Enum declaration, my code will keep working.

String to Enum – Using GetENumValue

To convert a string to an enum, you can use the GetEnumValue method in System.Typinfo – this is a little more work than going the other way however.

function GetEnumValue(TypeInfo: PTypeInfo;
const Name: string): Integer;

GetEnumValue will return an integer that you can then typecast back to the value in the enum. Assuming we have a variable called value of type Integer and we use the S variable from earlier

Value := GetEnumValue(TypeInfo(TCompass),S));
D := TCompass(Value);

Presto! Easy to convert values back and forth. However its not the easiest code to read quickly, but this does work cross platform on all the delphi compilers

Enum conversion with Generics / RTTI

Unit System.RTTI is cross platform and contains a great class for converting enum to string and back: TRttiEnumerationType

The TRttiEnumerationType class has two class functions (methods you can call without creating an instance of the class) that clean up the code required from using the TypInfo methods.  The easy reading version of these method declarations is:

class function GetName<T>(AValue: T):string;
class function GetValue<T>(AName: string): T;

Note these methods use Generics (thats the T bit). Generics are very cool as they allow you to write functionality once and then reuse it with different types at different times in code.

In this instance TRttiEnumerationType’s generic methods are for use with Enums only and not other class types as the functionality defined is specific for Enum’s.

To convert the TCompass enum now after adding RTTI to the uses would look like this.

S := TRttiEnumerationType.GetName<TCompass>(D);
ShowMessage(S);

To convert back from a string is also simpler.

D := TRttiEnumerationType.GetValue<TCompass>(S);

How much easier is that to read! and as we have only had to declare the type once, we have less chance of silly copy paste errors in code.

Summary

Thanks to cross platform unit System.RTTI and its class TRttiEnumerationType (which also uses multi-platform Generics), it is really simple to write really readable code that works with enums and compiles for Windows, Mac OS X, iOS and Android.

The post Using Generics & RTTI to get enum string name or enum value appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on June 4th, 2015 under Uncategorized | Comment now »


Important InterBase XE 7 – Update 2

InterBase XE7 – update 2

InterBase XE7 update 2 is now available for Windows and Linux server and ToGo. This update is highly recommended for all users of InterBase XE7.

For what is new and resolved issues in InterBase XE7 Update 2, please see the online InterBase documentation. – but in short, following update 1 with some change view enhancements – update 2 contains a number of fixes to general bugs reported.

Working with reserved words.

A list of Known Issues is available in the documentation. One that I will highlight is the addition of CHANGE, CHANGED, INSERTED, UPDATED and DELETED as reserved words in InterBase XE7 due to the introduction of Change Views.

I have heard of a few cases where developers have SQL statements that have stopped workings because their tables have fields that are one of the reserved words, e.g. UPDATED; Its easily to ensure those keep working by putting field names in “quotes” in your SQL statement.

As we know a lot of developers don’t quote their field names, we are working towards either a hot-fix or an update for the future that will only work with these as reserved words IF Change Views are being used, however it is recommended that you add “quotes” to the fields in your SQL if you are at all in doubt.

Download

For registered users, you can find the patch downloads at http://cc.embarcadero.com/reg/interbase

Server Edition

Windows
http://cc.embarcadero.com/item/30198

Linux
http://cc.embarcadero.com/Item/30199 

ToGo & IBLite Edition

Registered Users Downloads

Developer edition and Trial

https://downloads.embarcadero.com/free/interbase

 

The post Important InterBase XE 7 – Update 2 appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on May 15th, 2015 under Uncategorized | Comment now »


What to do with Beacons before you code?

A beacon is a Bluetooth Low Energy device including some information in its advertising data.

Working with beacons requires code to read the beacons and some setup to ensure you read only the right beacons, especially as more and more are appearing! This article mainly focuses on the latter and what you should be aware of before you deploy your beacons.

Programming for iBeacons & AltBeacons

While you can code to work with beacons via a number of languages, RAD Studio XE8 has introduces a new multi-platform component for working with beacons – as covered in this post from Sarina DuPont – this is very cool making it super easy to have both Android and iOS and Mac applications running from common code. However this is out of the scope of this post.

I will however point you to the sample projects shipped with RAD Studio XE8 using both Delphi and C++ in the following samples folder which can be opened directly using the shortcut to the samples in the IDE.

There is also great detail about what beacons are in DocWiki

<Samples>\<language>\Mobile Samples\Device Sensors and Services\Bluetooth\Beacons

Getting started with Beacon Hardware

So what do I need to know about beacons?

Beacon Standards

Firstly, beacons are typically following 2 standards for broadcasting over Bluetooth 4.

iBeacons from Apple (and requires a license if you want to create physical beacons yourself)
AltBeacons which is an open standard

Alt Beacon
iBeacon

Using these standards you can pick up data to identify a specific beacon and how far it is away. The 4 key bits of information to manage this are

UUID
Major ID
Minor ID
TxPower

Using the new Beacons component you can define which type of beacon(s) you want to scan for using the UUID as a filter, and optionally Major and Minor ID – and this brings us onto the importance of the UUID

Beacon Regions

Beacon UUID

By default the UUID is set based on the beacon manufacturer. If you are going to use beacons in a real world application then you will probably want to update the UUID to a unique ID that you will be scanning for. This way you can limit any other beacons that are deployed.

Beacon Major and Minor

Beacon Major and Minor ID’s are used to identify the specific location you want to indicate with the Beacon. Hence its important that you update the UUID so you read only the correct beacons to check for the location you are at.

An example would be using the major to identify a retail store and a minor to a specific area in the retail store.

Programming the Beacon

There are a number of beacon manufacturers out there, and its typically easy to re-program your beacon to have that unique UUID and then set the Major and Minor ID’s.

Once such beacon is the RadBeacon from Radius Networks

Radius Networks provide a useful Beacon config application that you can download for free (once you register)

The application is available for Android, iOS and Mac.Radius Network Beacon Configuration

 

 

The default pin for editing the beacons is 0000.

Requirements for the Config App

For the software requirements visit the Beacon config application home page. In short, Bluetooth 4 is a minimum and Mac (10.9+) or recent iOS / Android releases.

Securing your Beacons….

Before you deploy your beacons, you may want to secure your beacon from tampering.

It is suggested by Radius networks that you lock your beacon before its put into a live environment. Locking a beacon prevents any further editing over bluetooth, so you need to be sure of your config before you do this.

A little less radical is updating the pin code for editing the beacon, however this is easily cracked so really only ideal for short term setup.

More about what the different options on the config application do are available here: http://www.radiusnetworks.com/ibeacon/radbeacon/mac/2-0-0/help.html

The post What to do with Beacons before you code? appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 11th, 2015 under Uncategorized | Comment now »


Database updates in RAD Studio XE8

Database updates in RAD Studio XE8

With RAD Studio XE8 there have been a number of database updates to expand connectivity, and improve and introduce functionality for us programmers.

FireDAC & IBX support for Change Views

FireDAC has introduced new support for Change Views – enabling rapid identification of what has changed on the server side data and updating of client side stored data. See this <2min video for how these work.

Source code for the example ships in the samples directory:

<Samples><language>Database\FireDAC\Samples\DBMS Specific\InterBase\ChangeView

IBX has also introduced new components to make it easier to work with change views and subscriptions.

 New Platform – Teradata

FireDAC now includes support for Teradata, using the driver name TData.

TeraData in FireDAC

 

An example of how to set the driver properties is shown on the docwiki help for connecting to Teradata with Delphi.

DriverID=TData
Server=192.168.43.140
Database=MyDatabase
User_Name=dbc
Password=dbc

TDataSet TField speed up.

Marco Cantu mentioned on the Launch webinar Q&A a customer was claiming seen a speed up of around 25% on a TClientDataSet application due to the refactoring at the base of how TField is used at the core layer. :-) This is really cool for both VCL and also FMX developers.

64bit support for iOS

With the new platform for iOS 64bit, the database layer is also seamlessly available, just recompile and run :-)

Other updates

There are updates for EMS including push notification. EMS is a great way to access central data from mobile devices. EMS now is updated to include InterBase XE7 for both the server and ToGo side, allowing you to use Change Views on both Server and Clients.

Where FireDAC uses SQLite, it has been updated to a newer driver.

For more of whats new in RAD Studio XE8, including EMS updates, please click here Whats new in Delphi XE8 and C++ Builder XE8

 

The post Database updates in RAD Studio XE8 appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 10th, 2015 under Uncategorized | Comment now »


RAD Studio XE8 & my first Google Play app

RAD Studio XE8 has been launched today with a host of new features for both mobile and desktop applications.

Discover How RAD Studio XE8 Expands Your Business

Multi-platform FireUI
Extend Windows apps to mobile
Mobilize business with EMS
Update subscription
Get productive
Native Platform Controls
Stay informed with Analytics

For more on whats new visit RAD Studio XE8 documentation

My Google Play app built with XE8

I have been playing with a new application that combines my hobby as a Basketball referee with my geeky side and have published using RAD Studio XE8 a new Google Play store application for managing Basketball Shot Clocks.

Setting Up the Shot Clock
Shot Clock Timer - Running
Scaling Shot Clock Font

I started this app using components that was introduced in XE7 – AppTethering and Multi-View, and these have been great, but I have benefited recently from the new FireUI updates in building a version for multiple screens. I now have it running on Tablets, Phones and Android TV. (which is kind of fun).

Adding in XE8 “toys”

Analytics

Getting to XE8 was trivial from XE7, and my next step now is to add in the new Analytics features of XE8. AppAnalytics provides developers with a visual representation of how users are interacting with applications built with RAD Studio XE8

I’ve found you get some good analytics about platform and country etc from Google App Store, which is cool, but I want some in app details to know when its being used. – This is especially cool as this can be used in VCL and FireMonkey applications and there is a free version of the service with the option to purchase enhanced online analytics.

More Native Controls

I’m also going to look to increase the native controls used in the app with the new options for a number of the controls I have used (like the slider and list view). I like the way FireMonkey abstracts this as an option and even surfaces some new options in this area.

For more about the new controls and everything else that is new in XE8 please visit the online help documentation.

 

The post RAD Studio XE8 & my first Google Play app appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 8th, 2015 under Uncategorized | Comment now »


InterBase XE7 – Update 1 Released

InterBase XE7 Update 1 Overview

InterBase XE7, update 1 went live on Friday and brings with it SQL language enhancements for Change View, and some updates to IBConsole and the availability of InterBase ToGo for XE7

Full details about the update are available on the InterBase DocWiki

Change View Updates

There are 2 major additions to InterBase Change Views in Update 1

DROP SUBSCRIPTION
Change View SQL Extensions

Drop Subscription

Prior to update 1 you had to manually drop a subscription via an SQL statement. This was a temporary solution and has now been replaced with the correct SQL syntax

DROP SUBSCRIPTION <subscription name> [RESTRICT | CASCADE]

If you want to remove a subscription that has subscribers you must use the CASCADE command as RESTRICT is the default.

Change View SQL Extensions

InterBase SQL now includes additional language to support querying about the changed state of specific fields via the <FIELD> IS [NOT] {CHANGED | INSERTED | UPDATED | DELETED} clause.

Take the following example.  Lets imagine we have two employee records that have been modified.

EMP_NO 39 has their DEPT_NO changed
EMP_NO 109 has their SALARY changed.

At run time you want to select only those that have had a SALARY change prior to processing staff payments. To achieve this first, a Change View subscription is set active (making any SQL statement subsequently run only return the delta for that subscriber). Then SQL where clause then filters further where the SALARY IS UPDATED.

SET SUBSCRIPTION sub_employee_changes at ‘MyDeviceID’ ACTIVE;
SELECT EMP_NO, DEPT_NO, SALARY FROM EMPLOYEE WHERE SALARY IS UPDATED;

EMP_NO DEPT_NO SALARY
——– ———- ———-
109 600 75000

Regardless of what you select, the commit will still bring

InterBase IBConsole Updates

InterBase IBConsole has a number of new features, introduced in Update 1 designed to get you started quicker.

Getting Started with InterBase
Recent databases window
Change Views Integration

IBConsole Start HereIBConsole Start Here

Getting started with InterBase

When you open IBConsole now you find the new InterBase – Start Here page as a tab at the top of the screen. The start here page includes containing details about Community and featured posts, as well as training videos and direct links to the documentation. While an offline page ships with IBConsole, If you want to see this page now, please visit http://www.embarcadero.com/starthere/interbase/index.html

Having this page online allows us to improve our communication with our customers about critical information and appropriate news.

Recent Databases

There is also a new feature in the bottom left of the screen (see image above or below) enabling you to quickly connect back to the recent database you have been working on.

This windows shows you the database name, server and also the when you last accessed the database via IBConsole.

Change Views

Change View IBConsole

IBConsole also now includes access to work with subscriptions.

InterBase ToGo XE7

InterBase XE7 ToGo trial edition is now available for download – more details to come soon about ToGo.

The post InterBase XE7 – Update 1 Released appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on March 12th, 2015 under Uncategorized | Comment now »


InterBase Change Views Demo and Video

InterBase Change Views Example Demo

This week I hosted a Skill Sprints session looking at InterBase Change Views with an example set of code working around a Pharmacy needing to keep centralised drug information updated at distributed pharmacies.

The example code will ship with the next major release of the RAD Studio products – which you can get for free with the current RAD offer

This InterBase Change Views Example demo shows off this powerful way to track on the server what data is changing in a very lightweight and scalable way.

This Skill Sprint Video for InterBase Change Views follows on from the recent blog posts I have done on Change Views which are available here:

InterBase Change Views blogs

What is a Change View?
Creating a Change View
Using a Change View

InterBase Change Views in Spanish

Last week CodeRage III Brazil ran with a host of great sessions in Spanish, covering RTTI, App Tethering, DataSnap and FireDAC and also InterBase. Back in December I hosted the product Launch of InterBase XE7 at CodeRage 9, and it has been great working with Dormevilly and Fernando to get an updated Spanish version done, including some of the great capabilities we have today with Change Views. Great job guys :-)

The post InterBase Change Views Demo and Video appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on March 7th, 2015 under Uncategorized | Comment now »




Server Response from: BLOGS1