Log in

View Full Version : get last writeln line



caused
06-22-2012, 05:48 PM
Is there a way to get it ?

I believe scar had a function for that, but I cant remember it :x ....

Janilabo
06-22-2012, 06:02 PM
Commands in SCAR for Debug box control are:

function GetDebugLine(Line: Integer): string;
function GetDebugLineCount: Integer;
function GetDebugText: string;
procedure DeleteDebugLine(Line: Integer);
procedure ClearDebugLine(Line: Integer);
procedure ReplaceDebugLine(Line: Integer; Str: string);

Sadly they are missing from Simba's commandlist. :( Maybe they will be added in future? Hopefully.
Could be something to add in Mantis (http://bugs.villavu.com/login_page.php)...

Edit: Code for getting the last debug line (in SCAR) below..

begin
ClearDebug;
WriteLn('Blah...');
WriteLn('This IS the last line!');
WriteLn('Last debug line currently is: "' + GetDebugLine(GetDebugLineCount - 1) + '"!');
end.

Runaway
06-22-2012, 06:07 PM
Couldn't you just store the lastest writeln as a global var every time it's called?

Janilabo
06-22-2012, 06:14 PM
Couldn't you just store the lastest writeln as a global var every time it's called?Of course that works in your own scripts, but it still would be great to have the debug box commands added in, simply because they are so much more stable (example: you can't get the data SRL, MSI or others add to debug box with the method you mentioned, well, at least without modifying the files manually first)..

Main
06-22-2012, 06:20 PM
Are you trying to get rid of debug spams? (Like get rid of writeln that are the same?).

Var
OldDB: String;

Function TR: String;
Begin
Result := ' Time :' + TimeRunning + '.';
End;

Procedure ShowDB( S: String);
Var
DCB: Tpoint;
Begin
If S = OldDB Then
Exit;
Writeln( Tr + S);
OldDB := S;
End;


Just use ShowDB() instead of writeln and you can see the difference :)

Brandon
06-22-2012, 07:13 PM
To read the last line can be done via Extensions that may possibly be Windows only. I don't have other machines to test it on:



function FindWindow(ClassName, WindowName: PChar): HWND; external 'FindWindowA@User32.dll'
Then do the export for text functions:



Function SendMessage(Handle: HWND; Msg, WPARAM, LPARAM: Word): LongInt; external 'SendMessageA@User32.dll'

Function GetWindowText(Handle: HWND; Buffer: PCHAR; nMaxCount: Integer); external 'GetWindowTextA@User32.dll'
Put those in an extension, call the functions for it in your script or whatever and whalala it will return all the text in the debug box. It's then a simple function to get the last line of the returned text.

It's not PHP.. I just used the PHP Tags since I used it in my old thread here: http://villavu.com/forum/showthread.php?t=65657

Same concept.