---
url: >-
  /statelake/scripting-reference/functions-and-procedures/string-functions/soundex-functions/soundexint.md
---

# SoundexInt

**SoundexInt** is a function that uses the **Soundex** algorithm to convert the string **AText** into an integer that represents the phonetic value of the source string **AText**.

The parameter **ALength** is the number of characters to use when generating the **Soundex** string, where the range accepted is from 1 through to 8 due to the capacity of the integer type **TSoundexIntLength**.

::: info
The length specified by **Alength** refers to the **Soundex** code that is represented by the integer result, and not the actual integer result.
:::

If you specify an integer greater than 8 for **ALength** in this function, you will receive a nonsense value in return.

Both the **AText** and **ALength** values are accepted by either direct entry into the function, or via a variable.

The function is designed to encode words or names, and not entire sentences - although the **Soundex** value produced for a phrase or sentence may be quite similar.

Case does not matter for **AText**.

Please also refer to the string function [Soundex](/statelake/scripting-reference/functions-and-procedures/string-functions/soundex-functions/soundex).

For information regarding the decoding of these resulting integer values, please refer to [DecodeSoundexInt](/statelake/scripting-reference/functions-and-procedures/string-functions/soundex-functions/decodesoundexint).

**Declaration**: Function SoundexInt(const AText : string; ALength : TSoundexIntLength) : Integer;

Examples follow.

```pascal
procedure ScriptEvent (var Value : variant);
var

  sSound, sInput : string;
  aLen : TSoundexLength;
  siSound, smSound : integer;
  aLenInt : TSoundexIntLength;

begin
  LogInfo('');
  sInput := 'MCGILLICUDDY';                           //All uppercase
  siSound := SoundexInt(sInput, 8);                   //Range of 8 (max)
  smSound := SoundexInt(sInput, 5);                   //Range of 5
  LogInfo(sInput+'(8) equals '+IntToStr(siSound)+'   '+sInput+' (5) equals '+IntToStr(smSound));

  sInput := 'mcgillicuddy';                           //All lowercase
  siSound := SoundexInt(sInput, 8);                   //Range of 8 (max)
  smSound := SoundexInt(sInput, 5);                   //Range of 5
  LogInfo(sInput+'(8) equals '+IntToStr(siSound)+'   '+sInput+' (5) equals '+IntToStr(smSound));

  sInput := 'Pumpkin';                                //Sentence case
  siSound := SoundexInt(sInput, 8);                   //Range of 8 (max)
  smSound := SoundexInt(sInput, 5);                   //Range of 5
  LogInfo(sInput+'(8) equals '+IntToStr(siSound)+'   '+sInput+' (5) equals '+IntToStr(smSound));

  sInput := 'Romano-Wickham';                         //Hyphenated
  siSound := SoundexInt(sInput, 8);                   //Range of 8 (max)
  smSound := SoundexInt(sInput, 5);                   //Range of 5
  LogInfo(sInput+'(8) equals '+IntToStr(siSound)+'   '+sInput+' (5) equals '+IntToStr(smSound));

  aLenInt := 8;                                       //Range of 8 (max)
  siSound := SoundexInt('Robinson Crusoe', aLenInt);  //Christian and surname
  aLenInt := 5;                                       //Range of 5
  smSound := SoundexInt('Robinson Crusoe', aLenInt);
  LogInfo('Robinson Crusoe(8) equals '+IntToStr(siSound)+'   '+'Robinson Crusoe(5) equals '+IntToStr(smSound));
  LogInfo('');

end;
```
