/    Sign up×
Community /Pin to ProfileBookmark

An alphanumeric calculator

I want to make an alphanumeric calculator. If you don’t know the “Gemetria”, the ancient way of calculating was with the alphabet, where a=1,b=2. The tenth letter and on would be 2 digits (10,20…). 19th letter and on would be 3 digits (100, 200…). So I want to paste words and submit and the value of the word would show. The values of the Hebrew Alphabet are the following:

[quote]

every other key must be 0

)=1
B=2
g=3
d=4
h=5
w=6
x=8
+=9
y=10
k and j=20
l=30
m and e=40
n and a=50
s=60
(=70
p and =80
c and u=90
q=100
r=200
#=300
t=400

[/quote]

I put some things together but couldn’t figure out entirely. The Js section is from a calculator with buttons, and has #1-9. I was wondering if that can be used or to be changed entirely.

This is what I have so far:

[code]
<HTML>
<HEAD>
<TITLE><%= pageTitle %></TITLE>
<script type=”text/javascript”>
<!–
Dim operator, buffer, operation

function Process(){
var frm = document.getElementById(“form1”);
var x = Number(frm.t1.value);
var = (x +);
alert(“( ” + x + ” ) = “)
}

Sub one_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”1″
if operation=0 Then display.value=display.value+”1″
operation=0
End Sub
Sub two_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”2″
if operation=0 Then display.value=display.value+”2″
operation=0
End Sub
Sub three_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”3″
if operation=0 Then display.value=display.value+”3″
operation=0
End Sub
Sub four_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”4″
if operation=0 Then display.value=display.value+”4″
operation=0
End Sub
Sub five_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”5″
if operation=0 Then display.value=display.value+”5″
operation=0
End Sub
Sub six_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”6″
if operation=0 Then display.value=display.value+”6″
operation=0
End Sub
Sub seven_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”7″
if operation=0 Then display.value=display.value+”7″
operation=0
End Sub
Sub eight_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”8″
if operation=0 Then display.value=display.value+”8″
operation=0
End Sub
Sub nine_onclick
if display.value=”0″ Then display.value=””
if operation=1 Then display.value=”9″
if operation=0 Then display.value=display.value+”9″
operation=0
End Sub

Sub plus_onclick
determine()
operator=”plus”
operation=1
End Sub

</script>
</HEAD>
<body class=”body”>

<form id=”form1″ action=”” onsubmit=””>
Enter a word to determine the numerical value:
<input type=”text” name=”t1″/>
<input type=”button” value=”Gemetria” onclick=”Process()”/>
</form>
[/code]

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 13.2004 — Most of what you've got there looks like VBScript...
Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 13.2004 — Anyway, does it just add together the values of each letter? because then:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Calculator&lt;/title&gt;
&lt;script type="text/javascript"&gt;

function getKeyValue(chr) {
chr=chr.toLowerCase();
if(chr==")") return 1;
if(chr=="b") return 2;
if(chr=="g") return 3;
if(chr=="d") return 4;
if(chr=="h") return 5;
if(chr=="w") return 6;
if(chr=="x") return 8;
if(chr=="+") return 9;
if(chr=="y") return 10;
if(chr=="k" || chr=="j") return 20;
if(chr=="l") return 30;
if(chr=="m" || chr=="e") return 40;
if(chr=="n" || chr=="a") return 50;
if(chr=="s") return 60;
if(chr=="(") return 70;
if(chr=="p" || chr=="=") return 80;
if(chr=="c" || chr=="u") return 90;
if(chr=="q") return 100;
if(chr=="r") return 200;
if(chr=="#") return 300;
if(chr=="t") return 400;
return 0;
}

function computeValue(str) {
var ans=0;
for(var i=0; i&lt;str.length; i++) {
ans+=getKeyValue(str.charAt(i));
}
return ans;
}

function calc(inID, outID) {
document.getElementById(outID).value=computeValue(document.getElementById(inID).value);
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body class="body"&gt;

&lt;input type="text" id="gInput"&gt;&lt;/input&gt;
&lt;input type="button" value="calculate value" onclick="calc('gInput', 'gOutput')"&gt;&lt;/input&gt;
&lt;input type="text" id="gOutput" readonly="true"&gt;&lt;/input&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@gilgalbiblewheeauthorSep 13.2004 — I thought it was javascript. Thanks.
Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 13.2004 — No worries. I don't know much about VB, except the genaric look of the stuff (such as keywords like dim and sub i think are analagous to var and function). Is my above code helpful for your question?
Copy linkTweet thisAlerts:
@gilgalbiblewheeauthorSep 13.2004 — That was exactly what I was looking for. Thanks a lot.

You'll find it here:

http://n.1asphost.com/wheelofgod/kjv.asp
Copy linkTweet thisAlerts:
@steelersfan88Sep 13.2004 — Dim actually is nothing like var. I think Charles is the only one to describe it well. The [font=monospace]var[/font] keyword actually adds a property to the window object. No real variable is created. Dim, on the other hand, actually creates a variable in the memory, and clears it out for you, intiializing numeric vars to 0 and string vars to null.

Sub is nothing like function either ?. Sub actually illustrates that a procedure is to take place. While the synonym of Sub when it comes to JS is a function, it is not the same the other way around. The synonym to a JS function is a VB function. A VB Sub does not return a value, it is a basic subroutine [procedure].

Dr. Script
Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 14.2004 — Well, like I said, I know almost nothing about VBScript. I was about 1% right and 99% wrong in my assesment of the keywords.

I mean, adding a property to the window object is like adding a property to the heap memory or stack frame in a programming language like Java. It is a place where you store a value, a value that can vary... sort of like a variable. You can see the confusion.

I'm also so used to Java (real Java, not JavaScript) methods that I think of function=subroutine=method as a chunk of code you define somewhere to encapsulate a particular functionality, rather than "functions" having to return values and "subroutines" or "procedures" not having to return anything. In Java, my primary and favorite language, all are methods. Is there even a way to define a pure subroutine in javascript? I mean, something that would give an error if you even tried to return a value? (Yes yes they are properties of the object created from the function call not return values or whatever, you know what I mean) In that way, sub seems similar to function.

Like I said, wrong but not totally moronic.

Live and learn.
Copy linkTweet thisAlerts:
@steelersfan88Sep 14.2004 — Clearly you have a minimal understanding. I'm a complete expert in VB and Pascal. I like all the old languages (despite [b]V[/b]B being new). Not to mentio nthe part BASIC actually means BASIC (or simple if you will).

I suppose Java and VB would actually have this in common, as you are making the comparison. I, let me put this nicely, don't care for Java.
Copy linkTweet thisAlerts:
@steelersfan88Sep 14.2004 — Just wondering for you code as well. Why not do something such as:[code=php]function getKeyValue(c) {
var chars = new Array()
chars[chars.length] = {char:")",value:"1"};
chars[chars.length] = {char:")",value:"1"};
chars[chars.length] = {char:"b",value:"2"};
chars[chars.length] = {char:"g",value:"3"};
chars[chars.length] = {char:"d",value:"4"};
chars[chars.length] = {char:"h",value:"5"};
chars[chars.length] = {char:"w",value:"6"};
chars[chars.length] = {char:"x",value:"8"};
chars[chars.length] = {char:"+",value:"9"};
chars[chars.length] = {char:"y",value:"10"};
chars[chars.length] = {char:"k",value:"20"};
chars[chars.length] = {char:"j",value:"20"};
chars[chars.length] = {char:"l",value:"30"};
chars[chars.length] = {char:"m",value:"40"};
chars[chars.length] = {char:"e",value:"40"};
chars[chars.length] = {char:"n",value:"50"};
chars[chars.length] = {char:"a",value:"50"};
chars[chars.length] = {char:"s",value:"60"};
chars[chars.length] = {char:"(",value:"70"};
chars[chars.length] = {char:"p",value:"80"};
chars[chars.length] = {char:"=",value:"80"};
chars[chars.length] = {char:"c",value:"90"};
chars[chars.length] = {char:"u",value:"90"};
chars[chars.length] = {char:"q",value:"100"};
chars[chars.length] = {char:"r",value:"200"};
chars[chars.length] = {char:"#",value:"300"};
chars[chars.length] = {char:"t",value:"400"};

for(var i=0,a;a=chars[i];i++) {
if(c==a.char) return a.value;
}
return 0;
}[/code]
I think that this might just allow for a little bit easier modifying. If not an array as above, I would imagine the switch statement is the best option.
Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 14.2004 — Meh, whichever way is easier for him to use is good.

With regards to my minimal understanding of VB, of course I have a minimal understanding; I've never used it (I guess I should learn so you'll stop making fun of my limited knowledge) ? I understand less about the underlying workings of memory management (in particular when it comes to a language I don't know) than I do about algorithms and data structures at the higher level.

If I may ask, so that I can better understand, what is the strict definition of "variable" under which you operate? Get as technical as possible so I can really give it a thorough going over, since obviously the average dictionary definition isn't going to do here ?

And what's so bad about Java? It's really a nice language to code, although slightly limited in usefulness as compared to C/C++ and others by its platform-independent, interpreted nature.

Like everyone else, I'm here to learn. ?
Copy linkTweet thisAlerts:
@steelersfan88Sep 14.2004 — What is so bad about Java? Well, really because the standard programmer doesn't know it. The high level language that is still peaking is C++. Java is catching up, but Java too is falling, and C++ is returning to the top. What is wrong about it ... nothing at all. Some of us are just against things I guess, kinda like designers (NOT coders) and tables.

Obviously a dictionarty will give the basic definition of a variable that we all know as a variable. If you are into Java, I guess the real only reference I can give you is [url=http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html]this[/url]. Variable itself is almost an undefined term that we can't describe, like the color purple.

Which by the way, no-one can describe. Try telling a blind person about purple ... try defining it.
Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 14.2004 — If it's so hard to define clearly, how can you have such a precise notion of what is a variable and what is not? Therefore, in my (admittedly tiny) mind, anything that fits the vague definition we do have (from that link of yours: "A variable is an item of data named by an identifier.") can be called a variable, and, properties of the window object or not, javascript "variables" fit the definition well enough for me.

I like your purple analogy; it can be approximately described by combinations of red and violet wavelengths of light, although just exaclty where it stops being purple and starts being something else is in the eye of the beholder.

Anyway, I'm gonna stop arguing now. I should never have opened my mouth about dim and sub. Oh, what a fool I was! :p, especially about sub (I'm just so darned used to the C and Java way, where, to make a subroutine, you just make a void-returning function/method, that I was blinded to the truth!). Now I know, and knowing's half the battle, G.I. JOE! (Man, it's been a while since I watched that show) ?
×

Success!

Help @gilgalbiblewhee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...