photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: Ger on August 30, 2017, 08:42:43 PM

Title: Copy Data App - varBrowser
Post by: Ger on August 30, 2017, 08:42:43 PM
When using the Browse Variables button in the Copy Data App, I can select a variable, but when clicking OK, the result is not copied in the expression field. Is that a small bug in the app or am I doing something wrong?

Furthermore, the documentation (https://www.photools.com/dev-center/doc/imatch/IMatch.html (https://www.photools.com/dev-center/doc/imatch/IMatch.html)) states varBrowser being a Promise:

varBrowser(params) → {Promise})

Shouldn't the code then be something like:

IMatch.varBrowser(0).then(function(r) {...

Finally, the example in the documentation uses the statement:

var res = IMatch.browseVariables(100);


Code in the Copy Data App:

              $('#btn-browser').click(function(e) {
                    var result = IMatch.varBrowser(0); // We use the selected file as the template file
                    if (result.result == 'ok') {
                        $('#expression').val($('#expression').val() + result.var);
                        saveData();
                    }
                    e.preventDefault();
                    return false;
                });
            });


Ger
Title: Re: Copy Data App - varBrowser
Post by: Mario on August 30, 2017, 08:52:42 PM
Thanks. Fixed for the next release. Old version shipped  :-[
Correct is:

                $('#btn-browser').click(function(e) {
                    IMatch.varBrowser(0).then(function(response) {
                        if (response.result == 'ok') {
                            $('#expression').val($('#expression').val() + response.var);
                            saveData();
                        }
                    });
                    e.preventDefault();
                    return false;
                });
Title: Re: Copy Data App - varBrowser
Post by: Ger on August 30, 2017, 08:59:23 PM
Thanks, Mario, just wanted to post my working version.


            $('#btn-browser').click(function (e) {
                IMatch.varBrowser({
                    samplefile: 0
                }).then(function (r) {
                    if (r.result == 'ok') {
                        $('#expression').val($('#expression').val() + r.var);
                        saveData();
                    }
                });
                e.preventDefault();
                return false;
            });


Ger