[code lang=”delphi”]Var
LoopInt : Integer;
DirName, FullName, RanStr : String;
FileSavedTo : TextFile;
// Length of string to create
RandArray : Array[0..4087] Of Char;
FirstCount : Extended;
begin
FirstCount := GetTickCount;
Label2.Caption := ”;
Randomize;
RanStr := ”;
DirName := Directory95ListBox1.Directory;
If DirName[Length(DirName)] <> ‘\’ Then DirName := DirName + ‘\’;
FullName := DirName + Edit1.Text;
If FileExists(FullName) Then DeleteFile(FullName);
For LoopInt := Low(RandArray) To High(RandArray) Do
Begin
RanStr := RanStr + Chr(Random(255 – 32 + 1) + 32);
End;
AssignFile(FileSavedTo, FullName);
If FileExists(FullName) Then
Reset(FileSavedTo)
Else
Rewrite(FileSavedTo);
Writeln(FileSavedTo, RanStr);
CloseFile(FileSavedTo);
Label2.Caption := ‘DONE’;
Label4.Caption := FloatToStr((GetTickCount – FirstCount) / 1000);
FileListBox1.Update;
[/code]
[tags]Delphi, Strings[/tags]
0 Kommentare zu “Random String”