By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,477 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,477 IT Pros & Developers. It's quick & easy.

Function not defined problem

P: n/a
Hi all...

I'm new to Java programming. I've seen how finicky java is as far case
and space sensitivity sensitivity is concerned. However, I'm slowly
getting hang of it.
I came accross this weird problem that I just can't figure out. First
of all, here is a link to the script:

http://www.ve3gop.com/aprs/

Explorer seems to open it fine, however the Firefox is pretty fussy
about it. I have just installed Firebug and everytime I load up the
page in Firefox, it returns with the following error:

UpdateData is not defined
Repeatericon.iconAnchor = new GPoint(6, 20);

I checked and rechecked the code and this doesn't make any sense to
me.

Can anyone help?

thanks
Alex

Jun 15 '07 #1
Share this Question
Share on Google+
17 Replies


P: n/a
On Jun 15, 9:50 am, Navaidstech <awie...@hotmail.comwrote:
Hi all...

I'm new to Java programming. I've seen how finicky java is as far case
and space sensitivity sensitivity is concerned. However, I'm slowly
getting hang of it.
Javascript ain't Java. Trust this, eh?
I came accross this weird problem that I just can't figure out. First
of all, here is a link to the script:

http://www.ve3gop.com/aprs/

Explorer seems to open it fine, however the Firefox is pretty fussy
about it. I have just installed Firebug and everytime I load up the
page in Firefox, it returns with the following error:

UpdateData is not defined
Repeatericon.iconAnchor = new GPoint(6, 20);

I checked and rechecked the code and this doesn't make any sense to
me.
It's a timing issue, you're calling UpdateData
immediately before its definition. Move the call.

---
Geoff

Jun 15 '07 #2

P: n/a
Javascript ain't Java. Trust this, eh?

What now???!!! I've seen a few things over the past few days that
would make me pull my hair, but I didn't see this one coming. LOL.

>
UpdateData is not defined
Repeatericon.iconAnchor = new GPoint(6, 20);
I checked and rechecked the code and this doesn't make any sense to
me.

It's a timing issue, you're calling UpdateData
immediately before its definition. Move the call.
You mean move the entire Repeater icon definition along with the
UpdateData call to somewhere else in the program so it's not too close
to the actual function?

thanks
ALex

Jun 15 '07 #3

P: n/a
On Jun 15, 3:21 pm, Navaidstech <awie...@hotmail.comwrote:
Javascript ain't Java. Trust this, eh?

What now???!!! I've seen a few things over the past few days that
would make me pull my hair, but I didn't see this one coming. LOL.
UpdateData is not defined
Repeatericon.iconAnchor = new GPoint(6, 20);
I checked and rechecked the code and this doesn't make any sense to
me.
It's a timing issue, you're calling UpdateData
immediately before its definition. Move the call.

You mean move the entire Repeater icon definition along with the
UpdateData call to somewhere else in the program so it's not too close
to the actual function?
You could, I generally put function definitions
in the head and leave the body for the immediate
script. But the basic problem is the parser seeing
the UpdateData call, and trying to execute it,
before it has read and created the function.

This is quick copy from your script:

<*snip*>

UpdateData(RepeaterLocation);

