Easily see hex dumps of data
Some letters are not printable - they might be like a newline or a beep code. You can see what these characters are with what is called a hexdump. This is where the value of each character is displayed in hexadecimal along side its text representation. This is extremely useful for debugging. Here’s an example from the tracing sandbox:
10:50:40.362684 0x10b1205c0 main . . Result= (size=184)
54 68 65 20 71 75 69 63 The quic
6B 20 62 72 6F 77 6E 20 k br own
66 6F 78 20 6A 75 6D 70 fox jump
65 64 20 6F 76 65 72 20 ed o ver
74 68 65 20 6C 61 7A 79 the lazy
20 64 6F 67 2E 0A 54 68 dog ..Th
65 20 71 75 69 63 6B 20 e qu ick
62 72 6F 77 6E 20 66 6F brow n fo
78 20 6A 75 6D 70 65 64 x ju mped
20 6F 76 65 72 20 74 68 ove r th
65 20 6C 61 7A 79 20 64 e la zy d
6F 67 2E 0A 54 68 65 20 og.. The
71 75 69 63 6B 20 62 72 quic k br
6F 77 6E 20 66 6F 78 20 own fox
6A 75 6D 70 65 64 20 6F jump ed o
76 65 72 20 74 68 65 20 ver the
6C 61 7A 79 20 64 6F 67 lazy dog
2E 0A 54 68 65 20 71 75 ..Th e qu
69 63 6B 20 62 72 6F 77 ick brow
6E 20 66 6F 78 20 6A 75 n fo x ju
6D 70 65 64 20 6F 76 65 mped ove
72 20 74 68 65 20 6C 61 r th e la
7A 79 20 64 6F 67 2E 0A zy d og..
See the characters after dog? The value is 0x0A in hexadecimal which means the \n or newline character.
To get a hex dump with tracing it’s a matter of using BAS_HEX(Label, Data, Size) in your code. For example:
void APPrepeatSentence(const BASstring& Sentence){
BAS_FUNCTION(APPrepeatSentence);
BAS_VAR(Sentence);
BASstring Result;
for (int i=0; i < 4; i++){
BAS_VAR(i);
Result = Result + Sentence + "\n";
}
BAS_HEX("Result", Result.data(), Result.size());
BASout << Result;
}