Ever seen those extremely annoying banner-ads that proclaim that you name has a magical meaning? Ever wonder how they manage to extract values from something as simple as a name? Well if you promise not to make another banner then i’ll share the secret (he said with a scary voice).
Ye old gematria
This is an old routine for calculating those sublime and mystical numbers of ancient lore. It was converted from ordinary Delphi without much problems. It only needed a minor adjustment on the array constants to work. This shows just how easy it can be to port over ordinary object pascal from other systems and get them running on your website or mobile device.
Note: In the charset constant below I have used ordinary, modern Latin characters. This will of-course go terribly wrong if you attempt to decode ancient Greek or Hebrew. You will need to manually replace the modern characters with the unicode versions of the old alphabets (this code out-dates unicode and widechar).
Enjoy the mystery 🙂
[sourcecode language=”delphi”]
type
TJLGematria = (gmCommon,gmHebrew,gmBeatus,gmSepSephos);
const
JL_GEMATRIA_HEBREW: Array [0..25] of Integer =
([0,2,100,4,0,80,3,5,10,10,20,30,40,50,0,
80,100,200,300,9,6,6,6,60,10,7]);
const
JL_GEMATRIA_COMMON: Array [0..25] of Integer =
([1,2,700,4,5,500,3,8,10,10,20,30,40,50,
70,80,600,100,200,300,400,6,800,60,10,7]);
const
JL_GEMATRIA_BEATUS: Array [0..25] of Integer =
([1,2,90,4,5,6,7,8,10,10,20,30,40,50,70,
80,100,200,300,400,6,6,6,60,10,7]);
const
JL_GEMATRIA_SEPSEPHOS: Array [0..25] of Integer =
([1,2,3,4,5,6,7,8,10,100,10,20,30,40,50,
3,70,80,200,300,400,6,80,60,10,800]);
Function JL_CharToGematria(Value:String;
Const Codex:TJLGematria):Integer;
const
Charset = ‘abcdefghijklmnopqrstuvwxyz’;
var
FIndex: Integer;
FTemp: String;
Begin
result:=0;
FTemp:=value;
FTemp:=lowercase(FTemp);
FIndex:=pos(FTemp,Charset);
If FIndex>0 then
Begin
dec(FIndex);
Case codex of
gmCommon: inc(result,JL_GEMATRIA_COMMON[FIndex]);
gmHebrew: inc(result,JL_GEMATRIA_HEBREW[FIndex]);
gmBeatus: inc(result,JL_GEMATRIA_BEATUS[FIndex]);
gmSepSephos: inc(result,JL_GEMATRIA_SEPSEPHOS[FIndex]);
end;
end;
end;
Function JL_StrToGematria(Value:String;
Const Codex:TJLGematria):Integer;
var
x: Integer;
Begin
result:=0;
value:=lowercase(trim(value));
If length(value)>0 then
for x:=1 to length(value) do
inc(result,JL_CharToGematria(Value[x],Codex));
end;
[/sourcecode]