Solved

# Assigning letters a value

Posted on 2003-03-01
Medium Priority
154 Views
Hey all,
What I'm trying to do is break down a word and assign a value to each letter, so it needs to work with upper and lowercase just the same.  The values range from 1-9 and get assigned in order of the letters and when it reaches 9 it starts at 1 again (ie. A-1,B-2,I-9,J-1).  Then I need it to add the assigned values together.

Thanks.
0
Question by:Quantum
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 3

Expert Comment

ID: 8049588
wery easy   100% working solution
this assume that in string is only leters

s:='enyword';
rez:=0;
for j:=1 to length(s) do
rez:=rez+((ord[upcase(s[j])]-65) mod 9)+1;

this code if in word u mey have and other things like spaces numbers or enything else

s:='enyword';
rez:=0;
for j:=1 to length(s) do
if upcase(s[j]) in ['A'..'Z'] then
rez:=rez+((ord[upcase(s[j])]-65) mod 9)+1;

wery easy arent?

0

LVL 15

Accepted Solution

VGR earned 2000 total points
ID: 8051750
numerology ? :D

I have a lot of code...

Interface

Function Chiffrage(par:string):string;
Function Chiffre(par:char):byte;

Implementation

Function Chiffre;
Var chif : byte; { ATTENTION : ne s'appliquera qu'aux LETTRES. }

Begin
chif:=(Ord(UpCase(par))-64);
Case chif Of
1..9  : Chiffre:=chif;
10..18 : Chiffre:=(chif-9);
19..26 : Chiffre:=(chif-18);
End; { of CASE }
End;

Function Chiffrage;
Var lresult : string;
i      : byte;
ch     : string; { car bug de TPv4.0 : tjrs pas Char=st1 ! }

Begin
lresult:=par;
For i:=1 to Length(par) Do
Begin
Str(Chiffre(par[i]),ch);
lresult[i]:=ch[1];
End;
Chiffrage:=lresult;
End;
0

Expert Comment

ID: 9316991
Quantum:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

LVL 15

Expert Comment

ID: 9331691
split

or paq & norefund
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
###### Suggested Courses
Course of the Month8 days, 16 hours left to enroll