{mdm}Script 2.0 Advanced Usage


 

One of the most unique and powerful features of the {mdm}Script™ 2.0 API is it's Synchronous Execution. The easiest way to understand the benefits of this Synchronous behavior, is to compare the syntax to previous Asynchronous execution:

 

Let's assume you want to create a simple Application which allows the user to do the following:

 

a) Browse their local Hard Drive for any Text File.

 

b) Load the contents of the File into their Application.

 

c) Prompt the contents in a simple Dialog.

 

 

Previously, with {mdm}Script™ 1.0, the code required to successfully execute this procedure would be:

 

       

       mdminit();

       

       function loadFile(fileToLoad){

               mdm.loadfromfile(fileToLoad, promptValue);

       }

 

       function promptValue(fileContent){

               mdm.prompt(fileContent);

       }

 

       mdm.browsefile(loadFile);

 

 

 

The above code uses Callbacks to compensate for the Asynchronous Execution. Whilst callbacks do the job, they can become very cumbersome to use and manage when several actions are required.

 

With {mdm}Script™ 2.0 the same procedure can be executed like so:

 

 

       mdm.Dialogs.prompt( mdm.FileSystem.loadFile( mdm.Dialogs.BrowseFile.show() ) );

 

 

 

As you can immediately see, the entire process can be executed in a single line of code! By eliminating the need for Asynchronous Callbacks, code is easier to read, understand and manage. Best of all, updates can be made quickly without having to refer to functions and callbacks which may reside in other frames or symbols.