Subject Re: [firebird-support] Re: udf firebird delphi
Author Martijn Tonies
Try this one:

procedure MixString(Incoming: PChar);
var OutStr, IncomingStr: string;
i, j: Integer;
IncomingStr := StrPas(Incoming);
OutStr := '';
while Length(IncomingStr) > 0
do begin
i := Random(Length(IncomingStr) - 1) + 1;
// we select a random position in an ever becoming smaller string
OutStr := OutStr + IncomingStr[i];
// and copy the character at the selected position to our output string
// without overwriting other characters
Delete(IncomingStr, i, 1);
StrPCopy(Incoming, OutStr);

It might not be particular fast on largish strings though...

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Upscene Productions