PDA

View Full Version : JScript and Date in init


Nic
06-24-2004, 05:25 AM
Hi,

I am trying to create a new class that extend basevaluecomponent. As part of this I want to create a variable to hold a date. I want to set the initial value of this variable to todays date. To do this I am trying to define an attrbute, that is populated from the init() method calling:

var time=new Date();

when I do a simple time.getYear(); I get an error:

undefined object does not have a property 'getYear'

To questions why is the Jscript failing init and two is an attribute the correct place to store the data for the control.

Cheers

Nic

antun
06-24-2004, 08:17 AM
I think you're doing the right thing on both counts, except time might be a reserved word - try var t = new Date();

-Antun

Nic
06-25-2004, 12:23 AM
Thanks Antun. I found the problem it was with the fact that I had an attribute named time, which will obviously cause a name collision. The problem is the compiler didn't report it as such. I renamed the attribute and all was good.

Thanks

Nic

antun
06-28-2004, 08:49 AM
The problem is the compiler didn't report it as such.

You're absolutely right - there is a feature request filed against this. The solution is either going to be, as you suggested, to have the compiler warn the user, or to remove the problem altogether.

-Antun