Why use Gandi Terminal
Debugging in Scratch can be a ... CATASTROPHE🌋 , especially in these situations:
- when a project contains many variables and lists.
- when tracing the changes of a variable in a loop.
- when multi-sprites are driven by events.
Gandi Terminal is designed to solve these problems and make debugging easier.
Best Practices
Modules
The terminal contains two major parts. What are they?
Functions and Definitions
Tracing
The following methods help you log variables or simply print a string to the Terminal.
Show or hide the terminal window.
Log / Warn / Error
Using the method "log" to print a message in green, "warn" for yellow, and "error" for red. For example, when you run the code above, the terminal will print the message below.
Trace {a message} with color {green}
The "trace" method is similar to log, warn, and error, but you can choose the color.
This is similar to the previous one, but it won't print <VALUE> more than once if <VALUE> is not changed.
For example, when you run the code at left, you will get the result shown on the right.
Clear
Simply enough, this command will clear the output in the Terminal.
Runloop Control
The following events or methods can be used to pause your application for debugging and monitoring the changes of variables.
When {variable} Changed
The event will be dispatched when {variable} is changed. For example:
When {boolean} turns true from false
The event will be dispatched when a boolean expression turns TRUE from FALSE.
Pause and Continue
Programmatically pause or continue the application run loop. It can be used to set a conditional breakpoint. For example, the following code will automatically pause the application when the variable score is less than 0.
Terminal Commands
The following commands can be used in the Terminal window. Before using them, you should run the command "show terminal".
Command | Description | Example |
help | show command help | |
clear | clear the terminal output | |
? <var> | fuzzy search and print variables or lists named <name> | print variables with the name ‘player’:
? player |
?? | print all variables and lists | |
h | shortcut for help | |
c | shortcut for clear | |
e <command> | dispatch an event with the command | e showmethemoney |
Dispatch a Customizable Command
If you want to use the Terminal to change variables in Scratch or run code back to Scratch, you can use the terminal command e <command>
In the Terminal window, for example, use command e your command, as shown below:
In Scratch, your program will receive the event as shown below. You can use the variable “command” under the hat block.
Roadmap and Logs
Version | Log / What’s New |
0.3.2 | Added:
1. customizable command in Terminal
Special thanks to @Bob for this suggestion
- 25.July 2022 |
0.3.1 | Fixed:
1. styles
Added:
1. hide button
2. trace command
- 25.July 2022 |
0.3 | Added:
1. Terminal commands
Fixed:
1. a bug leads to code missing |
0.2 | Added:
1. trace
2. when the variable changed
3. when <> turns true from false
4. pause and continue |
0.1 | Added:
1. show/hide Terminal
2. log / warn / error
4. clear |