i made this code to generate random name, it works but i don't think the result is really great...

basically, how it works :

you paste some text in the memo, click on button1 it will parse the text and put all couple of letters in the listbox. click now on button2, an it will generate a word in the edit

do someone know a better way ?

[pascal]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ D?İclarations priv?İes }
public
{ D?İclarations publiques }
end;

var
Form1: TForm1;

implementation

const
Alphabet = ['a'..'z']; { Uppercase letters have already been deleted! }
Vowels = ['a', 'e', 'i', 'o', 'u', 'y']; { Uppercase letters have already been deleted! }
Consonants = Alphabet - Vowels;

{$R *.dfm}
function validchar(c:char) : boolean ;
begin
result := false;
if (c in ['a'..'z']) then result:=true;
end;

function isConsonant (c:char) : boolean ;
begin
result := false;
if (c in Consonants) then result:=true;
end;

function isVowel (c:char) : boolean ;
begin
result := false;
if (c in Vowels) then result:=true;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,j,k :integer;
buffer,syl :string ;
found:boolean;
begin
for i := 0 to memo1.Lines.Count -1 do
begin
buffer := memo1.Lines[i];
buffer := lowercase(buffer);
j:=1;
while j $$ length(buffer)-1 do
if validchar(buffer[j]) and validchar(buffer[j+1]) then
begin
syl :=buffer[j]+buffer[j+1];
found:=false;
k:=0;
while k $$ listbox1.Items.Count do
begin
if syl = listbox1.Items[k] then found := true;
k:=k+1;
end;
if not found then listbox1.Items.Add(syl);
j:=j+1
end else j:=j+1;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
numsyl,i,j:integer;
str,temp,input:string;
bufferstrings:tstrings;
begin
numsyl:=5 + random(5);
str := listbox1.Items[random(listbox1.Items.Count)];
temp:= str;
//vcc
//ccv
//cvc
//cvv
bufferstrings:=Tstringlist.Create;
for i := 0 to numsyl-1 do
begin
bufferstrings.Clear;
for j := 0 to listbox1.Items.Count-1 do
begin
input:= listbox1.Items[j];

if isVowel( temp[1] ) then
begin
// 1st is a vowel
if isVowel( temp[2] ) then
begin
// 2nd is a vowel = 3rd must be a consonant
if (temp[2] = input[1]) and (not isVowel(input[1])) then bufferstrings.Add(listbox1.Items[j])
end
else
begin
// 2nd is a consonant = 3rd must be a consonant or vowel
if (temp[2] = input[1]) then bufferstrings.Add(listbox1.Items[j]);
end;
end
else
begin
// 1st is a consonant
if isVowel( temp[2] ) then
begin
// 2nd is a vowel = 3rd must be a consonant or vowel
if (temp[2] = input[1]) then bufferstrings.Add(listbox1.Items[j])
end
else
begin
// 2nd is a consonant = 3rd must be a vowel
if (temp[2] = input[1]) and (isVowel(input[1])) then bufferstrings.Add(listbox1.Items[j]);
end;
end;

end;
if bufferstrings.Count <> 0 then
begin
input:=bufferstrings.Strings[random(bufferstrings.Count)];
str := str + input[2];
temp:=input;
end
else
begin
break;
end
end;
edit1.Text:=str;
bufferstrings.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;

end.[/pascal]

replace $$ by <>, i don't know why, it seems that bbcode parser cut a portion of code without this trick...