SRL Archive - FAQ

Save/Export


anonymity

2010-06-10 12:28:08

I have been trying to come up with a good way to save all debug content and/or all report box info as a txt file or something similar.

Is there built in way to "export"/save any(all) of this information? In a pinch, if something fails and calls for a computer shutdown or computer updates or similar I want to know how things were going and read through that information.

Ideas, direction, thoughts, or solutions?

Thanks.

Ogre

2010-06-10 14:18:37

Instead of using WriteLn() make a procedure that will do something like

procedure WriteLnSave(string: string);
begin
GlobalVarWhereYouSaveDebugText:= GlobalVarWhereYouSaveDebugText + #10 + #13 + string; //the #10 and #13 make a newline
WriteLn(string);
end;

and you might want to make a ClearDebugSave procedure

procedure ClearDebugSave;
begin
GlobalVarWhereYouSaveDebugText:='';
ClearDebug;
end;

and I think it's pretty simple to write to a file, but I'm not sure what the procedure is, as I don't have Simba/SCAR on this computer

anonymity

2010-06-11 12:20:21

Thanks for the quick reply, :) I will give this a whirl over the weekend. Hopefully I will be able to make something work.

MylesMadness

2010-06-11 15:16:44

In scar there you could just use GetDebugText to get the text, but that doesn't exist in simba so I guess you need to just do what was already suggested

mastaraymond

2010-06-17 07:19:39

If you really want to log everything, really simple.. Just open CMD, then do this: "simba.exe > debug.log".

Then it will put all the output information in the debug.log file ;).

anonymity

2010-06-17 13:22:55

From: Ogre
Instead of using WriteLn() make a procedure that will do something like
procedure WriteLnSave(string: string);
begin
GlobalVarWhereYouSaveDebugText:= GlobalVarWhereYouSaveDebugText + #10 + #13 + string; //the #10 and #13 make a newline
WriteLn(string);
end;
and you might want to make a ClearDebugSave procedure
procedure ClearDebugSave;
begin
GlobalVarWhereYouSaveDebugText:='';
ClearDebug;
end;
and I think it's pretty simple to write to a file, but I'm not sure what the procedure is, as I don't have Simba/SCAR on this computer

^ [Ogre]could you elaborate a little more on that please.
From: MylesMadness
In scar there you could just use GetDebugText to get the text, but that doesn't exist in simba so I guess you need to just do what was already suggested
^ Thanks. .. ok, I have to tease you on that.. so basically, you said "I have a solution for a different question, really you should just try what was already posted." - Good to know though :P
From: mastaraymond
If you really want to log everything, really simple.. Just open CMD, then do this: "simba.exe > debug.log".

Then it will put all the output information in the debug.log file ;).

Well, you see, I want to be able to save the text for every time a specific simba script runs. If I do that, it removes the old simba log. Also, the debug.log basically corrupts (won't save the previous information) if simba crashes or the computer force closes simba, or shuts down.

Not only when it runs, but in a pinch I need to be able to come back and see, 'oh this is how far it got, this is what happened, alright goodstuff, om nom nom.'

=]

Wizzup?

2010-06-17 14:27:39

From: anonymity
Well, you see, I want to be able to save the text for every time a specific simba script runs. If I do that, it removes the old simba log. Also, the debug.log basically corrupts (won't save the previous information) if simba crashes or the computer force closes simba, or shuts down.

Not only when it runs, but in a pinch I need to be able to come back and see, 'oh this is how far it got, this is what happened, alright goodstuff, om nom nom.'

=]


I don't see how it corrupts if Simba is closed. And you can simply view the end of the file, now can't you?
Actually I'm not sure if windows can do it. On Linux, it's just tail -f <file>

anonymity

2010-06-18 18:09:22

I have checked this a number of times. I don't know how it exports the data into the log file… but it doesn't come in as it happens… If I open or copy the log file out during the middle of a script, the logged data is usually is stuck somewhere near the beginning of the script and not up to speed with where the script is actually at and what has been debugged. As such if the script is closed, it doesn't show all that was going on… It is either an in complete log file or the like.

