Uncaught TypeError

I have a bug in my app somewhere that i am trying to find.

The error says:
“basicFunctions.js Uncaught TypeError: Cannot read property ‘toString’ of null. line 738 column 19”

Where exactly is line 738, column 19? Because line 738 of my code is currently a commented section.

Thanks

Run your code in the debugger to see where line 738 is

If i run the app in Chrome and look at the code source, line 738 is commented text.
What is column 19 referring to?

It’s in a helper library called basicFunctions.js.

Are you using the CStr function? If you pass it a bad value, you can get this error.

Thanks.
Yes, i am using the CStr function.
Is that the only function that can cause this error?

Thanks

What value are you passing to CStr?

I use it in a few places. I’m always passing a number.
I’m still not sure which one is causing the problem. I’ll have to dig deeper.

Check all the instances that you are doing this. It looks like may be passing a value which you do not expect. Let me know what you find!

@pedau strings and numbers are objects. The objects have a series of built in methods (ways of manipulating the object). For instance a string of:

var name = “pedau”;

has a method toUpperCase() which converts the string to uppercase like this:

name.toUpperCase();

which results in:

name = "PEDAU";

When you try to call method on an object that doesn’t exist as in this example

function doStuff(name)
{
   console.log( names.toUpperCase() );
}

You will get the error you’ve been getting because names doesn’t exist (we defined name in the function) and since names doesn’t exist the method toUpperCase() will not exist.

In your case you may be dealing with a typo (names vs name), you may be trying to pass a variable that has never been defined OR you may have something like this:

var name;

and since name has been declared but not defined it will also have no methods attached to it.

If I were debugging this, I’d first do a quick scan of the variables/names being passed in and make sure all those are being set. Next I’d console.log() the variables and see which one is not being set. This should pop up fairly quickly.

HTH

Thank you for your replies.
When i get back into it, i’ll do a scan of the variables passed in. I think it will most likely be a typo error at this stage.
Thanks.