Quantcast
Channel: Syncplify.me
Viewing all articles
Browse latest Browse all 144

The mftJS language (sneak-a-peek)

$
0
0

The mftJS language is like JavaScript, actually it is JavaScript, nearly 100% compatible with the ECMA5 specification, but it has several additional functions and methods specifically designed to develop Managed File Transfer scripts.

The following are some limitations with mftJS:

  • “use strict” will parse, but won’t have any effect
  • The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification
  • mftJS targets ES5. ES6 features (eg: Typed Arrays) are not supported

In addition to the above, some specific limitations apply to the way regular expressions are handled. Therefore, the following syntax is incompatible:

  • (?=)  // Lookahead (positive), currently raises a parsing error
  • (?!)  // Lookahead (backhead), currently raises a parsing error
  • \1   // Backreference (\1, \2, \3, …), currently raises a parsing error

Aside from that, JavaScript programmers will feel extremely familiar with mftJS, and the added power of high-level MFT-specific functions, will make developing MFT tasks with this language a real breeze.

Let’s look at a short code sample:

{
    var scli = NewSftpClient();   
    scli.Host = 'mysftp.server.con:22';
    scli.User = 'sshuser';
    scli.Pass = GetSecret('name of the secret');   
    if (scli.Connect()) {           
        dirList = scli.ListDir('/documents');       
        scli.Close();
    }
    scli = null
}

As you can see the syntax is very familiar to every JavaScript programmer. There are, though, several additional functions.

A small but very important detail: typically JavaScript functions use the camelCase convention, so in order to distinguish and make it extremely clear to tell which functions are mftJS-specific extensions, our own functions are named using the PascalCase convention (first letter is capital).

In the sample code here above you’ll immediately notice the NewSftpClient() function, which creates an SFTP client object that we can later use throughout the rest of the script to carry out SFTP file transfers.

The GetSecret() function, instead, retrieves any secret you have previously stored in Syncplify.me MFT!’s encrypted database… so you don’t have to put your passwords in clear right there in the script.

This is just a very early sneak-a-peek onto the mftJS language, all of the above is subject to change before we get to the actual release of the software. But we thought it would be useful to share with our users, and we’re happy to receive your inputs, suggestions and recommendations.


Viewing all articles
Browse latest Browse all 144

Trending Articles