Forum Moderators: open

Message Too Old, No Replies

Time Delay without window object?

timeout delay

         

adrianbromfield

9:54 am on Oct 3, 2008 (gmt 0)

10+ Year Member



Hi guys, i have been looking around for way to do a similar job to setTimeout that doesnt require the window object and have had no luck.

I am writing a jscript that will be ran via a scheduled task, therefore it wont be within a browser window so the window object doesnt exist.

Does anybody know of a function or if i am able to create the window object to use it? or has anybody done a similar thing before and knows how i can do what im trying to do some other way?

thanks for any help in advance guys.

Adrian

httpwebwitch

2:56 pm on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you could create a loop that runs until a specified number of milliseconds have elapsed.

var d = new Date();
var now = d.getTime();
// delay
while (new-now < 10000){
var x= new Date();
var new = x.getTime();
} // delay is over, continue...
alert('hello world');

Caveat. I have no idea if it'll work, and you could easily end up with bugs that cause an infinite loop. Just an idea.

This question is unusual. Scheduled tasks don't usually use or need Timeouts. In the timeless world of crons, everything happens whenever it happens, with no human-interface or time-dependent activities to worry about... can you divulge what you're working on where you'd need a setTimeout where there's no window?

adrianbromfield

2:00 pm on Nov 19, 2008 (gmt 0)

10+ Year Member



hey, yea the problem is the script collects a big bunch of images together and then ftp's them to another server. problem being is that the ftp starts before all the images are collected for some reason. maybe there is a way to check that the file collecting is finished?
Though thanks for your previous message, ill give that a whirl.