Author Topic: HTML and Javascript examples  (Read 2135 times)

Ger

  • Sr. Member
  • **
  • Posts: 278
HTML and Javascript examples
« on: January 30, 2017, 10:01:38 AM »
Mario (and others),

As indicated in a few other threads, script users will have a decision point later this year with the arrival of IMatch 6: upgrading will mean the loss of Basic scripting; to be replaced by HTML/Javascript. I'm one of the users that use a few Basic scripts for workflow processing, so this means I will have to convert these scripts to HTML/JS. It's good to get my brain moving and learn some html/css/js programming...

So i started to look and modify some existing apps to learn how to retrieve IM variables and write-back a new value. With the help of the geonames app I figured out how to do this. Next is playing with categories and attributes: creating/modifying/deleting categories and (un)assigning files to categories. Same for attributes of course.

It would be great if some (elementary) apps performing standard IMatch functions are available to get some first directions. If somebody has such application examples, that would be great!

Ger

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29729
Re: HTML and Javascript examples
« Reply #1 on: January 30, 2017, 11:10:23 AM »
Don't look at current apps.

These apps rely on the old object model provided by IMatch (they use the same methods as Basic scripts). This stuff is old and will be removed together with Basic Scripting.

To learn about how you write scripts with JavaScript and HTML and IMWS, please go to the

IMatch Anywhere Developer Center

I'm currently building the reference for IMWS and programming there. Since IMatch will have IMWS embedded, the same scripts and technologies can be used for both!
Lots of samples already, and links to useful tutorials on JavaScript and HTML.

Ger

  • Sr. Member
  • **
  • Posts: 278
Re: HTML and Javascript examples
« Reply #2 on: January 30, 2017, 11:55:22 AM »
Ah... I was under the impression that HTML/JS *in* IMatch would continue to exist.

As I did not follow all threads on IMWS; does this mean that scripting within IMatch (not IMA) will be completely disabled?
Or are IMWS scripts available in IM6 directly as well - if so, how?

I will anyway look into the Developer Center (which to me was linked to IMatch Anywhere only).

Ger

thrinn

  • Super Hero
  • ****
  • Posts: 1020
Re: HTML and Javascript examples
« Reply #3 on: January 30, 2017, 12:46:06 PM »
My understanding is: HTML/JavaScript will continue to exist in IMatch 6. But as Mario mentioned in some other post, the object model used to access the database, the files therein and everything else, will presumably change. For example, many Basic scripts first retrieve the "current selection", then do something with these files. If I convert such a Basic script into an IMatch 5 App I would maybe use the same logic. In fact, one small JavaScript function I use for moving files to different directories, dependent on some specific file name patterns, looks like:
Code: [Select]
  function _moveImportedFiles() {
    // The database
    var l_db = IMatchLib.database();
   
    //  Get selected files
    var l_sel = IMatchLib.application().GetFileWindow(IMatchLib.FileWindowType.imfwtCurrent).SelectedFiles;
    if (l_sel.Count < 1)
      return;
     
    for (i=1; i<=l_sel.Count; i++) {
      var l_file = l_sel(i).Name;
     
      for (j=0; j<FileNameMatching.length; j++){
        var l_regex = new RegExp(FileNameMatching[j].pattern);
       
        if ( l_regex.test(l_file) ){
          l_destfolder = l_db.Folders(FileNameMatching[j].folder);
          l_db.MoveFile(l_sel(i), l_destfolder);
//        Set category
          if (FileNameMatching[j].cat.length>0){
            l_db.Categories(FileNameMatching[j].cat).AssignFile(l_sel(i));
          }
        }
      }
    }
  }


But I am not so sure that for scripting in IMatch 6 this function will work. It depends heavily on the current object model: Get the "Application" object, get the File Windows, get the selected files...:
Code: [Select]
var l_sel = IMatchLib.application().GetFileWindow(IMatchLib.FileWindowType.imfwtCurrent).SelectedFiles;
This said, I am confident that it will be possible in IMatch 6 to achieve the same functionality. But the JavaScript code will not exactly be the same. Some rewriting will be necessary.

Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29729
Re: HTML and Javascript examples
« Reply #4 on: January 30, 2017, 02:39:39 PM »
Ah... I was under the impression that HTML/JS *in* IMatch would continue to exist.
It will of course. Even better. But you will no longer use the old object model to access IMatch data - this will go together with the Basic language.
Instead you will access IMatch data using the methods provided by IMWS.

Quote
As I did not follow all threads on IMWS; does this mean that scripting within IMatch (not IMA) will be completely disabled?
Or are IMWS scripts available in IM6 directly as well - if so, how?
IMatch 6 will use an improved version of the App Panel. In it you can run HTML and JavaScript. To get data from IMatch you use the methods provided by IMWS. 

Quote
I will anyway look into the Developer Center (which to me was linked to IMatch Anywhere only).

Whether IMatch WebServices are embedded in IMatch or you run them standalone or even on a separate server - the programming interfaces and how you use them will always be the same. You can run any web site or app that is written to use IMWS also "in" an IMatch app panel!

That's one of the major advantages of this concept.
Other advantages are that your scripts will work with a local (embedded or standalone IMWS) or an IMWS running on a server in your basement or in a data center 5000 miles away.


[/quote]