Re: RandomFrom problem: MathStrUtils not found

Posted by Jenny, DelphiLand Team

In Reply to RandomFrom problem: MathStrUtils not found posted by Phil Birell

: I want to use the function RandomFrom(ArrayOfStrings) in my program. I tried already to narrow the problem to the following simple program:

: procedure TForm1.Button1Click(Sender: TObject);
: begin
: ShowMessage(RandomFrom(['a', 'b', 'c']);
: end;
: ...but still Delphi gives an error:
: [Fatal Error] Unit1.Pas(8): File not found: 'MathStrUtils.dcu'

RandomFrom(SValues: array of string) is declared in the Delphi unit StrUtils. So you have to add StrUtils to the "uses" clause of your unit(s) where you use the function RandomFrom().

Note 1: RandomFrom is not available in Delphi 4.
Note 2: Some Help files of Delphi 7 say that this function is declared in "MathStrUtils". That's wrong, it must be: "StrUtils".

Jenny, DelphiLand Team.