SRL Archive - OSR Help

File Writing?


Death12652

2010-05-17 21:36:02

I have this…


procedure Save_Usernames(str: String);
var
theFile: Integer;
tempStr: String;
begin
if (FileExists(ScriptPath + 'Yaboe_Usernames.txt')) then
begin
theFile := OpenFile(ScriptPath + Name{This is a constant} + 'Yaboe_Usernames.txt', false);
ReadFileString(theFile, tempStr, FileSize(theFile));
CloseFile(theFile);
end;

theFile := RewriteFile(ScriptPath + 'Yaboe_Usernames.txt', false)
WriteFileString(theFile, tempStr + str + #32#32#32#32#32 + FloatToStr(ext) + #13);
CloseFile(theFile);
end;

And get this?


[Runtime Error] : Exception: Access violation at address 0077B189 in module 'scar.exe'. Read of address 00000003 in line 203 in script C:\Users\Brent\Desktop\SCAR 3.23 Beta\Yaboe Maker V2.1.2[Run Me].scar

Whenever the file is already made?

XcanadamanX

2010-05-17 23:09:30

what line gives the error?

Death12652

2010-05-17 23:49:43

This line


ReadFileString(theFile, tempStr, FileSize(theFile));

Also Now when I try this instead…


program New;
var
v : string;

procedure Save_Usernames(str: String);
var
theFile: Integer;
tempStr: String;
begin
if (FileExists(ScriptPath + 'Yaboe_Usernames11.txt')) then
begin
theFile := OpenFile(ScriptPath + 'Yaboe_Usernames11.txt', false);
ReadFileString(theFile, tempStr, FileSize(theFile));
CloseFile(theFile);
end;

theFile := RewriteFile(ScriptPath + 'Yaboe_Usernames11.txt', false)
WriteFileString(theFile, tempStr + str + #10#13);
CloseFile(theFile);
end;


begin
V := 'blahblahblahblah';
Save_Usernames(V);
end.

I get this…


[Runtime Error] : Exception: Access violation at address 0077AE65 in module 'scar.exe'. Read of address FFFFFFFC in line 18 in script

Line 18 is this…


WriteFileString(theFile, tempStr + str + #10#13);

i luffs yeww

2010-05-18 00:11:05

You're missing a CloseFile somewhere I think. I was getting that before. Sex should know. I'm asking him. :)

Sex

2010-05-18 00:13:37

No, he isn't missing a CloseFile.
You are running it without saving the script; therefore ScriptPath is empty.