SRL Archive - General

Log Saving


Naum

2010-04-19 17:16:39

Hey, I keep getting :

File access error
Debug saving - error occurred

When it tries to save anything to the folder during the script runtime.
Can you guys see if you get the same error? Or is my comp just 'hatin on me'?

{==============================================================================\
| MSI Group Scripting Include |
| RunMe.scar |
|==============================================================================|
| For the script User to just simply press play |
| |
|==============================================================================|
| ** Setup Instructions ** |
|==============================================================================|
| |
| -> Valid arguments for PlayerSkills[i]: |
| - [SKILL_WOODCUTTING] |
| |
| -> Valid arguments for PlayerObjects[i]: |
| - For banking: |
| - [[OBJ_TREE_NORMAL]] |
| |
| - For power skilling (order doesn't matter and it can be in any |
| combination you wish: |
| - [[OBJ_TREE_NORMAL, OBJ_TREE_OAK, OBJ_TREE_WILLOW, OBJ_TREE_MAPLE, |
| OBJ_TREE_YEW]] |
| |
| -> Valid arguments for Integers[P_CITY]: |
| - if power skilling, any city is fine |
| - CITY_VARROCK |
| |
| -> Valid arguments for Integers[P_LOC]: |
| - For banking: |
| - LOC_VE_BANK |
| - LOC_VE_TREES |
| |
| - For power skilling: |
| - LOC_POWER_SKILL |
| |
| -> Valid arguments for Booleans[P_BANK]: |
| - For banking: |
| - True |
| |
| - For power skilling: |
| - False |
\_____________________________________________________________________________}

program MSIScript;
//{$DEFINE REFLECTION} // Comment out if you don't want to use reflection walking
{.include SRL/SRL/MSI/Setup.scar}

const
BREAK_AFTER = 5; // Loads to break after/switching players after
BREAK_TIME = 15; // How long to break for in minutes (for single player only, multiplayer will switch players)

WORLD_SMART = 152;
WORLD_MEMBERS = False;

procedure DeclarePlayers;
var
i, j: Integer;
begin
HowManyPlayers := 3;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
CurrentSkill := 0;
SetLength(ProgressReportArray, HowManyPlayers);
SetLength(PlayerSkills, HowManyPlayers);
SetLength(PlayerObjects, HowManyPlayers);

with Players[0] do
begin
Name := 'empty cohen';
Pass := 'jackaster';
Nick := 'ohe';
Active := True;
Pin := '';
PlayerSkills[0] := [SKILL_WOODCUTTING];
PlayerObjects[0] := [[OBJ_TREE_NORMAL]];
Integers[P_CITY] := CITY_VARROCK;
Integers[P_LOC] := LOC_VE_BANK ;
Booleans[P_BANK] := True;
end;

with Players[1] do
begin
Name := 'troll cohen';
Pass := 'jackaster';
Nick := 'ohe';
Active := True;
Pin := '';
PlayerSkills[1] := [SKILL_WOODCUTTING];
PlayerObjects[1] := [[OBJ_TREE_NORMAL]];
Integers[P_CITY] := CITY_VARROCK;
Integers[P_LOC] := LOC_VE_BANK ;
Booleans[P_BANK] := True;
end;



with Players[2] do
begin
Name := 'cohen gorak';
Pass := 'jackaster';
Nick := 'ohe';
Active := True;
Pin := '';
PlayerSkills[2] := [SKILL_WOODCUTTING];
PlayerObjects[2] := [[OBJ_TREE_NORMAL]];
Integers[P_CITY] := CITY_VARROCK;
Integers[P_LOC] := LOC_VE_BANK ;
Booleans[P_BANK] := True;
end;

for i := 0 to High(Players) do
with Players[i] do
begin
BoxRewards := ['amp', 'mote', 'ostume', 'oins', 'unes', 're', 'ems'];

if (not Active) then
ProgressReportArray[i].FalseReason := 'User set to false';

ProgressReportArray[i].PlayerName := Name;
ProgressReportArray[i].PlayerStatus := Active;
ProgressReportArray[i].PlayerCity := Integers[P_CITY];
ProgressReportArray[i].PlayerLoc := Integers[P_LOC];

SetLength(ProgressReportArray[i].SkillInfo, Length(PlayerSkills[i]));
for j := 0 to High(PlayerSkills[i]) do
begin
SetLength(ProgressReportArray[i].SkillInfo[j].ObjQuants, Length(PlayerObjects[i][j]));
ProgressReportArray[i].SkillInfo[j].TotalObj := Length(PlayerObjects[i][j]);
end;
end;
end;

begin
Smart_Server := WORLD_SMART;
Smart_Members := WORLD_MEMBERS;
Smart_Signed := True;
Smart_SuperDetail := False;

SetupSRL;
SetupMSI;

BreakAfter := BREAK_AFTER;
BreakTime := BREAK_TIME;

DeclarePlayers;
MSI_Mainloop;
end.

^ Just click run and watch SCAR/Simba, and see if it saves a log. Because if it doesn't, then there's a big problem.

Coh3n

2010-04-20 23:37:40

I'm not sure exactly what the problem would be. It works for me fine on my desktop (running Ubuntu), but doesn't work on my laptop for either Simba or SCAR.

We could try taking out the try..except blocks and see what line the error occurs.

Coh3n

2010-04-28 17:26:39

I just worked on it for an hour or so and couldn't figure out what's wrong. If you take away the try..except statements you get:

Error: Exception: Invalid FileNum passed: -1 at line 61

Which is:
[php]
WritelnFileString(theFile + #10 + DebugMSG);
[/php]

Zyt3x said this never happened when he was testing out the script, so I don't know what we're doing wrong. :confused:

Wizzup?

2010-04-28 17:46:59

I assume ``theFile'' is not opened correctly. Do you have permissions to do so?
writeln(inttostr(theFile));
If it is -1, then you're doing it wrong. ;)

Coh3n

2010-04-28 17:56:23

From: Wizzup?
I assume ``theFile'' is not opened correctly. Do you have permissions to do so?
writeln(inttostr(theFile));
If it is -1, then you're doing it wrong. ;)

The thing is, it works perfect when I run it with WINE, but when I run it with Windows, it messes up. I thought it was the permissions also, but my version of windows doesn't even have the permissions option, and Naum is convinced that's not his problem. Here's where the error his.


{******************************************************************************}
{ procedure MSI_Debug(ProcName, TheMessage: string; DebugLevel:integer); }
{ By: Rasta Magician }
{ Description: Used for Debugging. Will debug to DebugBox if }
{ DebugLevel >= Debug_LevelToDebug }
{******************************************************************************}
procedure MSI_Debug(ProcName, TheMessage: string; DebugLevel:integer);
var
DebugMSG, path, str: string;
theFile: Integer;
begin
if DebugLevel < Debug_LevelToDebug then exit;
DebugMSG := TheTime+': ';

try
DebugMSG := DebugMSG + Capitalize(Players[CurrentPlayer].Name)+': ';
except end;

case DebugLevel of
//to add some more detail
DEBUG_PLAYER_ACTIONS: DebugMSG := DebugMSG + 'Player Action: ';
DEBUG_FUNCTIONS : DebugMSG := DebugMSG + 'Entering Func: ';
DEBUG_SMALL_DETAILS : DebugMSG := DebugMSG + 'Detail: ';
end;

DebugMSG := DebugMSG + ProcName + ': ';
DebugMSG := DebugMSG + TheMessage;
writeln(DebugMSG);

//Save the message to a file
try
path := AppPath + 'Includes\SRL\SRL\msi\MSI Logs\';
if FileExists(path + scriptStart + '.txt') then
begin
theFile := OpenFile(path + scriptStart + '.txt', False);
ReadFileString(theFile, str, FileSize(theFile));
CloseFile(theFile);
end;

theFile := RewriteFile(path + scriptStart + '.txt', False);

WriteFileString(theFile, str + #10 + DebugMSG); //error here
CloseFile(theFile);
except
Writeln('Debug saving - error occurred');
end;
end;

Oh and way off topic, but all of the sudden all the bold text in my firefox is no not bold (new posts, bold words in SCAR tags, etc.).. any idea what happened? :p

Nava2

2010-04-28 18:34:48

Try this:
//Save the message to a file
try
path := AppPath + 'Includes\SRL\SRL\msi\MSI Logs\';
if FileExists(path + scriptStart + '.txt') then
begin
theFile := OpenFile(path + scriptStart + '.txt', False);
ReadFileString(theFile, str, FileSize(theFile));
CloseFile(theFile);
end;

theFile := RewriteFile(path + scriptStart + '.txt', False);

WriteFileString(theFile, str + #10 + DebugMSG); //error here
except
Writeln('Debug saving - error occurred');
finally
try closeFile(theFile); except end; // make sure its *always* closed if possible.
end;

Coh3n

2010-04-29 08:52:56

I would, but I can't even open Simba for some reason. I keep getting an error.

Wizzup?

2010-04-29 08:53:51

Can you save the settings.xml for me? I'd like to look at it later.
You can resolve this by deleting the settings.xml, although I don't know why it would be corrupted.

Coh3n

2010-04-29 08:59:48

From: Wizzup?
Can you save the settings.xml for me? I'd like to look at it later.
You can resolve this by deleting the settings.xml, although I don't know why it would be corrupted.

Okay thanks, and I attached the file.

@Nava -> Still didn't work.

ReWriteFile - Exception. Could not create file: C:\Documents and Settings\Owner\Desktop\Simba\Includes\SRL\SRL\msi\MSI Logs\29-04-10 at 08:02:03 AM.txt

I've also tried to use Simba's CreateFile instead of ReWriteFile, and that didn't work.

Coh3n

2010-05-07 09:59:31

Since no one has been able to figure out why this happens for some people, is anyone opposed to adding a global variable SaveDebug, then add it to the script setup for the user to decide? The way we have it setup is that if for whatever reason it can't save the debug, it won't print the progress report. With a variable, obviously it can easily be changed, not to mention some people just may not want a build up of files in their MSI folders.

Sir R. M8gic1an

2010-05-07 20:45:57

From: Coh3n
Since no one has been able to figure out why this happens for some people, is anyone opposed to adding a global variable SaveDebug, then add it to the script setup for the user to decide? The way we have it setup is that if for whatever reason it can't save the debug, it won't print the progress report. With a variable, obviously it can easily be changed, not to mention some people just may not want a build up of files in their MSI folders.


Sounds good. And if we realize that it can't write to file then we can just do saveDebug := false;
~RM

Coh3n

2010-05-09 18:31:50

From: Rasta Magician
Sounds good. And if we realize that it can't write to file then we can just do saveDebug := false;
~RM

Exactly my thoughts. :)

E: Done in revision 100. :)