SRL Archive - OSR Help

perplexing things.


JN13

2012-03-12 23:36:18

[Warning] (1:1): "and True" is not needed at line 0


I know it must be in some tut somewhere that I can't find… but what does this mean :duh:

also!

how do I change this to make it save in unique reports? can I tack the time on the end to make it unique, not overwrite the previous one? (it reports if the script terminates for crashsmart)


procedure WriteReportToFile;
var
theFile: Integer;
thePath: string; //Ty Coh3n
begin
thePath := AppPath + 'Scripts\ABBA_Report{'+ToStr(TheTime)+'???}.txt';// this is the problem spot

try
theFile := RewriteFile(thePath, False);
except
Writeln('Error opening file!');
end;

WriteFileString(theFile, '******************************************************************' + #13 + #10);
WriteFileString(theFile, ' AdvancedBarBarianAgility v1.07 by Johnnimms13 & Co.' + #13 + #10);
WriteFileString(theFile, 'Time: ' + TimeRunning + ' Laps ' + IntToStr(Loads) + #13 + #10);
WriteFileString(theFile, 'We have gained ' + ToStr(Round(Exp)) + ' Agility Experience!' + #13 + #10);
WriteFileString(theFile, '******************************************************************' + #13 + #10);

CloseFile(theFile);
end;

weequ

2012-03-13 20:35:55

[Warning] (1:1): "and True" is not needed at line 0
Basically if you have something like
if (BankScreen and 1=1) then //1=1 is always true and therefore unnccessary.

Sometime if you use constants it will warn you without a reason

Example:


const
UseBankPin = true;

if (BankScreen and UseBankPin) then//Now it might still print that warning. Just ignore it.

Editing soon to ansver 2nd question.

Edit:

procedure WriteReportToFile;
var
theFile: Integer;
thePath: string; //Ty Coh3n
year, month, day, hour, min, sec, ms: Word;
timeString: String;
begin
DecodeDate(Date, year, month, day);
DecodeTime(Now, hour, min, sec, ms);
timeString := ToStr(year)+'-'+ToStr(month)+'-'+ToStr(day)+' '+ToStr(hour)+':'+ToStr(min)+':'+ToStr(sec);
thePath := AppPath + 'Scripts\ABBA_Report{'+timeString+'}.txt';// this is the problem spot

try
theFile := RewriteFile(thePath, False);
except
Writeln('Error opening file!');
end;

WriteFileString(theFile, '******************************************************************' + #13 + #10);
WriteFileString(theFile, ' AdvancedBarBarianAgility v1.07 by Johnnimms13 & Co.' + #13 + #10);
WriteFileString(theFile, 'Time: ' + TimeRunning + ' Laps ' + IntToStr(Loads) + #13 + #10);
WriteFileString(theFile, 'We have gained ' + ToStr(Round(Exp)) + ' Agility Experience!' + #13 + #10);
WriteFileString(theFile, '******************************************************************' + #13 + #10);

CloseFile(theFile);
end;
try it.

Another way would be using GetFiles or FileExists to create a file with increasing index number at the end.

JN13

2012-03-13 23:05:53

Thank you so much!

I keep getting this error though

ReWriteFile - Exception. Could not create file: C:\Simba\Scripts\ABBA_Report{2012-3-13 20:10:22}.txt
Error: Exception: Invalid FileNum passed: -1 at line 115


maybe create file instead of rewrite? Apparently wasn't the problem :(

weequ

2012-03-14 09:10:47

From: johnnimms13
Thank you so much!

I keep getting this error though

ReWriteFile - Exception. Could not create file: C:\Simba\Scripts\ABBA_Report{2012-3-13 20:10:22}.txt
Error: Exception: Invalid FileNum passed: -1 at line 115


maybe create file instead of rewrite? Apparently wasn't the problem :(

Yeah maybe it works. Doesn't hurt to try. Replace it with:

theFile := CreateFile(thePath);

If that doesn't work then try having
CreateFile(thePath);
theFile := RewriteFile(thePath, False);

in that order.