SRL Archive - OSR Intermediate Scripting Tutorials

Understanding SCAR's Ouput Functions


Naum

2009-07-19 13:31:15

Understanding SCAR's DebugBox Functions


Table Of Contents
O - Intro.
I - DebugBox Functions/Procedures and Descriptions + Usage.
II - End Note.



O - Intro.

Hello, and welcome to my tutorial on SCAR's DebugBox functions. In this tutorial I will explain functions such as ClearDebug; and GetDebugLineCount. Knowing how to use this is vital. So you may ask: 'How does this relate to RuneScape?'. Well… Ever heard of a progress report? It shows you what you've done, and for how long in a Script, how would you edit it without printing it again?.


I - DebugBox Functions/Procedures and Descriptions.

The Debug functions of SCAR are:
[php]procedure ClearDebug;
Clears debug box.

procedure DeleteDebugLine(Line: Integer);
Deletes a line from the debug box.

function GetDebugLineCount: Integer;
Get the number of lines in the debug box.

function GetDebugText: string;
Gets the text in the debugbox.

function GetDebugLine(Line: Integer): string;
Returns a certain given line of the debug box.

procedure ClearDebugLine(Line: Integer);
Clears a certain line of the debug box.

procedure ReplaceDebugLine(Line: Integer; s: string);
Replaces a certain line of the debug box.

function GetDebugParams: TDebugParams;
Retrieves the default make-up settings for the debugbox.

procedure SetDebugParams(Params: TDebugParams);
Sets make-up settings for the next WriteLn to the debugbox.

procedure AddToReport(s: string);
Adds a message to the report box.

procedure ClearReport;
Clears all messages sent to the report box

procedure ChangeReportWidth(Width: Integer);
Changes the width of the report box to the given Width. [/php]

I will break them down and we will analyze them step-by-step (Here's a smiley to keep you going on: :)).


1.
[php]procedure ClearDebug;
Clears debug box.[/PHP]

It basically does what it says. Run this script:
Begin
WriteLn('jjjjjj');
Writeln('kkkk');
Wait(1000);
ClearDebug;
End.


2.
[php]procedure DeleteDebugLine(Line: Integer);
Deletes a line from the debug box.[/php]

The first line is '0' then next line is '1' and so on.. Try this:
Begin
ClearDebug; //see that ;)
WriteLn('This line will be deleted');
Wait(800);
WriteLn('This Line wont');
Wait(800);
DeleteDebugLine(0);
Wait(800);
WriteLn('See ;)');
End.


3.
[php]function GetDebugLineCount: Integer;
Get the number of lines in the debug box.[/php]

Run it…
Begin
ClearDebug;
WriteLn('ggg');
If Random(2) = 0 Then WriteLn('hhh');
WriteLn(IntToStr(GetDebugLineCount)+' lines in Debug Box');
End.


4.
[php]function GetDebugText: string;
Gets the text in the debugbox.[/php]

It does what it says. Run this son:
Begin
ClearDebug; //;)
If Random(2) = 1 Then WriteLn('Roflmao')
Else WriteLn('lololol');
If GetDebugText = 'Roflmao' Then
WriteLn('We typed in Roflmao, that means that Random(2) was 1')
Else
WriteLn('We typed in lololol, that means that Random(2) was 0');
End.


5.
[php]function GetDebugLine(Line: Integer): string;
Returns a certain given line of the debug box.[/php]

It sure does ;):
Begin
WriteLn('kjk');
Writeln('lkl');
WriteLn('Last Line was : '+GetDebugLine(GetDebugLineCount-1));
End.
^ Look at that, I used a function in a function ;). See how they relate to each other?


6.
[php]procedure ClearDebugLine(Line: Integer);
Clears a certain line of the debug box.[/php]

Begin
WriteLn('this line will be deleted');
Wait(999);
WriteLn('this line will not');
Wait(999);
ClearDebugLine(GetDebugLineCount - 2);
End.
^ Function in a function again :spot: ^


7.
[php]procedure ReplaceDebugLine(Line: Integer; s: string);
Replaces a certain line of the debug box.[/php]

This will replace a debug line, Remember what was said before of the progress report thing? This is your salvation! :eek:
Var I : ShortInt;

Begin
WriteLn('A simple countdown');
Wait(700);
For I := 60 Downto 0 Do
Begin
ReplaceDebugLine(GetDebugLineCount-1, IntToStr(I));
Wait(200);
End;
End.
See it doesn't print a mass amount? So you can replace Lines during run time.


8.
[php]function GetDebugParams: TDebugParams;
Retrieves the default make-up settings for the debugbox.[/php]

In the 'New' Scar, you can modify the debugbox much more. This gets the default settings for the debugbox:
Var I : TDebugParams;

