Soundex Script
Webb - all rights reserved - ©2004
spacer
Author - James Cook
Email: James_Cook@ieee.org
Webpage:

Summary: This script converts a name into the soundex code used by the US census.  The soundex is a coded surname (last name) index based on the way a surname sounds rather than the way it is spelled. Surnames that sound the same, but are spelled differently, like SMITH and SMYTH, have the same code and are filed together. The soundex coding system was developed so that you can find a surname even though it may have been recorded under various spellings.

Every soundex code consists of a letter and three numbers, such as W-252. The letter in the code is always the first letter of the surname. The remaining three numbers are assigned to the remaining letters of the surname as follows:

Number Represents the Letters
  1     B, F, P, V
  2     C, G, J, K, Q, S, X, Z
  3     D, T
  4     L
  5     M, N
  6     R

The letters A, E, I, O, U, H, W, and Y are ignored and not assigned a number. Zeroes are added at the end if necessary to produce a four-character code. Additional letters are disregarded.

Instructions: Simply tap out the surname name you wish to convert to Soundex code.  The soundex will build on the stack.  Script will stop accepting letters after the Soundex code has been satisfied.  Script sets calculator mode to Base 36 to display first letter of code.  Script returns to Base 10 on exit.

Code:

RPN.2.b+4\Soundex\
{o}#'36'UbCa;
{c}#'10'Ub;
[a]0Xa0Xb;
[b]c(0:1:2:3:0:1:2:0:0:2:2:4:5:5:0:1:2:6:2:3:0:1:0:2:0:2);
[e]xac(g1CbXb#'46656'*#'466560'+1xa+Xa:
Cbg1xb=0!(g10=0!(g1Xb#'1296'*+1xa+Xa:Xb):Xb):
Cbg1xb=0!(g10=0!(g1Xb#'36'*+1xa+Xa:Xb):Xb):
Cbg1xb=0!(g10=0!(g1Xb+1xa+Xa:Xb):Xb):
D'Soundex code for this name is\
complete.  Any additional\
letters will be ignored.'d1d1Ca);
"Soundex";
"A"0Ce;
"B"1Ce;
"C"2Ce;
"D"3Ce;
"E"4Ce;
"F"5Ce;
"G"6Ce;
"H"7Ce;
"I"8Ce;
"J"9Ce;
"K"#'10'Ce;
~
"L"#'11'Ce;
"M"#'12'Ce;
"N"#'13'Ce;
"O"#'14'Ce;
"P"#'15'Ce;
"Q"#'16'Ce;
"R"#'17'Ce;
"S"#'18'Ce;
"T"#'19'Ce;
"U"#'20'Ce;
"V"#'21'Ce;
~
"W"#'22'Ce;
"X"#'23'Ce;
"Y"#'24'Ce;
"Z"#'25'Ce;
"New "Ca;
"?:Help"D'Soundex Calculator\James E. Cook (c)
1999\James_Cook@ieee.org'd1;