?
Solved

Assigning letters a value

Posted on 2003-03-01
4
Medium Priority
?
156 Views
Last Modified: 2010-04-04
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
Comment
Question by:Quantum
  • 2
4 Comments
 
LVL 3

Expert Comment

by:ILE
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

by:
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

by:CleanupPing
ID: 9316991
Quantum:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 15

Expert Comment

by:VGR
ID: 9331691
split

or paq & norefund
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question