PDA

View Full Version : Where is the Error??


Unregistered
03-29-2001, 12:36 AM
Where is the error in this script below, I have been trying to figure it out for the last couple of hours! It is driving me mad, it tells me that I am missing a ";" (no quotes) at some line at 411 (not same as posted, because it is in the middle of the page) char. 24 here is the script:


<SCRIPT LANGUAGE="JavaScript">

<!--

//store the quotations in arrays

quotes = new Array(34);
authors = new Array(34);

quotes[0] = "No one down here, but the FBI's most unwanted.";
authors[0] = "Mulder";

quotes[1] = "How can an eight year-old boy who can barely multiply be a threat to national security? And people call me paranoid.";
authors[1] = "Mulder";

quotes[2] = "Mulder, You may not be who you are.";
authors[2] = "Scully";

quotes[3] = "I'm not going to give up. Not as long as the truth is out there.";
authors[3] = "Mulder";

quotes[4] = "The truth is still out there, but it's never been more dangerous.";
authors[4] = "X";

quotes[5] = "Don't try and threaten me, Mulder. I've watched presidents die.";
authors[5] = "Cigarette Smoking Man";

quotes[6] = "Nothing dissapears without a trace.";
authors[6] = "Albert Hosteen";

quotes[7] = "Nothing dissapears without a trace.";
authors[7] = "Albert Hosteen";

quotes[8] = "If you were to die now, the truth will die and only the lies survive us.";
authors[8] = "Mr. Mulder";

quotes[9] = "Television does not make a perfectly sane man go out and kill five people. Not even 'must see' TV.";
authors[9] = "Mulder";

quotes[10] = "Everything Dies.";
authors[10] = "Alien Bounty Hunter";

quotes[11] = "That's why they put the I in FBI.";
authors[11] = "Mulder";

quotes[12] = "Mulder: "Tell me I'm crazy." Scully: "You're crazy.";
authors[12] = "";

quotes[13] = "(On phone) I don't know what it is. Maybe a binary sequence of some kind. Could be anything, could be nothing. I know you're busy.. Look, umm.., I know a friend who knows a friend who knows a friend who can get you tickets to a Redskins game. You got it. Alright. You know where to find me? Thanks Danny.";
authors[13] = "Mulder";

quotes[14] = "Mulder: "C'mon, how can an eight-year-old boy who can barely multiply be a threat to national security? People call me paranoid." Scully: "Well, how did Kevin obtain the top-secret information? I mean, where do you think he got it from?" Mulder: (Points to the sky)";

authors[14] = "";

quotes[15] = "Scully: "I have a date." Mulder: "Can you cancel?" Scully: "Unlike you Mulder, I would like to have a life." Mulder: "I have a life!"'

authors[15] = "";

quotes[16] = "You can kill a man, but you can't kill what he stands for. You have to break his spirit first. It's a beautiful thing to see.";
authors[16] = "Cigarette Smoking Man";

quotes[17] = "It begins where it ends. . .in nothingness. A nightmare born from deepest fears; coming to me unguarded. Whispering images unlocked from time and distance. A soul unbound; touched by others but never held. . .on a course charted by some unseen hand; the journey ahead promising no more then my past reflected back upon me. Until, at last, I reach the end; facing a truth I can no longer deny. . .alone. . as ever.";
authors[17] = "Scully";

quotes[18] = "I think that you appreciate that there are extrodinary men and women; and extrodinary moments when history leaps forward on the backs of these individuals. That what can be imagined can be achieved. . .and that we must dare to dream. But that here is no substitute for perceveriance and hard work; and team work, because no one gets there alone. And that while we commemorate the greatness of these events and the individuals who achieved them; we can never forget the sacrifice of those who made these achievments and leaps possible."
"I just thought it was a pretty cool keychain.";
authors[18] = "Mulder & Scully";

quotes[19] = "How did this happen?" "The birds and the bees and the money babies, Mulder." "The birds are doing it, the bees are doing it; even educated MDs are doing it.";
authors[19] = "Mulder & Scully";

quotes[20] = "I owe you everything, Scully, you owe me nothing!";
authors[20] = "Mulder";

quotes[21] = "I got you bad.";
authors[21] = "Scully";

//calculate a random index

index = Math.floor(Math.random() * quotes.length);

//display the quotation

document.write("<DL>\n");

document.write("<DT>" + "\"" + quotes[index] + "\"\n");

document.write("<RIGHT><B><I>" + "- " + authors[index] + "\n"+"</I></B></RIGHT>");

//done

//done -->

</SCRIPT>


Thanks,

Kevin

Ian
03-29-2001, 05:03 AM
Hi, you error is here, it should have a ; at the end, not a '

= "Scully: "I have a date." Mulder: "Can you cancel?" Scully: "Unlike you Mulder, I would like to have a life." Mulder: "I have a life!"'


however, once you get that fixed, I'm sure you will have quite a few more, you will probably also find you cannot use " in the middle of your quotes as this will be closing them. you will have to use a backslash to prevent them being read as part of the script.

= "Scully: \"I have a date.\" Mulder: \"Can you cancel?\" Scully: \"Unlike you Mulder, I would like to have a life." Mulder: \"I have a life!\"";

like so. you will have to do that will all you have " inside.

if you still have problems, please post your url.

Unregistered
03-29-2001, 04:09 PM
It is still giving me an error. at line 413 chr 24, but I can not find it. My url is below, the script should show up right after my counter on the bottom of the page, atleast that is where I want it to be :) This is why I never became a programmer :)


