SRL Archive - Help

Random usernames; return key


i puzzle i

2013-01-06 17:13:42

I have a function list, that grabs a specified line number in usernames.dat
The problem is it's including the enter key before the line of text.

Could anyone help me with making it output just straight "username", and not hitting return before typing "username".



This is what im using. Sorry im just clueless as to how to do this.

program ReadLines;
var fileno:integer;
//Reads a file
function ReadFile(RelativePath : string) : string;
begin
FileNo := OpenFile(RelativePath, true);
If FileNo > -1 then
begin
If not(ReadFileString(FileNo, Result, FileSize(FileNo))) then
Result := 'error';
CloseFile(FileNo);
end else Result := 'error'
end;

//Writes a new file or overwrites existing one
function WriteFile(RelativePath, Content : string) : boolean;
begin
Result := true;
FileNo := RewriteFile(ScriptPath + RelativePath, true);
If FileNo > -1 then
begin
If not(WriteFileString(FileNo, Content)) then
Result := false;
CloseFile(FileNo);
end else Result := false;
end;

//Adds to an existing file
function AppendFile(RelativePath, Content : string) : boolean;
begin
Result := true;
If not(ReadFile(RelativePath) = 'error') then
WriteFile(RelativePath, (ReadFile(RelativePath) + Content))
else Result := false;
end;

//Reads a line out of a file specified by line
function ReadFileLine(RelativePath : string; line : integer) : string;
var
currentline : integer;
filebuffer : string;
begin
currentline := line;
filebuffer := ReadFile(RelativePath);
If line = 0 then
begin
delete(filebuffer, pos(#13, filebuffer), length(filebuffer))
Result := filebuffer
end else
begin
repeat
delete(filebuffer, 1, pos(#13, filebuffer));
currentline := currentline - 1;
until(currentline = 0);
delete(filebuffer, pos(#13, filebuffer), length(filebuffer));
Result := filebuffer;
end;
end;

//Gets number of lines in a file. Always returns 1 if nothing in file
function GetFileLines(RelativePath : string) : integer;
var
filebuffer : string;
begin
filebuffer := ReadFile(RelativePath);
repeat
delete(filebuffer, 0, pos(#13, filebuffer));
Result := Result + 1;
until(pos(#13, filebuffer) = 0);
Result := Result + 1;
end;

begin
wait(3000)
//ReadFileLine('C:\Simba\Scripts\usernames.dat', 2); //Reads line #2 out of yourfilehere.dat
sendkeys(ReadFileLine('C:\Simba\Scripts\usernames.dat', random(8000)),0,0)
end.