Logo
  • Features
  • Educators
  • What's New
  • Blog
  • Showcase
  • About us
  • Contact
Try it now!
Terminal
Terminal

Terminal

Why use Gandi Terminal

Debugging in Scratch can be a ... CATASTROPHE🌋 , especially in these situations:

  1. when a project contains many variables and lists.
  2. when tracing the changes of a variable in a loop.
  3. when multi-sprites are driven by events.

Gandi Terminal is designed to solve these problems and make debugging easier.

Best Practices

How to figure out the sequencing of the events while code reading in Scratch? - Gandi IDE

Code reading is one of the best ways to learn to code. However, when reading a complex project, for instance Among Us from TimMcCool, it is frustrating to figure out how functions are been called, and the sequencing of the events. With Gandi Terminal, you can insert a trace block under each function and event.

getgandi.com

How to trace the changes of a variable in one algorithm? - Gandi IDE

Debugging in Scratch is extremely hard. In most modern IDEs, one technique that monitors programs in real-time debugging is known as "tracing", which involves a specialized use of logging to record information about a program's execution. As the screenshot is shown below, the left side shows a simple algorithm with a loop within another loop.

getgandi.com

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.

image

Show or hide the terminal window.

Log / Warn / Error

image

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.

image

Trace {a message} with color {green}

image

The "trace" method is similar to log, warn, and error, but you can choose the color.

image

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.

image

Clear

image

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

image

The event will be dispatched when {variable} is changed. For example:

image

When {boolean} turns true from false

image

The event will be dispatched when a boolean expression turns TRUE from FALSE.

image

Pause and Continue

image

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.

image
💡
Question: if the program is already paused, how can a program run the “continue” block? Answer: normally I will put a continue block together with a pause block. If the program is paused, I don’t need to move my cursor over a long distance to click the continue button on the stage. Like this:
image

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:

image

In Scratch, your program will receive the event as shown below. You can use the variable “command” under the hat block.

image

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
💡
If you have any questions or suggestions, you can leave a comment here: Notion: https://yxshawn.notion.site/Terminal-8f8897f67eee414cb90ebe20941d2273 Or find us in the discord channel: https://discord.gg/U3nyveCvRa
Logo

Designed by 2ndR with love

Discord