Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Tue Jul 27, 2004 9:04 pm
I fail to see how this turns into an infinite loop :/ That's UO minutes it's getting, btw, which changes every few seconds (depending on your setting).
Code: Select all
var iMinute = GetMinute();
var tempMinute = iMinute + 3;
do
{
iMinute = GetMinute();
pUser.SysMessage( "Minute nr: "+iMinute );
}
while (iMinute < tempMinute )
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780 Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked:
0
Been thanked:
0
Post
by giwo » Tue Jul 27, 2004 10:25 pm
That's a good question... looks to me like it should work fine.
Try this instead
Code: Select all
var tempMinute = GetMinute() + 3;
for( var iMinute = GetMinute(); iMinute < tempMinute; iMinute = GetMinute() )
{
pUser.SysMessage();
}
Scott
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Tue Jul 27, 2004 10:44 pm
Hmmm same issue, apparently. Strange.
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576 Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked:
0
Been thanked:
0
Contact:
Post
by Maarc » Wed Jul 28, 2004 2:36 am
That's an easy one
The UO time gets updated once per execution loop. The JS you're executing occurs within the same execution loop. Ergo, GetMinute returns the same value *every* time. It never has a chance to update. It's like doing
Code: Select all
var x = 1;
for( ; x < 10; x = 1 )
{
DoSomething();
}
Guess what happens?
Xuri
Site Admin
Posts: 3704 Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked:
48 times
Been thanked:
8 times
Contact:
Post
by Xuri » Wed Jul 28, 2004 2:38 am
Gah. So it's not possible. Okay.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780 Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked:
0
Been thanked:
0
Post
by giwo » Wed Jul 28, 2004 4:26 am
Heh, quite right.
*blushes*
Ahh well, just run a timer that executes every second, Xu.
Scott