473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Function not defined problem

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
17 2319
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Thanks Lost... I'll have to take some time and make sense out of it.
LOL

Alex

Jun 24 '07 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jan-Henrik Grobe | last post by:
Hallo, I am coming to this newsgroup with a very strange Problem. I have two c++ files A.cpp and B.cpp....In A.cpp I am creating an openGL window and in B.cpp I have stored the callback...
2
by: nospam_timur | last post by:
I'm writing a Linux device driver that needs to compile with several different Linux versions. In my code, I need to reference certain functions by their address alone. Something like this: ...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
3
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
13
by: Anthony de Almeida Lopes | last post by:
Hello, I am wondering why it is not possible to have a function-like macro like the following: #define __nothread(name) do { \ #ifdef _PTHREAD_H ...
11
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, I have a problem with one of msaccess.exe API calls that work on my desctop but does not work on the laptop from within MS ACCESS. There is a lot of differences between 2 computers...
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
2
by: guy.gorodish | last post by:
hi, i have couple of qeustions: 1. I have built a interop of c dll. In this dll i have a function that expect a pointer to a struct. I want to pass a struct from my c# interop into this c...
28
by: ravi | last post by:
Hello everybody, I am writing a small application which does some work before the user main function starts execution. I am trying to #define the main function. But the problem is that,
2
by: hzgt9b | last post by:
I know how to overwrite a function. Normally this is what I would do: function someFunction() { /* orig definition here */ } //later in the execution stream I would do... someFunction = function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.