Smart Mobile Studio
  • News
  • Forums
  • Download
  • Store
  • Showcases
    • Featured demos
    • The Smart Contest 2013, Round 1 – Graphics
  • Documentation
    • Get the book
    • System requirements
    • Prerequisites
    • Getting started
      • Introduction
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • Themes and styles
    • Project types
      • Visual project
      • Game project
      • Console project
    • Layout manager
    • Networking
      • TW3HttpRequest
      • TW3JSONP
      • Loading files
  • About

Smart Mobile Studio 2.2 Hotfix 1

Posted on 15.04.2016 by gabr42 Posted in Announcements, Developers log, News

This is just a small update to Smart Mobile Studio 2.2. We have fixed the GUI problems (black rectangles under icons), updated DWScript to the latest version, and made small change to the Find in Files function.

To update, you can rerun the SmartUpdate utility [more information] or download the installer from the following locations:

  • Smart Mobile Studio 2.2 installer
  • Free command-line compiler

Changes

  • Fixed icon display problem (black background).
  • Updated compiler
    • Fixed critical issue with smart linking and lambda functions
    • Fixed missing dot in FormatDateTime.
    • Fixed range checking for dynamic arrays.
    • Improved compatibility with Google’s closure compiler.
  • Improved ‘Find in Files’ – current selection is used for search text.

Compiler options explained

Posted on 09.04.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles 1 Comment

CompilerOptionsIn the forums there was a post about a detailed description of the compiler options. Since there are currently no in-depth information available this post tries to clarify the topic a bit.

Continue reading→

Compiler options

It’s finally here – Smart Mobile Studio 2.2

Posted on 07.04.2016 by Smart Mobile Studio Team Posted in Announcements, Developers log, News

Yes, it is true! Not a beta, not a release candidate – we have finally published The Real Thing!

For the impatient

Download and run the installer.

  • Smart Mobile Studio 2.2 installer
  • Free command-line compiler

Portable installation

Smart Mobile Studio 2.2 can also be downloaded with the SmartUpdate utility [more information]. To get the final release, you should download from the (default) Release channel.

SmartUpdate - Release channel

If you already have a SmartUpdate-installed Beta channel on your disk, you can simply upgrade it to a Release by running the SmartUpdate.exe with the /changechannel switch.

What’s new

In two words: A Lot. Version 2.2 started out as a small upgrade, but as we worked on it we added tons and tons of stuff. A long list of changes since the 2.1 release can be found below.

What about the future?

We are already working on two fronts. A version 2.3 with revamped RTL (much faster visual component library and other goodies), support for search paths in the compiler and more is already in the work. At the same time we are triaging the issue list to determine which feature and bug requests will be fixed in the 2.2.1 hotfix.

List of changes since release 2.1

