PDA

View Full Version : I'm a newbie I need help



retart
Dec 9th, 2002, 06:06 PM
It's very simple what i'm trying to do i have downloaded Morse code converter script - By Luke Watson I have changed everything that i want to change but there two things i can't figure out:
1. I can't get it to use spaces or even find that they are there
2. I also want to remove the "EXPLANATION:" part of the script
I have tried to email the creator but his email does not work for reason so i am hoping that someone on here can help i think i have posted enough info on this

Here is the script:


<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Start -->

//Morse code converter- By Luke Watson ([email protected])
//Script featured on JK (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script and more
// Mod by David rittenhouse

var charCodes=new Array(27);
charCodes["a"]="26";
charCodes["b"]="27";
charCodes["c"]="28";
charCodes["d"]="29";
charCodes["e"]="30";
charCodes["f"]="31";
charCodes["g"]="32";
charCodes["h"]="33";
charCodes["i"]="34";
charCodes["j"]="35";
charCodes["k"]="36";
charCodes["l"]="37";
charCodes["m"]="38";
charCodes["n"]="39";
charCodes["o"]="40";
charCodes["p"]="41";
charCodes["q"]="42";
charCodes["r"]="43";
charCodes["s"]="44";
charCodes["t"]="45";
charCodes["u"]="46";
charCodes["v"]="47";
charCodes["w"]="48";
charCodes["x"]="49";
charCodes["y"]="50";
charCodes["z"]="51";
charCodes[" "]="52";
var temp=''

function encode() {
document.morsecode.chars.value=document.morsecode.chars.value.toLowerCase();
document.morsecode.codebox.value="";
temp=''
var chars=document.morsecode.chars.value.split("");

for (a=0; a<chars.length; a++) {
if (chars[a]!=" ") {
if (window.charCodes[chars[a]]) {
document.morsecode.codebox.value+=charCodes[chars[a]];
temp+=chars[a]+"="+charCodes[chars[a]]+"\n";
}
else
temp+=chars[a]+"=(None)\n";
}
else temp+="\n";
}
document.morsecode.codebox.value+="\n\n\nEXPLANATION:\n\n"+temp
}
// -->
</SCRIPT>


Now i belive this is the part i have trouble with:

function encode() {
document.morsecode.chars.value=document.morsecode.chars.value.toLowerCase();
document.morsecode.codebox.value="";
temp=''
var chars=document.morsecode.chars.value.split("");

for (a=0; a<chars.length; a++) {
if (chars[a]!=" ") {
if (window.charCodes[chars[a]]) {
document.morsecode.codebox.value+=charCodes[chars[a]];
temp+=chars[a]+"="+charCodes[chars[a]]+"\n";
}
else
temp+=chars[a]+"=(None)\n";
}
else temp+="\n";
}
document.morsecode.codebox.value+="\n\n\nEXPLANATION:\n\n"+temp
}
what i'm trying to make is a simple encoder for the code i made and i just dont want to have to use find&replace in notepad because it takes to long.
Any Help would great!
David

retart
Dec 9th, 2002, 07:30 PM
ok i have fixed the space error and dont need help with that anymore but i still would like some help with other thing

retart
Dec 9th, 2002, 07:40 PM
Well i fixed everything my self so thanks for the help any way here is the finshed script:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=JAVASCRIPT>
<!-- Start -->

//Morse code converter- By Luke Watson ([email protected])
//Script featured on JK (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script and more
// Mod by David rittenhouse
// To convert My own Code

var charCodes=new Array(31);
charCodes["a"]="26";
charCodes["b"]="27";
charCodes["c"]="28";
charCodes["d"]="29";
charCodes["e"]="30";
charCodes["f"]="31";
charCodes["g"]="32";
charCodes["h"]="33";
charCodes["i"]="34";
charCodes["j"]="35";
charCodes["k"]="36";
charCodes["l"]="37";
charCodes["m"]="38";
charCodes["n"]="39";
charCodes["o"]="40";
charCodes["p"]="41";
charCodes["q"]="42";
charCodes["r"]="43";
charCodes["s"]="44";
charCodes["t"]="45";
charCodes["u"]="46";
charCodes["v"]="47";
charCodes["w"]="48";
charCodes["x"]="49";
charCodes["y"]="50";
charCodes["z"]="51";
charCodes[" "]=" ";
charCodes["."]=".";
charCodes["?"]="?";
charCodes[","]=",";
charCodes["!"]="!";
var temp=''

function encode() {
document.morsecode.chars.value=document.morsecode.chars.value.toLowerCase();
document.morsecode.codebox.value="";
temp=''
var chars=document.morsecode.chars.value.split("");

for (a=0; a<chars.length; a++) {
if (chars[a]!="") {
if (window.charCodes[chars[a]]) {
document.morsecode.codebox.value+=charCodes[chars[a]];
}
else
temp+=chars[a]+"=(None)\n";
}
else temp+="\n";
}
document.morsecode.codebox.value+=""+temp
}
// -->
</SCRIPT>

<FORM name=morsecode>
<P>Type in a word or phrase:</P>
<P>&nbsp;<INPUT style="WIDTH: 500px; HEIGHT:125px" size=28 value=Hi
name=chars> <INPUT onclick=encode() type=button value=Encode><BR><BR><TEXTAREA style="WIDTH: 70%" name=codebox rows=11 cols=50> </TEXTAREA><BR><INPUT onclick="document.morsecode.codebox.select(); document.execCommand('Copy');" type=button value="Copy To Clipboard">
</P></FORM>
<P><FONT face=arial size=-2>This free script provided by</FONT><BR><FONT
face="arial, helvetica" size=-2><A href="http://javascriptkit.com">JavaScript
Kit</A></FONT></P></BODY></HTML>

cg9com
Dec 9th, 2002, 07:50 PM
glad we could help! ;)
nex time you should use more descriptive topics that describe your problem, there are alot of "newbie help" topics posted here ...