function UpdateData(FollowMarker) {

<*snip*>
Quick fix is just changing it to:

function UpdateData(FollowMarker) {
....
}

UpdateData(RepeaterLocation);

----
Geoff

Jun 15 '07 #4

P: n/a
Right you are Geoff...

I moved the repeater definition to end of the script and now it works
great.
I would have never thought this would make a difference because I
thought that once a function is called, the script will find it
somehow and execute it... not so, it seems.

Thanks for the suggestion of moving all the functions to the head...
this sure will alleviate a ton of headaches.

Thanks for your help Geoff...

Alex

Jun 15 '07 #5

P: n/a
Navaidstech <aw*****@hotmail.comwrote in news:1181939736.543979.211250
@p77g2000hsh.googlegroups.com:
I would have never thought this would make a difference because I
thought that once a function is called, the script will find it
somehow and execute it... not so, it seems.
It depends on the programming language... With PHP for example, you can put
the function literally anywhere and it will be found/executed, but alas
with Javascript, its top to bottom....

Jun 15 '07 #6

P: n/a
On Jun 16, 5:21 am, Navaidstech <awie...@hotmail.comwrote:
Javascript ain't Java. Trust this, eh?

What now???!!! I've seen a few things over the past few days that
would make me pull my hair, but I didn't see this one coming. LOL.
UpdateData is not defined
Repeatericon.iconAnchor = new GPoint(6, 20);
I checked and rechecked the code and this doesn't make any sense to
me.
It's a timing issue, you're calling UpdateData
immediately before its definition. Move the call.
While that may fix the problem, it is not because the call is before
the declaration - that order is not important. It is more likely that
a parameter passed in the call has not been set or is undefined (which
is the error that Safari reports).

updateData is called with a parameter RepeaterLocation, and *that* is
not defined until the very end. The function was being called with an
undeclared parameter.
>
You mean move the entire Repeater icon definition along with the
UpdateData call to somewhere else in the program so it's not too close
to the actual function?
If your function expects to be passed a value, ensure that happens or
handle cases where it doesn't. You can read about Identifier
Resolution, Execution Contexts and Scope Chains here:

<URL: http://www.jibbering.com/faq/faq_not....html#clIRExSc >
--
Rob

Jun 16 '07 #7

P: n/a
On Jun 16, 7:46 am, Good Man <h...@letsgo.comwrote:
Navaidstech <awie...@hotmail.comwrote in news:1181939736.543979.211250
@p77g2000hsh.googlegroups.com:
I would have never thought this would make a difference because I
thought that once a function is called, the script will find it
somehow and execute it... not so, it seems.

It depends on the programming language... With PHP for example, you can put
the function literally anywhere and it will be found/executed, but alas
with Javascript, its top to bottom....
That is not correct. While resolution proceeds from top top bottom
(which I think all programming languages do), function and variable
declarations are resolved before any code is executed. Try:

x();
// As much code as you like
function x(){ alert('hi');}
Try the link in my reply to Navaidstech.

--
Rob

Jun 16 '07 #8

P: n/a
On Jun 16, 11:31 am, RobG <r...@iinet.net.auwrote:
On Jun 16, 7:46 am, Good Man <h...@letsgo.comwrote:
Navaidstech <awie...@hotmail.comwrote in news:1181939736.543979.211250
@p77g2000hsh.googlegroups.com:
I would have never thought this would make a difference because I
thought that once a function is called, the script will find it
somehow and execute it... not so, it seems.
It depends on the programming language... With PHP for example, you can put
the function literally anywhere and it will be found/executed, but alas
with Javascript, its top to bottom....

That is not correct. While resolution proceeds from top top bottom
(which I think all programming languages do), function and variable
declarations are resolved before any code is executed. Try:

x();
// As much code as you like
function x(){ alert('hi');}

Try the link in my reply to Navaidstech.
On reflection, Richard's article may be a bit much for some. The
bottom line is that for each script block, declarations are all
processed first, then execution begins. Here's a simple example:

<script type="text/javascript">

x('hi'); // Shows 'hi';

var a = 'hi from a';
x(a); // Shows 'hi from a'

x(b); // Shows 'undefined' since b is declared before
// execution but not assigned a value until later

x(z); // Script aborts, "Can't find z" because
// it hasn't been declared.

// x is declared down here
function x (y){ alert(y); }

var b = 'hi from b'; // b declared but not assigned a value
// until execution gets to this point

</script>
--
Rob

Jun 16 '07 #9

P: n/a
While that may fix the problem, it is not because the call is before
the declaration - that order is not important. It is more likely that
a parameter passed in the call has not been set or is undefined (which
is the error that Safari reports).
Rob, is this what Safari reports now?
Prior to Geoff's reply the entire repeater icon creation and
definition of the RepeaterLocation variable took place BEFORE the
UpdateLocation function. Firefox was reporting problems with this and
refused to run, while IE6 took it and was pretty happy with it.
I have since moved this icon creation procedure to the end and now
both Firefox and Exploder are happy.
updateData is called with a parameter RepeaterLocation, and *that* is
not defined until the very end. The function was being called with an
undeclared parameter.
Again, I'm not sure if you are referring to the old code but as it is
now, I'm declaring the RepeaterLocation variable first followed by
call to the function and passing on the RepeaterLocation parameter.
>
If your function expects to be passed a value, ensure that happens or
handle cases where it doesn't. You can read about Identifier
Resolution, Execution Contexts and Scope Chains here:

<URL:http://www.jibbering.com/faq/faq_notes/closures.html#clIRExSc>
More stuff to learn...LOL!
THanks!

Alex

Jun 16 '07 #10

P: n/a
On Jun 15, 9:31 pm, RobG <r...@iinet.net.auwrote:
On Jun 16, 7:46 am, Good Man <h...@letsgo.comwrote:
Navaidstech <awie...@hotmail.comwrote in news:1181939736.543979.211250
@p77g2000hsh.googlegroups.com:
I would have never thought this would make a difference because I
thought that once a function is called, the script will find it
somehow and execute it... not so, it seems.
It depends on the programming language... With PHP for example, you can put
the function literally anywhere and it will be found/executed, but alas
with Javascript, its top to bottom....

That is not correct. While resolution proceeds from top top bottom
(which I think all programming languages do), function and variable
declarations are resolved before any code is executed. Try:

x();
// As much code as you like
function x(){ alert('hi');}

Try the link in my reply to Navaidstech.

--
Rob
This is the idea I had set up prior to moving the icon procedure to
the end.
As I mentioned in my previous reply, IE6 was happy while Firefox was
not...

Alex

Jun 16 '07 #11

P: n/a
On Jun 17, 1:23 am, Navaidstech <awie...@hotmail.comwrote:
While that may fix the problem, it is not because the call is before
the declaration - that order is not important. It is more likely that
a parameter passed in the call has not been set or is undefined (which
is the error that Safari reports).

Rob, is this what Safari reports now?
No, it now says "can't find variable postamble" (as does Firefox)
because you've inserted a script element beyond the closing html tag
that tries to call it. You must put script elements in the body or
head.

Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.
--
Rob

Jun 17 '07 #12

P: n/a
RobG wrote:
Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.
Do you know offhand, if I create a website that is perfectly viewable in
Safari (Windows), can I safely assume that it will look the same in
Safari (Mac) or is that a pipe dream?

My next question, assuming it's a pipe dream will be would you mind
viewing a site of mine and taking a screenshot? (My Mac is
incapacitated at the moment, or I would check myself.)

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 17 '07 #13

P: n/a
On Jun 17, 1:42 pm, -Lost <maventheextrawo...@techie.comwrote:
RobG wrote:
Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.

Do you know offhand, if I create a website that is perfectly viewable in
Safari (Windows), can I safely assume that it will look the same in
Safari (Mac) or is that a pipe dream?
I don't know, but I would assume so (i.e. it will look the same, not
it's a pipe dream ;-) )

My next question, assuming it's a pipe dream will be would you mind
viewing a site of mine and taking a screenshot? (My Mac is
incapacitated at the moment, or I would check myself.)
Sure, either put the URL here or e-mail me.
--
Rob

Jun 17 '07 #14

P: n/a
RobG wrote:
On Jun 17, 1:42 pm, -Lost <maventheextrawo...@techie.comwrote:
>RobG wrote:
>>Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.
Do you know offhand, if I create a website that is perfectly viewable in
Safari (Windows), can I safely assume that it will look the same in
Safari (Mac) or is that a pipe dream?

I don't know, but I would assume so (i.e. it will look the same, not
it's a pipe dream ;-) )
Great!
>My next question, assuming it's a pipe dream will be would you mind
viewing a site of mine and taking a screenshot? (My Mac is
incapacitated at the moment, or I would check myself.)

Sure, either put the URL here or e-mail me.
Thanks. E-mail sent.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 17 '07 #15

P: n/a
On Jun 16, 9:29 pm, RobG <r...@iinet.net.auwrote:
On Jun 17, 1:23 am, Navaidstech <awie...@hotmail.comwrote:
While that may fix the problem, it is not because the call is before
the declaration - that order is not important. It is more likely that
a parameter passed in the call has not been set or is undefined (which
is the error that Safari reports).
Rob, is this what Safari reports now?

No, it now says "can't find variable postamble" (as does Firefox)
because you've inserted a script element beyond the closing html tag
that tries to call it. You must put script elements in the body or
head.
Yeah, I'm not sure how that sneaked in there. I thought I had it
deleted before.
It's gone now, anyway.
>
Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.

--
Rob
OK...this brings up a question: what is the difference between the
application/xml and text/html?
thanks
ALex

Jun 17 '07 #16

P: n/a
Navaidstech wrote:
On Jun 16, 9:29 pm, RobG <r...@iinet.net.auwrote:
>On Jun 17, 1:23 am, Navaidstech <awie...@hotmail.comwrote:
>>>While that may fix the problem, it is not because the call is before
the declaration - that order is not important. It is more likely that
a parameter passed in the call has not been set or is undefined (which
is the error that Safari reports).
Rob, is this what Safari reports now?
No, it now says "can't find variable postamble" (as does Firefox)
because you've inserted a script element beyond the closing html tag
that tries to call it. You must put script elements in the body or
head.

Yeah, I'm not sure how that sneaked in there. I thought I had it
deleted before.
It's gone now, anyway.
>Your DOCTYPE is XHTML strict, so all browsers should completely ignore
the error, however if you serve the page as application/xml, IE won't
show anything at all. A check using the Live HTTP headers plugin for
Firefox shows you are serving it as text/HTML, so the DOCTYPE is
ignored and browsers are treating it as poorly coded HTML.

OK...this brings up a question: what is the difference between the
application/xml and text/html?
thanks
All files, regardless of what they may be should always be sent with the
correct MIME type so that your UA or browsing device can make the
smartest possible choice in regards to handling the file.

http://www.webstandards.org/learn/ar...skw3c/sep2003/
http://www.w3.org/2003/01/xhtml-mime...nt-negotiation

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 17 '07 #17

P: n/a
Thanks Lost... I'll have to take some time and make sense out of it.
LOL

Alex

Jun 24 '07 #18

This discussion thread is closed

Replies have been disabled for this discussion.