All about custom debug appearancesby CX gamer
Difficulty: Intermediate
Scar version: 3.2.2An example of a custom debug appearance is this;

I will be teaching you how you can customise your debug box yourself.
BasicsFirst we need to declare a variable to store your personalised appearance in.
We will call this myDebugParam.
[scar]program CustomDebug;
var
myDebugParam : TDebugParams
begin
end.[/scar]
Now we need to assign some properties to the variable we have just created, the properties are;
* backColor: The background color
* color: The text-color
* name: The name of the font you're using
* style: The text style saved in a TfontStyle (more on this later)
We declare some of these properties;
[scar]program CustomDebug;
var
myDebugParam : TDebugParams
begin
myDebugParam.backColor := clBlack;
myDebugParam.color := clGreen;
myDebugParam.name := 'Times New Roman';
end.[/scar]
Note: I'm using clBlack and clGreen as easy reference, but you can just as well use an integer color.
Now we have our custom appearance declared, we need to tell SCAR to use it.
We do this with the
setDebugParams(myDebugParam); command.
[scar]program CustomDebug;
var
myDebugParam : TDebugParams;
begin
myDebugParam.backColor := clBlack;
myDebugParam.color := clGreen;
myDebugParam.name := 'Times New Roman';
setDebugParams(myDebugParam);
end.[/scar]
And ofcourse, we need to 'use' our new appearance, so we use a
writeln command.
[scar]program CustomDebug;
var
myDebugParam : TDebugParams;
begin
myDebugParam.backColor := clBlack;
myDebugParam.color := clGreen;
myDebugParam.name := 'Times New Roman';
setDebugParams(myDebugParam);
writeln('Hello, world!');
end.[/scar]
If you run this script, it should output something like

.
Please note that the
setDebugParams-command will only use your appearance for the next
writeln.
Using stylesUsing a style (
bold,
italic,
underlined or
strike-through) is very easy.
You will just need add another property.
[scar]myDebugParam.style :=[/scar]
This is followed by one or more of the following, placed between square brackets.
fsBold
fsItalic
fsUnderline
fsStrikeOutExample;
[scar]program CustomDebug;
var
myDebugParam : TDebugParams;
begin
myDebugParam.backColor := clBlack;
myDebugParam.color := clGreen;
myDebugParam.name := 'Times New Roman';
myDebugParam.style := [fsItalic, fsUnderline];
setDebugParams(myDebugParam);
writeln('Hello, world!');
end.[/scar]
This will output

.
You may also create a variable;
[scar]myTfontStyles : TfontStyles[/scar]
which can store the same values.
Multiple appearances per lineIt is currently possible to use more than one appearance on a single line.
For this, we will need to create 2 debug parameters. You should be able to make those now.
Then we will need to declare a string, and we save the first part of our message to that string.
[scar]program CustomDebug;
var
myDebugParam1, myDebugParam2 : TDebugParams;
s : string;
begin
myDebugParam1.backColor := clBlack;
myDebugParam1.color := clGreen;
myDebugParam1.name := 'Times New Roman';
myDebugParam2.backColor := clBlack;
myDebugParam2.color := clRed;
myDebugParam2.name := 'Times New Roman';
setDebugParams(myDebugParam1);
s := 'Hello, ';
end.[/scar]
Now here comes the tricky part;
we are going to use 2
writeln's, but we want them to output on the same line.
For that to happen, we make the string a bit longer, but we won't declare the added characters.
This will cause the
writeln to skip the new-line, so the next
writeln will continue after the last, on the same line.
'Hello, ' has 7 characters, so we will make string
s 8 characters long.
Note that any length equal or longer than 8 will work.
[scar]setDebugParams(myDebugParam1);
s := 'Hello, ';
setLength(s, 8);
writeln(s);[/scar]
And now we will just set the new debug parameters and write the last part of our message;
[scar]setDebugParams(myDebugParam2);
writeln('world!');[/scar]
If done right, you should have this code now;
[scar]program CustomDebug;
var
myDebugParam1, myDebugParam2 : TDebugParams;
s : string;
begin
myDebugParam1.backColor := clBlack;
myDebugParam1.color := clGreen;
myDebugParam1.name := 'Times New Roman';
myDebugParam2.backColor := clBlack;
myDebugParam2.color := clRed;
myDebugParam2.name := 'Times New Roman';
setDebugParams(myDebugParam1);
s := 'Hello, ';
setLength(s, 8);
writeln(s);
setDebugParams(myDebugParam2);
writeln('world!');
end.[/scar]
Which should look something like

.
This concludes my brief tutorial. I hope you understood most of it.

If you have any questions, please ask.