Begin
I := GetDebugParams;
WriteLn(I.BackColor);
Writeln(I.Color);
WriteLn('The font name in the debug box is ' + I.Name);
End.


9.
[php]procedure SetDebugParams(Params: TDebugParams);
Sets make-up settings for the next WriteLn to the debugbox.[/php]

This is just pure fun :):
Var I : TDebugParams;

Begin
I := GetDebugParams;
WriteLn(I.BackColor);
Writeln(I.Color);
WriteLn('The font name in the debug box is ' + I.Name);
WriteLn('Before');
I.BackColor := clBlack;
I.Color := clBlue;
I.Name := 'Comic Sans MS';
SetDebugParams(I);
WriteLn('After');
End.


10.
[php]procedure AddToReport(s: string);
Adds a message to the report box.[/php]

This handy function adds a line to the ReportBox, which is beside the DebugBox, SRL Randoms Report is printed there ;):

Begin
AddToReport('lol!');
End.
^ Magic!!! ^


11.
[php]procedure ClearReport;
Clears all messages sent to the report box[/php]

Does what it says ;).

Begin
AddToReport('this will be cleared?');
Wait(800);
ClearReport;
AddToReport(' it did :)');
Wait(800);
ClearReport;
End.


12.
[php]procedure ChangeReportWidth(Width: Integer);
Changes the width of the report box to the given Width.[/php]

This procedure changes the width of the ReportBox, but it also in-directly influences the DebugBox ;).

Begin
ChangeReportWidth(320);
Wait(800);
ChangeReportWidth(420);
End.


II - End Note.
Thanks to everyone who reads my tutorials and comments, it's nice to see I get feedback, thanks :)

Dynamite

2009-07-20 01:40:30

You are an absolute machine!
Nice tut!

T~M

Awkwardsaw

2009-07-21 00:30:16

nice tut :)

but what about addreport, or clearreport?

it adds text to the report box, where your progress reports should go :D

Da 0wner

2009-07-21 00:33:44

[php]procedure AddToReport(s: string);
Adds a message to the report box.

procedure ClearReport;
Clears all messages sent to the report box

procedure ChangeReportWidth(Width: Integer);
Changes the width of the report box to the given Width.[/php]

Nadeem

2009-07-21 00:43:27

Nice Nauman :) ~ As if you do not have enough rep already :p ahah j/k



~NS

Naum

2009-07-21 00:50:01

From: Da 0wner
[php]procedure AddToReport(s: string);
Adds a message to the report box.

procedure ClearReport;
Clears all messages sent to the report box

procedure ChangeReportWidth(Width: Integer);
Changes the width of the report box to the given Width.[/php]


Dude, that's in another section in the SCAR manual, but I will add it :).

Thanks for all the other comments guyz!

Lol @ Nad :D

Richard

2009-07-21 01:08:05

Reckon you could display all the different params in the TDebugParams type?

Da 0wner

2009-07-21 01:11:19

BackColor (the background)
Color (the text color)
Style (the styles)
Name (not sure what that is :p)

Style is an array of fontstyles.

i.e

TDP.Style := [fsBold, fsItalic]; //etc.

Richard

2009-07-21 01:27:26

From: Da 0wner
BackColor (the background)
Color (the text color)
Font (the font)
Name (not sure what that is :p)

Font is an array of fontstyles.

i.e

TDP.Font := [fsBold, fsItalic]; //etc.


I thought font was its own type…

Var
i: TDebugParams;

begin
i.font.color := x;
i.font.name := y;
end.

Da 0wner

2009-07-21 01:28:59

Style I meant :p.

Sabzi

2009-07-21 01:40:21

Name is like Times New Roman, Arial and others. Fonts here while you are posting. I have looked up them here how they look like when I was trying this. Before this tut :/. But I forgot harder what I learn myself. Still learning from tuts is much easier.

Da 0wner

2009-07-21 02:34:26

Aha, that's what I was missing :p. Thanks.

Naum

2009-07-21 14:09:09

From: Richard
I thought font was its own type…

Var
i: TDebugParams;

begin
i.font.color := x;
i.font.name := y;
end.


From: Da 0wner
Style I meant :p.


From: Sabzi
Name is like Times New Roman, Arial and others. Fonts here while you are posting. I have looked up them here how they look like when I was trying this. Before this tut :/. But I forgot harder what I learn myself. Still learning from tuts is much easier.


From: Da 0wner
Aha, that's what I was missing :p. Thanks.


Thanks :). I'll add the Debug thing to the Tut, just remember in Overwrite.scar, this function is used.

Press Play

2010-07-01 02:37:13

This is cool. I never knew you could delete lines in the debug! I'm going to use this :)