Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 11:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: CreateClock Script Problem, Urgent!
PostPosted: October 9th, 2007, 12:21 pm 
Offline

Joined: December 25th, 2004, 3:31 pm
Posts: 178
Hello,

I have a clock object in script:

Code:
QuizClock = CreateClock("ScriptClock","QuizTimer","[mm]:[ss].[f]");


I then start the timer using the code QuizClock.Start(); When I want to stop the timer I use QuizClock.Stop();

This all works fine once I use QuizClock.Stop() to stop the clock. If the stop command is not used and the page is changed or reloaded I get an error once the page is shown again and the clock continues from where it left off.

Error:
Quote:
Script_Puzzle[105] (19, 0) : Object Not Found : The called object is not a valid object type (undefined? null?)


The error refers to QuizClock.Start(), have tried setting vars = 0, tried using the QuizClock.Start() script on page load but it doesn't recognize this once the clock is already created on a previous page. I am unsure why I am having this problem, I would have thought that code QuizClock = CreateClock("ScriptClock","QuizTimer","[mm]:[ss].[f]"); would have reset all clock related variables anyway.

On Debug.trace the QuizClock is null on second load of page. So the final question which I assume will fix it is how do you reset the clock if it is null? It is not possible to use QuizClock.Stop() if the clock is null. Why would it be appearing as null when the page is loaded twice, but works fine the first time.

Any suggestions?


Last edited by josephroddy on October 9th, 2007, 1:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: October 9th, 2007, 1:42 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You would have thought so :-) Also, and odder still is that you can used the Clock.Start command as many times as you like on the page, but if you return to the page from another, then the same command causes a problem.

I think your solution is to check whether the clock is running before issuing the start command. This will probably need a seperate variable such as ClockStatus that you can use to track the status of the clock EG:

if (ClockStatus == 'stopped' )
{
Clock.Start
ClockStatus = running
}


//Then when you stop the clock use

Clock.Stop
ClockStatus = stopped

Mack

P.S I switched to using the ticker action a while back as I find it a lot more flexable.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 9th, 2007, 1:49 pm 
Offline

Joined: December 25th, 2004, 3:31 pm
Posts: 178
Thanks for the reply, I thought I was doing something wrong. The ticker seems like a better option, is this a bug with the clock command, does Digital Workshop know about it I wonder?

I might just add the clock stop command on every button that causes a page change which will be a temp solution. Just looking through now and this won't be as easy as first thought as most buttons are on a master page and the stop command won't work and throws up an error if there is no clock on another page.

Any more suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: October 9th, 2007, 2:13 pm 
Offline

Joined: December 25th, 2004, 3:31 pm
Posts: 178
Added this to my master page exit button

Code:
if (QuizTimer != "00:00.0")
{
   QuizClock.Stop(); // will stop the clock.
   QuizTimer = "00:00.0"   
}


This code will check to see if var QuizTimer is not equal to 00:00.0, if so it will stop the clock and reset var to 00:00.0. Having this will make it work on pages without the clock as exiting from a page with a clock will automatically reset it to 00:00.0


Top
 Profile  
 
 Post subject:
PostPosted: October 9th, 2007, 9:43 pm 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Thanks for the tip, josephroddy!

BTW... I always welcome any scripting tips I can get. Is there a section in the forum for those?

_________________
http://www.akidsheart.com
http://www.storyit.com


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 19th, 2007, 11:06 pm 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
The problem is due to the fact that CreateClock() will return null if the specified clock already exists.
You could check the return value before assigning it to the variable you wanted to use:
Code:
NewClock = CreateClock("ScriptClock","QuizTimer","[mm]:[ss].[f]");
if (NewClock != null)
{
  QuizClock = NewClock;
}
QuixClock.Start()

For a future version I'll look into whether CreateClock() should really return the existing clock if it already exists.

_________________
ddww Opus Developer


Top
 Profile Visit website  
 
 Post subject:
PostPosted: June 27th, 2008, 9:11 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Has this issue been fixed in the latest release of Opus v6.01?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group