gilgalbiblewhee
04-05-2005, 08:35 PM
I have a database table where I managed to add with ASP an extra column which breaks down the previous column "text_data" and counts the number of words:
<td>
<% Dim TheString, ArrayTemp, NumberOfWords, Word
TheString = rs("text_data")
ArrayTemp = split(TheString, " ")
NumberOfWords = UBound(ArrayTemp) + 1
' Response.Write "<P>The String is: " & TheString
Response.Write "<P>Number of words: " & NumberOfWords
' Response.Write "<P>Here are the words which compose that string: "
For Each Word In ArrayTemp
Response.Write "<BR><font size=""5"" face=""BSTHebrew"">" & word & "</font> = "
next%>
</td>
My goal is to take each letter and assign them to a number:
a=1,b=2...
Which I have done in another place with JavaScript:
//<![CDATA[
//&&& 1st of 2 instances of getKeyValue(). changed name of Fx, '_h' for hebrew?
function getKeyValue_h(chr) {
//A switch statement is more efficient for this
switch(chr.charAt()){
case "a": return 1;
case "b": return 2;
case "g": return 3;
case "d": return 4;
case "h": return 5;
case "w": return 6;
case "x": return 8;
case "j": return 9;
case "y": return 10;
case "k":;
case "$": return 20;
case "l": return 30;
case "m":;
case "~": return 40;
case "n":;
case "!": return 50;
case "s": return 60;
case "[": return 70;
case "p":;
case "@": return 80;
case "c":;
case "#": return 90;
case "q": return 100;
case "r": return 200;
case "f":;
case "v": return 300;
case "t": return 400;
default: return 0;
}
}
function computeValue(str) {
var ans = 0;
for(var i = 0; i < str.length; i++) {
ans += getKeyValue_h(str.charAt(i));
}
return ans;
}
//]]>
The JavaScript was for a textbox object and textarea. Is there a way to calculate (add) the numbers of the letters assigned after each " = " in the ASP code?
<td>
<% Dim TheString, ArrayTemp, NumberOfWords, Word
TheString = rs("text_data")
ArrayTemp = split(TheString, " ")
NumberOfWords = UBound(ArrayTemp) + 1
' Response.Write "<P>The String is: " & TheString
Response.Write "<P>Number of words: " & NumberOfWords
' Response.Write "<P>Here are the words which compose that string: "
For Each Word In ArrayTemp
Response.Write "<BR><font size=""5"" face=""BSTHebrew"">" & word & "</font> = "
next%>
</td>
My goal is to take each letter and assign them to a number:
a=1,b=2...
Which I have done in another place with JavaScript:
//<![CDATA[
//&&& 1st of 2 instances of getKeyValue(). changed name of Fx, '_h' for hebrew?
function getKeyValue_h(chr) {
//A switch statement is more efficient for this
switch(chr.charAt()){
case "a": return 1;
case "b": return 2;
case "g": return 3;
case "d": return 4;
case "h": return 5;
case "w": return 6;
case "x": return 8;
case "j": return 9;
case "y": return 10;
case "k":;
case "$": return 20;
case "l": return 30;
case "m":;
case "~": return 40;
case "n":;
case "!": return 50;
case "s": return 60;
case "[": return 70;
case "p":;
case "@": return 80;
case "c":;
case "#": return 90;
case "q": return 100;
case "r": return 200;
case "f":;
case "v": return 300;
case "t": return 400;
default: return 0;
}
}
function computeValue(str) {
var ans = 0;
for(var i = 0; i < str.length; i++) {
ans += getKeyValue_h(str.charAt(i));
}
return ans;
}
//]]>
The JavaScript was for a textbox object and textarea. Is there a way to calculate (add) the numbers of the letters assigned after each " = " in the ASP code?