PDA

View Full Version : Understanding SCAR's Ouput Functions



Naum
07-19-2009, 05:31 PM
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:

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.

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


1.

procedure ClearDebug;
Clears debug box.

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


2.

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

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.

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

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


4.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

procedure ClearReport;
Clears all messages sent to the report box

Does what it says ;).

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


12.

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

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
07-20-2009, 05:40 AM
You are an absolute machine!
Nice tut!

T~M

Awkwardsaw
07-21-2009, 04:30 AM
nice tut :)

but what about addreport, or clearreport?

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

Da 0wner
07-21-2009, 04:33 AM
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.

Nadeem
07-21-2009, 04:43 AM
Nice Nauman :) ~ As if you do not have enough rep already :p ahah j/k



~NS

Naum
07-21-2009, 04:50 AM
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.

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
07-21-2009, 05:08 AM
Reckon you could display all the different params in the TDebugParams type?

Da 0wner
07-21-2009, 05:11 AM
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
07-21-2009, 05:27 AM
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
07-21-2009, 05:28 AM
Style I meant :p.

Sabzi
07-21-2009, 05:40 AM
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
07-21-2009, 06:34 AM
Aha, that's what I was missing :p. Thanks.

Naum
07-21-2009, 06:09 PM
I thought font was its own type...

Var
i: TDebugParams;

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


Style I meant :p.


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.


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
07-01-2010, 06:37 AM
This is cool. I never knew you could delete lines in the debug! I'm going to use this :)