Compiler

  • Updated to latest DWScript.
  • Improved Date/Time handling.
    • DateTimeZone scoped enumeration (.Default, .Local, .UTC).
    • FormatSettings.ShortDateFormat, LongDateFormat, ShortTimeFormat, LongTimeFormat, Zone.
    • An extra “utc” parameter of DateTimeZone type on many DateTime functions.
    • A new ParseDateTime function, which acts as a reverse FormatDateTime
    • ISO8601 functions (were declared but missing from the codegen)
    • FormatSettings.Zone allows setting the default behavior between Local & UTC, and the utc parameter of DateTime functions allows to override that.
    • FormatSettings does not yet expose short/long day/month names, but these are used for Formatting & Parsing dates.
    • Fixed date/time rounding issues in the JS RTL.
    • JDateHelper was moved from W3C.Date to System.Date.
  • Added VarIsArray & VarIsClear.
  • Supports “export” qualifiers for functions (use in libraries).
  • Added support for ‘~’ in asm sections.
  • Added option to generate RTTI for objects in the implementation section.
  • Added missing error message for an invalid lambda syntax.
  • Added support for floating point modulus. (see https://www.delphitools.info/2015/10/29/floating-point-modulus)
  • Added support for sets in constant records.
  • Stricter enumerations type checks.
  • Integer operators are now more “strongly” typed, facilitates use of helpers over aliased integer types.
  • Case..of type matching is now more tolerant with variants.
  • Made code suggestions in a local scope more resilient to syntax errors in that local scope.
  • Compiler displays a hint about empty then/else blocks.
  • Compiler supports comparing Variant to nil with = and <> operators.
  • Conditional compilation symbols can be passed to the smsc compiler by using -defines=list.
  • Fixed: Source files with the UTF BOM header $FEFF are supported.
  • Fixed array add type-checks for classes & sub-classes.
  • Fixed array assignment typechecks.
  • Fixed an issue which caused a slight increases in memory usage after each compilation (a leak that was not strictly a leak).
  • Fixed “Invalid variant operation” error.
  • Fixed codegen for some class parameters.
  • Fixed codegen for StrBeginsWith.
  • Fixed method type detection bug.
  • Fixed issue with external class fields being assigned in an initialization section.
  • Fixed issues with incorrect array assignments.
  • Fixed handling of overloaded methods & override.
  • Fixes related to syntax errors in connectors (like Variant / JSON).
  • Fixed codegen bug with interfaces across inherited classes.
  • Fixed issue with nested contexts.
  • Fixed missing support for “set of” record fields.
  • Fixed bug with nested constant arrays.
  • Fixed obfuscation support.
  • Fixed some bugs and memory leaks.
  • Fixed compiler bug related to strict helpers.

RTL

  • Redesigned component management resulting in much faster redraw.
    • All visual elements now has a new procedure: ObjectReady() which you should override and use to adjust and set object values.
    • Added the property “ComponentState” as used by Delphi and FreePascal.
  • Added Indexed Database API W3C.IndexedDatabase (http://www.w3.org/TR/IndexedDB/).
  • Added System.Memory.
    • Marshaled pointer support, combined with support for Move, FillChar and all the other “memory” methods.
  • Added System.TypeCon containing data conversion classes.
  • Added System.DateUtils, capable of handling both local and UTC time.
  • Added System.Dataset unit containing in-memory database.
  • Added new system units: System.Streams, System.IO,  System.FileUtils, System.Messages.
  • Added Pixi.js library.
  • Added SmartCL.Legacy.pas containing Delphi-style TCanvas, TBitmap, and file path functions.
  • Added SmartCL.PageDiv unit, for managing a fixed buffer of abstract elements divided into pages. This is used by database navigators, thumnail viewers and anything which displays a fixed number of items out of a large whole.
  • Added simple label control SmartCL.Components.SimpleLabel.
  • Added TSimpleButton, a simple, rounded iOS standard button without gradients.
  • QTX Effects added to SmartCL.Effects.pas
  • Screen API wrapped in the TW3Screen class (accessible through the TApplication.Screen property).
    https://developer.mozilla.org/en-US/docs/Web/API/Screen
  • Improved TW3Image.
  • Defined ‘file’ input type for TEdit.
  • Added “Element” property (exposes the JXMLHttpRequest object) to TW3HttpRequest.
  • Added ResponseToMemory and ResponseToStream to TW3HttpRequest.
  • Added TW3WebSocket to SmartCL.Inet.
  • Added mousewheel support to scrollbars.
  • Added support for the Page Visibility API.
  • Added WebVR (Editors Draft) API.
  • Added font loading API (see http://www.w3.org/TR/css-font-loading/).
  • Added events OnActivate and OnDeactivate to TW3CustomForm.
  • Added cryptographic header translations (Cryptography API and “DRM” API).
  • Added neural network libraries Brain and Synaptic.
  • Added APIs:  W3C.Console, W3C.Push, W3C.ServiceWorkers, WHATWG.Fetch
  • Added AAC audio file support
  • Separated external objects defined by the JavaScript specification itself to a separate namespace ECMA. New units: ECMA.Date, ECMA.Json, ECMA.Math, ECMA.RegEx. RegEx class now lives in th ECMA.RegEx unit and global JSON object in the ECMA.Json unit.
  • Added System.Nullable containing nullable primitive types (see http://smartmobilestudio.com/2016/01/16/nullable-types/).
  • JEventHandler renamed to TEventHandler as it is not a native JS type. JEventHandler still exists, but is marked ‘deprecated’.
  • Completed overloads for the JJSON class.
  • Improved several of W3C APIs.
  • Updated Node.JS units.
  • Minor changes about accessing the audio tag from the Web Audio API.
  • Improved WebSocket support with binary and BLOB messages.
  • Redesigned REST API. REST API appends random number to the end by default (unless .NoRandomize is called).
  • Extended TypeScript header translation.
  • JUInt8ClampedArray was replaced with JUint8Array which has better browser support.
  • Fixed: touch events must not prevent default handler.
  • Fixed Scope confusion with CTRL + Click (namespace unit was opened instead of implementation unit).
  • Fixed modal dialog handling.
  • Fixed: Problem with ClientWidth & ClientHeight in document->body.
  • Fixed: Scrollbar math.
  • Fixed: Removed bug in ToggleSwitch where we used a “hack” to invoke a resize. This is no longer needed with the new system, so the bug and insertion of &nbsp; was removed.
  • Fixed “double free” bug in TW3Component.Destroy.
  • Fixed implementation of TMath.PI and TMath.E in Espruino.System.
  • Fixed System.Date/JDateHelper.SetAsDateTime and .SetAsLocalDateTime.
  • Fixed w3_getStyleAsFloat.
  • Fixed TW3Label positioning bug.
  • Fixed wrong declaration of JEventHandler (changed to ‘TEventHandler’ as it is rather a Pascal type declaration and not a JavaScript type).
  • Fixed TW3Dataset.Back.
  • Fixed Application.Document.ClientHeight.
  • Fixed TW3Slider component.
  • Fixed problems with TW3Label positioning.
  • Fixed TW3ScrollInfo.ScrollX and .ScrollY.

CSS

  • Added ‘None’ theme to allow CSS free simple demos using browser default.
  • New theme for Scrollbars.
  • Added CSS for TSimpleButton
  • Fixed: CSS3 form-background for Internet Explorer
  • Fixed: focus rectangle is now GONE for all themes.

IDE

  • Added: Metrics
  • Added: Project statistics
  • Added configuration option “Legacy support for IE9 (and below)”.
  • Added IDE setting to automatically save the project every N number of minutes (N is settable from 1 to 60).
  • Uses DCEF3 revision 2069 for built-in browser.
  • Improved UI with new (more) icons and a more consistent usage of fonts (now uses Segoe UI for all dialogs)
  • Improved JSON support.
    • JSON files can be added to the project.
    • Unit map shows JSON structure.
    • JSON files are available in the project generator API.
  • Improved Snippets management
    • Sort snippets after insertion
    • Renaming snippets
    • Snippets are not trimmed anymore (-> may contain leading spaces for indention)
    • (Incremental) search feature added
    • Doubleclick now pastes the snippets into the source code
  • Added: Close all tabs to the right
  • Added: Open file (tab) in explorer
  • Added: Only compile if necessary (when the project has been modified).
  • Added: Source code export tool.
  • Added: Search text highlighting.
  • Added SynEdit keystroke configuration to the IDE Settings/Keyboard page.
  • Added preferences page for internal browser configuration.
  • Added option controlling whether to add unit to the project’s uses section to the ‘new unit/form’ dialog.
  • Added unit name validation to the ‘new unit/form’ dialog.
  • Added option to have the internal browser log reversed (newest information at the top).
  • Added support for bulk deletion of several project files.
  • Added dialog to ask whether an unlinked external should be deleted upon making a project file all internal.
  • Added basic Cordova support.
  • New forms/units are external by default (on new installations).
  • Allows opening more than one file at once.
  • Introduced option for resource file path handling
  • Improved working with icons.
  • Implemented the sort project file feature.
  • Redesigned IDE Settings dialog.
  • Redesigned Project Options dialog.
  • Color is shown next to clXXX constants in the Code Insight window.
  • Implemented incremental searching in Project Manager.
  • Pressing Escape closes the Goto Line dialog.
  • Monitoring external files for changes can be turned off in IDE Settings.
  • The forms component list is now sorted
  • Welcome page can be closed.
  • Improved background compiler triggering and performance (ignores hidden designer implementation code)
  • Improved: [Enter] in project manager now opens file
  • Improved (IDE) compiler performance
  • Locate JS source code position in case of an error
  • Revived: Class browser, which now directly operates on the source code allowing to show even recent changes (in the editor).
  • Improved: Tightened XML files used by the IDE (less junk and empty tags) -> faster loading
  • Improved handling of open files that are not part of the project.
  • Improved ‘Normalize’ refactor.
  • Serial number is displayed in Help, License info.
  • Form name rename now calls rename refactoring.
  • ‘Mobile Manifest’ renamed to  ‘AppCache Manifest’.
  • Marked handled exceptions as expected so they don’t trigger EurekaLog dialog.
  • Fixed: ‘Asm’ highligher can be configured.
  • Fixed: Pressing Enter in Project Manager did not open selected unit.
  • Fixed: Search was not working for HTML source in the internal browser.
  • Fixed: If project was saved under a different name, it was not recompiled until it was modified in same other way.
  • Fixed: WriteLn messages were not always visible in logs.
  • Fixed: Switching from Project Manager to code could cause an access violation.
  • Fixed: Projects in the RTL/library folder won’t crash anymore
  • Fixed: Error in component name check (reserved words were possible)
  • Fixed: Extraction of units (in uses section) failed when comments were present within this section
  • Fixed: Automatic adding of new units now consider the right edge properly
  • Fixed: Unit scoping (namespaces) were not considered when adding new units to the uses section
  • Fixed: Node.js empty project generator created an invalid project (did not compile and needed manual tweaking of .sproj file)
  • Fixed: Messages window was visible when program was started
  • Fixed: Unit source is correctly displayed if new project or unit is created when no tabs are visible.
  • Fixed: When a new project is created, existing Unit1/Form1 files are no longer silently overwritten.
  • Fixed a problem when project files for a newly created project were not monitored for changes.
  • Fixed a problem when change was not detected if a form file (.sfm) was modified on disk.
  • Fixed issue where background compilation was performed twice on project load. The fix not only removes an internal exception, but also speeds up project loading as it only updates editor states once.
  • Fixed wrong icon for external resource files
  • Fixed: Double-clicking on a ‘folder’ icon crashed the program.
  • Fixed icon preview.
  • Fixed: Failed compilation didn’t always focus the editor.
  • Fixed issue with codegen which could crash on invalid source.
  • Fixed small issues with ‘Find in files’.
  • Fixed problems setting the linker output path.
  • Fixed ‘Open in browser’ button.
  • Fixed unnecessary limitations in ‘Keywords’ and ‘Homepage URL’ editors.

Editor/Designer

  • Updated CSS highlighter.
  • Syntax highlighting for JSON files.
  • Added visual designer guidelines.
  • Added simple ruler to the visual designer.
  • Added visual designer option to show the form’s bounds.
  • Added tool ‘Limit precision’ to the editor’s pop-up menu. This tool limits precision of numbers in the selected code.
  • Added ‘Wrap string’ feature to the editor to wrap a string which is longer than the right edge (Editor.RightEdge) to the next line(s).
  • Caret position change causes less workload (improved performance during source code navigation).
  • View state (editor/designer) is preserved in the <project>.dsk file.
  • Better live preview (less flickering).
  • Corrected ‘Show parameter’ (Shift + Ctrl + Space).
  • Improved Find&Replace dialog behaviour when executing ‘Replace all’.
  • Improved code completion.
  • Improved Ctrl+click behaviour.
  • Editor is refocused when internal browser window is closed.
  • Fixed source highlighting when double-quote was the first character in a line.
  • Fixed: Deletion of components in the designer did not mark the project as modified
  • Fixed DWS syntax highlighter for double quoted strings (did not highlight properly where delimiter was the very first character of a line).
  • Fixed: Form is marked as ‘modified’ when an event handler is created by double-clicking on a component.
  • Fixed: All controls on the form were duplicated when form was edited outside of the program while it was open in the editor.
  • Fixed event generation problem on secondary forms.
  • Fixed problems with Property Inspector and event generation (general crashes, “Invalid property value” exceptions).
  • Fixed the bug which occurred when several replacements were done in one line.
  • Fixed searching in RTL files (Find in Files, Include RTL/Library path).

Demos

  • Added DataSnap client/server demo.
  • Added DataSnap FishFacts demo.
  • Added DateTime demo.
  • Added HTML5 DOM demos.
  • Multiple demos corrected & adapted to the new RTL.
  • Added simple example for the Page Visibility API.
  • Added Splash Screen demo (http://smartmobilestudio.com/2015/09/27/writing-small-splash-screen-pre-loader-code).
  • Added a simple geolocation demo.
  • Added simple geolocation-based sunrise/sunset calculator.
  • Added a few examples to test certain cordova features (back button, audio playback [hooking its data for further processing]).
  • Improved Web Audio ABX Test demo.
  • Updated web audio examples and added new lessons.
  • Added third, manually created form to the `Multiple forms’ demo.
  • Added Layout Manager to the ‘Multiple forms’ demo to show how it is correctly used in a multiform application.
  • Updated REST demo.
  • Fixed Canvas Application demo.
  • Fixed: OnPrepare handler was not properly forwarded in SmartCL.Inet.REST.

Other

  • SmartUpdate program.
  • Unified installation for all editions.
  • Added support for “portable” installations that don’t require installation.
  • Cleaned-up default .spr file.
  • New icons.
  • Added a snippet that shows how to create a form in runtime.
finally release Version 2.2

Source map clean-up with Cordova

Posted on 05.04.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

Source maps are a very powerful way to support the debug process of HTML5-based web-apps. It actually maps the JS code to the higher level language (in this case Object Pascal). While this is very handy, especially in combination with obfuscation, it also reveals how the software is build internally. Thus you probably don’t want it to be shipped to customers.
Continue reading→

build script clean-up Cordova node.js Source maps

Smart Mobile Studio 2.2 Release Candidate 2

Posted on 30.03.2016 by gabr42 Posted in Announcements, Developers log, News

While the SmartMS 2.2 RC was generally well accepted, users found few critical bugs that should not make it into a released product. They are now fixed and we proudly present 2.2 Release Candidate 2!

As before, you have two installation options. A portable version can be installed with the SmartUpdate program from the Beta channel. Or you can download and run the installer – either for the full IDE or for the free command line compiler.

Changes since Release Candidate 1

  • RTL fixes regarding form activation and destruction.
  • Fixed: Wrong Form.Name when creating a new Form with dots in the name.
  • Fixed incorrect FHandle type in TW3TagObj.
  • Implemented TW3Dataset.Locate.
  • Fixed TW3Dataset.EOF.
  • Fixed TW3DataSet.Delete.
  • Fixed a bug in commandline compiler where wrong file could be used for compilation.
Stable release Version 2.2

Smart Mobile Studio 2.2 RC

Posted on 13.03.2016 by Smart Mobile Studio Team Posted in Announcements, Developers log, News

Smart 2.2 was long in the beta, but that can only mean it will be a great product, right? We believe we have fixed all important bugs and we proudly present the 2.2 Release Candidate!

This time you have two installation options. Firstly, you can download a portable version with the SmartUpdate program. If you are already running beta-5, you can just start SmartUpdate and it will fetch the new version. Otherwise, you should follow the detailed instructions outlined in the beta-1 announcement.

Secondly, you can install Smart with the setup program. Also available is an installer for the free command line compiler.

Changes since beta-5

  • Conditional compilation symbols can be passed to the smsc compiler by using -defines=list.
  • Added Pixi.js library.
  • Added DateTime demo.
  • Fixed compilation warnings in the RTL.
  • Added Layout Manager to the ‘Multiple forms’ to show how it is correctly used in a multiform application.
  • Added W3C.WebVR unit (http://mozvr.github.io/webvr-spec/).
  • Extended TypeScript header translation.
  • Editor is refocused when internal browser window is closed.
  • Fixed clipping for nested components.
  • Fixed searching in RTL files (Find in Files, Include RTL/Library path).
  • Fixed scrolling in console output.
  • Fixed TW3ScrollInfo.ScrollX and .ScrollY.
  • Fixed compiler bug related to strict helpers.
  • Fixed: OnPrepare handler was not properly forwarded in SmartCL.Inet.REST.
  • Removed old-style date functions from System.DateUtils and added `UTC` parameter to others.
Stable release Version 2.2

Smart Mobile Studio 2.2 (beta-5)

Posted on 24.01.2016 by Smart Mobile Studio Team Posted in Announcements, Developers log, News 8 Comments

Last October we thought that we have version 2.2 all but ready, but then users found some hard to fix problems and our schedule plan got heavily delayed into the 2016. Of course we spent all this time improving Smart in all its aspects and we added a ton of fixes and even some small new features. So now – when the original problems are fixed – we decided to release yet another beta. Hopefully this will be the last one.

If you are already running the beta-4, you can just start the SmartUpdate program and it will fetch the new version. Otherwise, you should follow the detailed instructions outlined in the beta-1 announcement.

Continue reading→

beta

Writing Node.js command-line tools

Posted on 23.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

NodeSmartIn the last article we have focused on how to use Cordova to build hybrid web applications with Smart Mobile Studio. In this article we focus about writing Node.js command-line tools (like Cordova) itself in Smart Mobile Studio.

Continue reading→

command-line node.js npm tool

Hybrid Web-Apps with Cordova

Posted on 19.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

CordovaAbout two years ago a detailed article about how to use Cordova has been published here. As times are changing quickly, an update for this becomes necessary. This article is about building hybrid web-apps with Cordova with Smart Mobile Studio.

Continue reading→

Android Chromium Cordova Hybrid Web-App icons node.js w3C

Events as objects

Posted on 18.01.2016 by Jon Lennart Posted in Developers log 5 Comments

Events are fun right? Well, only in part to be honest. For example, what do you do if you want to catch the same event but at different places?

This is where JavaScript’s addEventListener() comes into play. In short it allows you to add as many event-handlers to the same event as your heart desires. But raw unadulterated JavaScript is a bit of a mess, so I decided to wrap this up in clear cut objects. Oh, and I added a “fixed” event for when you want to have objects for standard events as well.

So now whenever you want to hook an event without ruining your published event-handlers (for instance in TW3CustomControl) you can just use one of these 🙂

Enjoy!

unit eventobjs;

interface

uses 
  w3c.dom,
  SmartCL.Components,
  SmartCL.System;

type


  TEventObjTriggeredEvent = procedure (sender:TObject;EventObj:JEvent);

  TEventObj = class(TObject)
  private
    FOwner:     TW3TagObj;
    FAttached:  Boolean;
    FEventName: String;
  protected
    procedure   HandleEvent(eobj:variant);virtual;
  public
    Property    Attached:Boolean read FAttached;
    procedure   Attach(EventName:String);
    procedure   Detach;
    constructor Create(AOwner:TW3TagObj);virtual;
    destructor  Destroy;Override;
  public
    Property    EventName:String read FEventName;
    Property    Owner:TW3TagObj read FOwner;
    Property    OnEvent: TEventObjTriggeredEvent;
  end;

  TFixedEventObj = class(TObject)
  protected
    FAttached:  Boolean;
    FOwner:     TW3TagObj;
    procedure   HandleEvent(eobj:variant);virtual;
  protected
    function    DoGetEventName:String;virtual;abstract;
  public
    Property    Attached:Boolean read FAttached;
    procedure   Attach;
    procedure   Detach;
    constructor Create(AOwner:TW3TagObj);virtual;
    destructor  Destroy;override;
  public
    Property    Owner:TW3TagObj read FOwner;
    Property    OnEvent: TEventObjTriggeredEvent;
  end;

  TElementRemovedEvent = class(TFixedEventObj)
  protected
    function  DoGetEventName:String;override;
  end;

  TElementAddedEvent = class(TFixedEventObj)
  protected
    function  DoGetEventName:String;override;
  end;

implementation


//#############################################################################
// TElementAddedEvent
//#############################################################################

function TElementAddedEvent.DoGetEventName:String;
begin
  result := "DOMNodeInserted";
end;

//#############################################################################
// TElementRemovedEvent
//#############################################################################

function TElementRemovedEvent.DoGetEventName:String;
begin
  result := "DOMNodeRemoved";
end;

//#############################################################################
// TFixedEventObj
//#############################################################################

constructor TFixedEventObj.Create(AOwner:TW3TagObj);
begin
  inherited Create;
  FOwner:=AOwner;
  Attach;
end;

destructor TFixedEventObj.Destroy;
begin
  Detach;
  inherited;
end;

procedure TFixedEventObj.Attach;
begin
  if FAttached then
  Detach;
  FOwner.Handle.addEventListener(DoGetEventName,@HandleEvent,true);
  FAttached := true;
end;

procedure TFixedEventObj.Detach;
begin
  if FAttached then
  begin
    FOwner.Handle.removeEventListener(DoGetEventName,@HandleEvent,true);
    FAttached := false;
  end;
end;

procedure TFixedEventObj.HandleEvent(eObj:variant);
begin
  if assigned(OnEvent) then
  OnEvent(self, JEvent(eObj));
end;

//#############################################################################
// TEventObj
//#############################################################################

constructor TEventObj.Create(AOwner:TW3TagObj);
begin
  inherited Create;
  FOwner := AOwner;
end;

destructor TEventObj.Destroy;
begin
  if FAttached then
  Detach;
  inherited;
end;

procedure TEventObj.HandleEvent(eobj:variant);
begin
  if assigned(OnEvent) then
  OnEvent(self,JEvent(eObj));
end;

procedure TEventObj.Attach(EventName:String);
begin
  if FAttached then
  Detach;

  FEventName := EventName;
  try
    FOwner.handle.addEventListener(FEventName,@HandleEvent,true);
  except
    FEventname:= '';
    FAttached:=false;
    exit;
  end;
  FAttached:=true;
end;

procedure TEventObj.Detach;
begin
  if FAttached then
  begin
    try
      FOwner.handle.removeEventListener(FEventName,@HandleEvent,true);
    finally
      FEventName := '';
      FAttached := false;
    end;
  end;
end;

end.
code events HTML5 javascript Object Pascal OP4JS Pascal Smart Mobile Studio w3C

Nullable types

Posted on 16.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles

JavaScript – in contrast to Object Pascal – is a dynamic language. Beyond dynamic type checks, this also means that it can be extended at runtime. Thus, variables and with this fields of prototypes may only be present (accessible) when they have been set first. In external JavaScript libraries, these are typically initialized or set, but not necessarily. And sometimes it is even intentional to leave them unset.

Continue reading→

DSharp DWScript javascript Nullable types Object Pascal

Telling a 32bit float from a 64bit float

Posted on 16.01.2016 by Jon Lennart Posted in Developers log 2 Comments

The RTL is getting a bit of attention these days, with plenty of visual effects, tweens and more being added to it. It’s easy to forget that sometimes even the smallest things can be of utmost importance. Like how to tell a single from a double via code!

As you may have noticed, Smart Mobile suddenly got support for streams, memory allocation and the ability to manipulate data on byte and bit level. This may sound trivial but it actually changes how we write and deal with data completely. Under vanilla JavaScript working with bits and bytes can be a huge problem. Most JS developers shun native, raw data like the plauge – because they cant do much with it. Well, thats not going to be a problem for us! Buffers, streams, memory allocation, move, copy — easy as apple pie 🙂

Effect Virtual Machine

Amos Basic 2d and 3d

Amos Basic 2d and 3d

Today I was fiddling with a “mini language” module I have been working on. Actually it’s an effect module that allows you to script and compile effect logic in smart pascal itself, so almost like a second language. If you ever played around with Amos Basic on the Amiga home computer back in the 90’s, you may remember that Amos had a secondary animation language? Well, on that old computer sprites and animation was interrupt based (just think threads if you dont have any idea what hardware interrupts are). This allowed the creator of Amos Basic, Francois Lionet, to add a really cool animation language which was executed in the background — allowing your main program to run in parallell to your animation code.

I dont know how many months and years I spent coding Amos and BlitzBasic in my teens, but let’s just say it was A LOT! Francois Lionet and Mark Sibly, the author of BlitzBasic and the Blitz compiler chain were my absolute childhood heroes.

Well, that animation language (but better naturally) is in effect what I am hoping to achieve with my little virtual machine. I really want it to be super-easy to create awesome effects, and I want it to be fast, flicker free and smooth as a baby’s bottom. So a mini bytecode system seems like just the ticket to get that working – and naturally it’s written in smart itself, so you can play around with it when it’s done.

But back to the problem: I had to extend the TReader and TWriter class with the abillity to handle variant datatypes. This also meant adding “word” as a new RTL datatype to handle those 16 bit values. And last but not least — detecting the difference between 32 and 64 bit floating points.

I mean, if you get that wrong it’s going to cause havoc!

CodeSeg and DataSeg

In a bytecode virtual machine like, say, Java or CLR (common language runtime, .NET style) your compiler have to deal with two different things: code and data. One thing is variables (both global and local), but what about constants? Whenever you pass a fixed value to a procedure, that value is actually a constant. It doesnt change and it will be compiled with your program. Well this is where the compiler get’s smart and picks that up, and the value is stored in a special list. So when the program runs, it will fetch that constant from storage and use it. Or, in case of the CLR, it will be compiled directly into the bytecode if it’s an intrinsic value (long story).

Bytecode galore

Bytecode galore

As you probably guess, that’s called a dataseg (data segment), which is different from a codeseg, where the opcode and “asm” is stored.

So thats when i suddenly realized: we have no function in the RTL to tell the difference between a 32bit float and a 64bit float !

Well here is one way of telling the difference. It’s already incorporated into the Read/Write variant, which are functions I added to TReader and TWriter. So you dont have to worry about it. But for those that have (for some odd reason) been looking for this — here it is:

 function IsFloat32(const x:variant):Boolean;
 begin
  asm
  @result = isFinite(@x) && @x == Math.fround(@x);
  end;
 end;

Not much is it? But yet so important.

HTML5 javascript Object Pascal Smart Mobile Studio

Using external JS libraries with Smart Mobile Studio

Posted on 15.01.2016 by Smart Mobile Studio Team Posted in Developers log, News and articles
Neuron groups, ZEISS-Microscopy, CC

Neuron groups, ZEISS-Microscopy, CC

In the forums there was a discussion about how to wrap existing libraries transparently and with a minimum of overhead. In that discussion an example was given about how to wrap the neural network library brain. To avoid posting the same text here as well, this blog post is about translating another neural network library called ‘Synaptic‘.

Continue reading→

HTML5 javascript Neuronal Networks Object Pascal

Smart Mobile Studio 2.2 (beta-4)

Posted on 08.10.2015 by Smart Mobile Studio Team Posted in Announcements, Developers log, News

Before releasing the final version of Smart Mobile Studio 2.2, we decided to push out one more (we hope it will be the last) beta release, beta-4.

If you are already running the beta-2, you can just start the SmartUpdate program and it will fetch the new version. Otherwise, you should follow the detailed instructions outlined in the beta-1 announcement.

Changes since beta-3

  • Sped-up replace dialog.
  • Built-in basic Cordova support.
  • Added correct MIME type for WOFF and WOFF2 fonts.
  • Added font loading API (see http://www.w3.org/TR/css-font-loading/).
  • Introduced option for resource file path handling.
  • Added ‘Wrap string’ feature to the editor to wrap a string which is longer than the right edge (Editor.RightEdge) to the next line(s).
  • Added a simple geolocation demo.
  • Added a simple geolocation-based sunrise/sunset calculator.
  • Resource files are only written to disk when they are modified, not every time project is saved.
  • Improved working with icons.
  • Added option to have the internal browser log reversed (newest information at the top).
  • Implemented the sort project file feature.
  • Added feature to only write resources when neeeded.
  • Added support for bulk deletion of several project files.
  • Added Splash Screen demo (http://smartmobilestudio.com/2015/09/27/writing-small-splash-screen-pre-loader-code).
  • Improved WebSocket support with binary and BLOB messages.
  • Updated to the latest DWScript.
  • JUInt8ClampedArray was replaced with JUint8Array which has better browser support.
  • Redesigned REST API and updated the demo.
  • REST API appends random number to the end by default (unless .NoRandomize is called).
  • Updated basic examples
  • Fixed method type detection bug in DWScript.
  • Fixed compiler issue with external class fields being assigned in an initialization section.
  • Fixed missing default icon for iOS.
  • Fixed compiler issues with incorrect array assignments.
  • Fixed the bug which occurred when several replacements were done in one line.
  • Fixed old MIME types.
  • Fixed Canvas Application demo.
  • Compiler fixes for overloaded methods & override.
  • Fixed response code in server for failed GET requests.
  • Fixed TW3Label positioning bug.
  • Fixed wrong icon for external resource files
  • Fixed System.Date/JDateHelper.SetAsDateTime and .SetAsLocalDateTime.
  • Fixed: Double-clicking on a ‘folder’ icon crashed the program.
  • Fixed w3_getStyleAsFloat.
  • Fixed icon preview.

Writing small splash screen / pre-loader code

Posted on 27.09.2015 by Smart Mobile Studio Team Posted in Developers log, News

For large applications it is often needed to have a splash screen that is shown while pre-loading the required resources in the background. It is especially needed when the application should run from the web with a low connection speed.

Typically the splash screen should show a static image or simple animation. At the same time it should pre-load and cache all resources which are required to run the application. This well-defined task does not need a lot code to run and thus should be written as efficient as possible to avoid long load times for the splash screen itself.

This article is about writing small splash screen / pre-loader code, which can be used upfront any of your application.

Continue reading→

company logo DOM Efficient HTML5 Pre-loader small Splash screen

Pages

  • About
  • Feature Matrix
  • Forums
  • News
  • Release History
  • Download
  • Showcases
    • The Smart Contest 2013, Round 1 – Graphics
  • Store
  • Documentation
    • Creating your own controls
    • Debugging, exceptions and error handling
    • Differences between Delphi and Smart
    • Get the book
    • Getting started
      • Introduction
      • Local storage, session storage and global storage
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • pmSmart Box Model
      • Themes and styles
    • Layout manager
    • Networking
      • Loading files
      • TW3HttpRequest
      • TW3JSONP
    • Prerequisites
    • Real data, talking to sqLite
    • System requirements
    • Project types
      • Visual project
      • Game project
      • Console project

Archives

  • December 2019
  • December 2018
  • November 2018
  • July 2018
  • June 2018
  • February 2018
  • September 2017
  • April 2017
  • November 2016
  • October 2016
  • September 2016
  • April 2016
  • March 2016
  • January 2016
  • October 2015
  • September 2015
  • July 2015
  • April 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • November 2011
  • October 2011
  • September 2011

Categories

  • Announcements (25)
  • Developers log (119)
  • Documentation (26)
  • News (104)
  • News and articles (16)

WordPress

  • Register
  • Log in
  • WordPress

Subscribe

  • Entries (RSS)
  • Comments (RSS)
  • Prev
  • 1
  • 2
  • 3
  • 4
  • …
  • 13
  • Next
© Optimale Systemer AS