My url: http://www.xfileszone.com/index2.html


Thanks so much for your help.

Kevin

Ian
03-29-2001, 08:34 PM
Hi Kevin, here is your corrected script. there are no errors, simply copy and paste.


<SCRIPT LANGUAGE="JavaScript">

<!--

//store the quotations in arrays

quotes = new Array(22);
authors = new Array(22);
quotes[0] = "No one down here, but the FBI's most unwanted.";
authors[0] = "Mulder";

quotes[1] = "How can an eight year-old boy who can barely multiply be a threat to national security? And people call me paranoid.";
authors[1] = "Mulder";

quotes[2] = "Mulder, You may not be who you are.";
authors[2] = "Scully";

quotes[3] = "I\'m not going to give up. Not as long as the truth is out there.";
authors[3] = "Mulder";

quotes[4] = "The truth is still out there, but it's never been more dangerous.";
authors[4] = "X";

quotes[5] = "Don't try and threaten me, Mulder. I've watched presidents die.";
authors[5] = "Cigarette Smoking Man";

quotes[6] = "Nothing dissapears without a trace.";
authors[6] = "Albert Hosteen";

quotes[7] = "Nothing dissapears without a trace.";
authors[7] = "Albert Hosteen";

quotes[8] = "If you were to die now, the truth will die and only the lies survive us.";
authors[8] = "Mr. Mulder";

quotes[9] = "Television does not make a perfectly sane man go out and kill five people. Not even 'must see' TV.";
authors[9] = "Mulder";

quotes[10] = "Everything Dies.";
authors[10] = "Alien Bounty Hunter";

quotes[11] = "That's why they put the I in FBI.";
authors[11] = "Mulder";

quotes[12] = "Mulder: \"Tell me I'm crazy.\" Scully: \"You're crazy.\"";
authors[12] = "";

quotes[13] = "(On phone) I don't know what it is. Maybe a binary sequence of some kind. Could be anything, could be nothing. I know you're busy.. Look, umm.., I know a friend who knows a friend who knows a friend who can get you tickets to a Redskins game. You got it. Alright. You know where to find me? Thanks Danny.";
authors[13] = "Mulder";

quotes[14] = "Mulder: C'mon, how can an eight-year-old boy who can barely multiply be a threat to national security? People call me paranoid. Scully: Well, how did Kevin obtain the top-secret information? I mean, where do you think he got it from? Mulder: (Points to the sky)";

authors[14] = "";

quotes[15] = "Scully: I have a date. Mulder: Can you cancel? Scully: Unlike you Mulder, I would like to have a life. Mulder: I have a life!";

authors[15] = "";

quotes[16] = "You can kill a man, but you can't kill what he stands for. You have to break his spirit first. It's a beautiful thing to see.";
authors[16] = "Cigarette Smoking Man";

quotes[17] = "It begins where it ends. . .in nothingness. A nightmare born from deepest fears, coming to me unguarded. Whispering images unlocked from time and distance. A soul unbound, touched by others but never held. . .on a course charted by some unseen hand, the journey ahead promising no more then my past reflected back upon me. Until, at last, I reach the end, facing a truth I can no longer deny. . .alone. . as ever.";
authors[17] = "Scully";

quotes[18] = "I think that you appreciate that there are extrodinary men and women, and extrodinary moments when history leaps forward on the backs of these individuals. That what can be imagined can be achieved. . .and that we must dare to dream. But that here is no substitute for perceveriance and hard work, and team work, because no one gets there alone. And that while we commemorate the greatness of these events and the individuals who achieved them, we can never forget the sacrifice of those who made these achievments and leaps possible. I just thought it was a pretty cool keychain.";
authors[18] = "Mulder & Scully";

quotes[19] = "How did this happen? The birds and the bees and the money babies, Mulder. The birds are doing it, the bees are doing it, even educated MD\'s are doing it.";
authors[19] = "Mulder & Scully";

quotes[20] = "I owe you everything, Scully, you owe me nothing!";
authors[20] = "Mulder";

quotes[21] = "I got you bad.";
authors[21] = "Scully";
//calculate a random index

index = Math.floor(Math.random() * quotes.length);

//display the quotation

document.write("<DL>\n");

document.write("<DT>" + "\"" + quotes[index] + "\"\n");

document.write("<RIGHT><B><I>" + "- " + authors[index] + "\n"+"</I></B></RIGHT>");

//done

//done -->

</SCRIPT>

KevDog
03-30-2001, 02:11 PM
Thanks Ian, you are the man! It worked perfectly. Where was my error? I would like to know because it would help me learn and fix my own errors in the future, I spent a good couple of hours trying to get the code to work :(.

Kevin

Ian
03-30-2001, 08:18 PM
Hi Kevin, just a few minor things really (but enough to stop it working of course).

First in your messages, you had several ";" IE: ...distance. A soul unbound; touched ...
this was being confused with the closing ;, of each line.

Also, using " inside your messages. IE: ...Mulder: "Tell me I'm crazy." Scully...
was doing the same as above - it was trying to close the message at the next " but not finding ; beside it. The only way to write speech marks within speach marks is to use the back slash "\".
...Mulder: \"Tell me I'm crazy.\" Scully...
then the browser will read them as text, not script.

Next, your array was set for more arrays than you had. was 34, now 22.
This was looking for more than you had, and could not find anymore so was creating "Undifined" error messages on screen.

In short, make sure the number of your arrays is the same as the number you have, and back slash any quotes you do not wish to be interpreted as script.

Hope this helps, and welcome to the board by the way :) (now that you have registered)