Page 1 of 1

using library

Posted: Fri Jul 10, 2015 6:16 am
by Dongzhi Yang7528784

Hi Support team,

I want to create some custom functions and global constant variables that can be used by all server code script. So I build a library with the following:

-----------------------------

var glob=(function(){

return{ "variable1":"value1",
"variable2":"value2",
"function1":function(p1,p2){//do something}}

})();

---------------------

but when i try to use 'glob' in my script, it always says that 'glob' is not defined.
Could you let me know what went wrong?

Thanks

Dongzhi


using library

Posted: Fri Jul 10, 2015 2:34 pm
by Dongzhi Yang7528784

Hi Team,

Anyone shed a light? I have tried to use the way how moment.js is exposing its function. But I still can't get it to work.

Could you give an example on how to use library?

Thanks

Dongzhi


using library

Posted: Sat Jul 11, 2015 8:20 pm
by Illya Stepanov

Hi Dongzhi -

I'm not sure if the global scope is available for server script code, we will need to clarify this with our backend developers team.


using library

Posted: Sun Jul 12, 2015 12:43 pm
by Dongzhi Yang7528784

Hi lllya,

I have solved the issue. I set "dependencies" on the service script to be dependent on the library, then it works now.

Any my library has been modified to the following:

-------

(function(){

this['settings']={ "variable1":"value1",
"variable2":"value2",
"function1":function(p1,p2){//do something}}

}).call(this);

--------------

Thanks

Dongzhi


using library

Posted: Sun Jul 12, 2015 1:22 pm
by Evgene Karachevtsev

Hi Dongzhi,

Thank you for the update!


using library

Posted: Sun Jul 12, 2015 6:08 pm
by Illya Stepanov

Here is what we have for data transfer between the server scripts: https://devcenter.appery.io/documenta...

I'm afraid that there is no other way to call a script from another.

Maybe also this one: https://devcenter.appery.io/documenta... - data can be transmitted through the request parameters. And no global variables will be needed in this way.