RemObjects SDK for JavaScript and Smart Mobile Studio

Recently, Smart Mobile Studio 1.0 was released and some of our customers expressed an interest in using it with our RemObjects SDK for JavaScript, so I gave it a try. For those of you who don’t know anything about it: Smart Mobile Studio lets you write Object Pascal code (based on the Delphi language) to build a JavaScript application.

You can download the trial version, install and run it. The IDE itself looks cute, its welcome screen offers quite a lot of starter info and we can start creating new projects immediately. Of course the first thing to do is to connect to the RemObjects MegaDemo server with the JavaScript libraries…

Adding RemObjects SDK files

I’ve found two ways of doing this:

Copy the library files to the project folder and manually add the following HTML at the end of the section of index.html.

<scripttype="text/javascript"src="RemObjectsSDK.js"></script><scripttype="text/javascript"src="MegaDemoLibrary_intf.js"></script>

Or just add press “add script” and paste the script text there.

Designing the form

We’re going to create our usual Sum test app, so let’s create a form like this:

The code

Skipping research attempts, here’s what I got:

procedure TForm1.OnSuccess(res:variant);begin W3EditBox3.Text:= res;end;

procedure TForm1.btnClick(sender:tobject);var svc:variant;beginasm@svc = new MegaDemoService(new RemObjects.SDK.HTTPClientChannel('http://localhost:8099/json'), new RemObjects.SDK.JSONMessage());end; svc.Sum(W3EditBox1.Text, W3EditBox2.Text,@self.OnSuccess);end;

Procedure TForm1.InitializeObject;Begininherited;{$I 'Form1:impl'} W3Button1.OnClick:= btnClick;End;

And that was enough to get the answer.

Conclusion

It’s quite easy to use RemObjects SDK for JavaScript as a third-party library with a quick asm section hack. The blog post of the Smart Mobile Studio creator shows that this may be done properly, and we’ll look into providing official and deeper integration with SmartStudio along those lines in the future.

valeriyg

0