Log in

View Full Version : ReadFileString



Jason2gs
03-13-2007, 10:37 PM
Can someone explain how to use this? By the look of the shadow box (the yellow box that pops up up when start the procedure name), it wants me to tell SCAR what to search for. I wan't it to find anything, however.

Plus, whenever I try to work it out, it gives me an error.

Please tell me how to use it.

Thanks,

Mike.

Infantry001
03-13-2007, 11:31 PM
Well, you have to specify exactly what file you want to read and where. Like this: C:\Program Files\Scar 2.03\MyDoc.txt

Jason2gs
03-14-2007, 12:11 AM
That doesn't really help.


procedure TheChecker;
begin
TheFileNum := ReWriteFile('C:\Program Files\Scar 2.03\PasswordFile.txt', False);
TheFile := OpenFile('C:\Program Files\Scar 2.03\PasswordFile.txt', False);
TheSize := FileSize(TheFileNum);
ReadFileString(TheFileNum, 'C:\Program Files\Scar 2.03\PasswordFile.txt', TheSize);
end;


What's wrong with that up there? It says it wants a variable, but I already have variables: TheFile, TheSize, TheFileNum, set.

Infantry001
03-14-2007, 01:07 AM
Can you post me the exact error? And the whole script (if you dont want to let pblic see it, pm it to me)

Jason2gs
03-14-2007, 01:14 AM
program New;
var
TheFile, TheSize, TheFileNum : Integer;
Username, Password : String;

procedure TheGetUsername;
begin
Username := ReadLn('Username?');
end;

procedure TheGetPassword;
begin
Password := ReadLn('Password?');
end;

procedure TheChecker;
begin
TheFileNum := ReWriteFile('C:\Program Files\Scar 2.03\PasswordFile.txt', False);
TheFile := OpenFile('C:\Program Files\Scar 2.03\PasswordFile.txt', False);
TheSize := FileSize(TheFileNum);
ReadFileString(TheFileNum, 'C:\Program Files\Scar 2.03\PasswordFile.txt', TheSize);
end;

begin
TheGetUsername;
TheGetPassword;
TheChecker;
end.




Line 21: [Error] (21:28): Variable Expected in script C:\Program Files\SCAR 2.03\Scripts\FilesTest.scar


Line 21 is...


ReadFileString(TheFileNum, 'C:\Program Files\Scar 2.03\PasswordFile.txt', TheSize);


Thanks for helping, BTW.

I'm quite new to this whole FileEditing branch of SCAR :)

Edit: The script is useless as of right now, but I do want it to check to see if the password typed matches the password in the file. Still gonna be useless, but I just want some practice as far as this ReadFileString/WriteFileString thing goes.

Infantry001
03-14-2007, 02:58 AM
Srry its gettin late over here, and i cant think straight :P (I cant find anything that's wrong)

Ill take a look tomorrow.

Jason2gs
03-14-2007, 06:39 PM
Kk, thanks ;)