using gs.sleep in a scoped application

dickhirsch
Giga Guru

Hi,

I'm trying to use gs.sleep (1000) in a scoped application and I keep getting an exception:. com.glide.script.fencing.MethodNotAllowedException: Function sleep is not allowed in scope "xxx"

I've tried "GlideSystem.sleep(1000); " but get a similar exception: java.lang.SecurityException: GlideSystem is not allowed in scoped applications exception.

Anyone have any hints.

Thanks,

D.

10 REPLIES 10

I've found some other references (look at the HTML source for the code) to using Java directly.



Packages.java.lang.Thread.sleep(1000);




What do you think....




D.


D,



I tried



Packages.java.lang.Thread.sleep(1000);



Evaluator: java.lang.SecurityException: Use of Packages calls is not permitted in scoped applications Caused by error in script at line 1 ==> 1: Packages.java.lang.Thread.sleep(10000);


Evaluator: java.lang.SecurityException: Use of Packages calls is not permitted in scoped applications Caused by error in script at line -1


Background message, type:error, message: Use of Packages calls is not permitted in scoped applications





Ouch.  



Thanks for testing for me.   I wonder if there is a different solution.



D.


Sven Bauer
Tera Contributor

Hi,



I had the same Problem.


I created a Script Include in Global Scope, Accessible from All AplicationScopes:



var MyGlobalScopeUtils = Class.create();


MyGlobalScopeUtils.prototype = {


      initialize: function() {


      },



        /** Wrapper for gs.sleep


        *


        * @param {Integer} duration in ms


        */


      sleep: function (duration) {


              gs.sleep(duration);


      },



      type: 'MyGlobalScopeUtils'


 


};





In my scoped scripts I can use


var globalUtils = new global.MyGlobalScopeUtils(); // I forgot "global." thanks to ryangarrett for the remark


globalUtils.sleep(1000);



Regards


      Sven


Seven,


With a minor adjustment, that worked perfect, Thank you.


Don't forget to use the global qualifier when you call it from a scoped application




        var globalUtils = new global.MyGlobalScopeUtils();


  1. globalUtils.sleep(180000);


Best,


Ryan