Edited

Wizzup?

2010-06-19 04:31:58

From: anonymity
I have checked this a number of times. I don't know how it exports the data into the log file… but it doesn't come in as it happens… If I open or copy the log file out during the middle of a script… it usually is stuck somewhere near the beginning of the script. As such if the script is closed, it doesn't show all that was going on…


That is because some I/O is buffered, I think. (Your explanation is not very clear) IOW, it doesn't immediately write everything to the file. It waits for a couple of more bytes before it issues a write. (Or after some time has passed) I guess a Flush() method could be exported.

Or did you mean it never writes stuff? If that is the case, you should be looking at what you are logging and if you're doing it correctly.

anonymity

2010-06-20 03:33:33

I edited for hopefully a little more clarity.

On somewhat a side note… I just have to ask, are there max outs?
ex: is there a max wait time, is there max for var, conts, tpoint, and the like.
I have tried this before and I was not sure if there was just a max out to failure (I set a wait time for about 3 days with a random, just to see how it would react.)… Or maybe I am just having problems with sex. Is it possible that that could be interfering with data if there is an update during the middle of a loop or the sort that is using what gets updated?

i luffs yeww

2010-06-20 13:58:38

Yes. You can only hold enough for what it asks for. I dunno how else to explain that. :p

anonymity

2010-06-21 17:59:50

^ Elaborate?

I dunno if I worded that properly. I want to know if there is a max out… can I wait for a 4 hours, 30 hours, 5 days, a week; that sort of thing.

"I have tried this before and I was not sure if there was just a max out to failure (I set a wait time for about 3 days with a random, just to see how it would react.)… Or maybe I am just having problems with sex. Is it possible that that could be interfering with data if there is an update during the middle of a loop or the sort that is using what gets updated?

"I have tried this before and I was not sure if there was just a max out to failure (I set a wait time for about 3 days with a random, just to see how it would react.)… Or maybe I am just having problems with sex. Is it possible that that could be interfering with data if there is an update during the middle of a loop or the sort that is using what gets updated?"

i luffs yeww

2010-06-22 02:01:49

Umm.. A data type can only hold a certain amount of data.. So yes, you can "max out," if I understand you correctly.

anonymity

2010-06-22 03:18:46

=], but that doesn't get me closer to a certain figure… I don't like guessing and checking to try and figure out what the number is. * Damn, who thought I would be referring back to calc class to get a number. lol. (sarcasm intended)

Thanks then. You've been helpful on that side thought.

lordsaturn

2010-06-22 23:30:38

Yeah, really simply done actually. Here's a proof of concept.


const
SavePathBase = ScriptPath+'debug';

var
FoundUsANewFile: Boolean;
SavePath: string;

procedure Debug(S: array of string);
var
theFile, i, Hi, c: Integer;
begin
try
if not FoundUsANewFile then
begin
c := 1;
SavePath := SavePathBase + ToStr(c) + '.txt';
while FileExists(SavePath) do
begin
Inc(c);
SavePath := SavePathBase + ToStr(c) + '.txt';
end;
theFile := RewriteFile(SavePath, True);
FoundUsANewFile := True;
end else
theFile := OpenFile(SavePath, True);

Hi := High(S);
for i := 0 to Hi do
begin
if i < Hi then //newline
S[i] := s[i]+#13+#10;
if not WriteFileString(theFile, S[i]) then
begin
Writeln('something went wrong debugging :( - Here it is anyways');
Writeln(S);
Exit;
end;
end;
finally
CloseFile(theFile);
end;
end;

begin
Debug(['hi', 'sup', 'no']);
end.

Pretty ugly with the globals.. But it's made to be dynamic.


Edit:
From: anonymity
I dunno if I worded that properly. I want to know if there is a max out… can I wait for a 4 hours, 30 hours, 5 days, a week; that sort of thing.
The maximum value for an integer in Simba is stored in the constant MaxInt. So

begin
Writeln(MaxInt);
Writeln(MaxInt+1);
end.
Will output the maximum and minimum integer values, respectively.