Randomize the lines in a file
Randomize the lines in a file
I am a bit rusty on my Pascal. I have a need to randomize the lines in a text file. Does anyone have a sample script that might help me get started? I need to do this several times a week so it seems worth the effort to create a script. The files contain between 10 and 20 thousand lines.
Don't know if this works for you but it's a start, i don't think it will run very fast on so many lines.
Code: Select all
// Pascal script
// Global variables
var
i, n, m: integer;
temp: WideString;
// Enter code here
begin
Randomize;
// the times you want to run it
for i := 1 to 2 do begin
for n := 0 to Document.LineCount-1 do
begin
// pick a random number
m := Trunc(Random * Document.LineCount);
// swap lines
temp := Document.Lines(n);
Document.Lines(n) := Document.Lines(m);
Document.Lines(m) := Temp;
end;
end;
end.
Re: Randomize the lines in a file
begin
// pick a random number
m := Trunc(Random * Document.LineCount);
// swap lines
temp := Document.Lines(n);
Document.Lines(n) := Document.Lines(m);
Document.Lines(m) := Temp;
// pick a random number
m := Trunc(Random * Document.LineCount);
// swap lines
temp := Document.Lines(n);
Document.Lines(n) := Document.Lines(m);
Document.Lines(m) := Temp;
Pass your itil certification and PW0-105 braindumps exams in first try by using our northwestern passguide and www.usna.edu and best quality