Avescripter Timer function

Hi,

I'm trying to update AH's weather docklet so that it updates on startup (which I've managed to do - see: http://www.aqua-soft.org/board/showthread.php?t=34879 ).

Now I need to find a way of delaying a command by a few seconds. Andreas kindly told me to use AveScripters this.Timers.New() timer.

Any advice on how to use this function to delay the execution of a command? Also where can I find out about the list of functions in avescripter in general (and how to use them etc.).

Many thanks,

Garcia.

#387266

If you download the latest beta version, you'll get an desklet that is called SDK which explains stuff. Its still a working progress sdk but it does tell you the information you want.

In your case if you look at the new command for timers it will tell you the parameters you need to send, but the different timertypes are defined in the skindata/timers timer type section. I'll fix that up in the next version.

What you want to do is Timer.New('NAME','1000','alert("hi")', 1);

This will create a new Timer called Name it will execute after 1000 ms, at which point it will call the command alert("hi") and since it was defined as type 1 it will not trigger again.

As for the update on startup, it should be working in most cases with the latest version of avescripter beta. There is 1 case I'm currently fixing that is causing a small conflict, that is, if you force a update on startup it will conflict with the already pending update. XML Data is always fetched on start up of the desklet. You shouldn't need to force it. The forcing is currenlty causing a few issues and I will solve it soon. Its pissing me off a lot.

Are you using the latest beta version?!

#387284

PCM,

Thanks very much for your comprehensive reply.

I am using the latest beta version with the SDK desklet. Your example function above is a big help.

It certainly makes sense that XML data is always fetched on start up. Which makes it all the stranger that AH weather doesn't do so on my system.

Any ideas?

Many thanks,

Garcia.

PS. I tried this:

SlideDown();

this.ForceXDataFetch();

Timer.New('NAME','5000','SlideUp()', 1);

and the Slide Up doesn't seem to work. Am I doing something wrong?

#387291

Ya.. I forgot 1 more thing New returns the timer it doesn't execute it right away.

mytimer = Timer.New('NAME','5000','SlideUp()', 1);

mytimer.ResetTimer(); //Start it.

It doesn't start timers right away, this allows you to create a few timers then start them all at the same time.

I'm working at fixingthe update problem. Should have an update this week.

#387315

mytimer = Timer.New('NAME','5000','SlideUp()', 1);

mytimer.ResetTimer(); //Start it.

Hmmm this doesn't work either. :(

I'm working at fixingthe update problem. Should have an update this week.

Ok thanks, though I was actually enjoying tinerking with avescripter.

Garcia.

#387332

Are you sure?!

I haven't tried it in that desklet, but if SlideUp() is correct that must work after 5 seconds.

I use it in the OSVolume as an example.

Did you check the error log for any errors?

#387540

Are you sure?!

Did you check the error log for any errors?

Good idea - the error log contains the following:

5009  Microsoft JScript runtime error
'Timer' is undefined Line:461 Column:1
-------------------------------

5009 Microsoft JScript runtime error
'Timer' is undefined Line:461 Column:1
-------------------------------

where the line numbering is:

459	 SlideDown();
460 this.ForceXDataFetch();
461 mytimer = Timer.New('Name','5000','SlideUp()', 1);
462 mytimer.ResetTimer();

Any ideas?

Garcia.

#387545

oh ya... its my stupid typos.

It should be Timers or more correctly. Desklet.Timers.New

#387547

Thanks very much pcm, "Timers.New" works a treat (although if I precede it with "Desklet." then I get an error).

Also I was calling the wrong function in AH's weather (in case anyone is interested) - the correct function to call would be FullModeToggle() - if you call SlideUp() SlideDown() directly the desklet gets stuck in small mode and you can't change it.

The final working function is as follows:

function CreateSetup()

{

var IsSmallMode = this.parameters.item('SMALLMODE').value=='1';

if (IsSmallMode)

{

ToggleFullMode();

this.ForceXDataFetch();

mytimer = Timers.New('Name','5000','ToggleFullMode()', 1);

mytimer.ResetTimer();

}

else this.ForceXDataFetch();

UpdateLayerPos();

SetSun();

}

The slide-down slide-up looks really slick.

I love it when a plan comes together ... ;) Thanks again pcm.

Garcia.

#387552