Skip to content
Le Bao Hiep edited this page Aug 30, 2021 · 4 revisions

Welcome to the scratch-run wiki!

scratch-run is a CLI interpreter for Scratch. Unlike similar projects (e.g., scrape), scratch-run is based on the official virtual machine for Scratch (namely scratch-vm), thus supporting all Scratch blocks and features (except image and audio, obviously).

Input

To input data, use the Ask () and Wait block. Input is read from the standard input.

By default, input is read line by line. For example,

1 2
3 4

would be passed to Scratch as 1 2 and 3 4 (corresponding to two Ask () and Wait blocks).

To read input token by token, set the question to read_token. In this case, the above input would be passed to Scratch as four separate tokens 1, 2, 3, and 4 (corresponding to four Ask () and Wait blocks).

Output

To output data, use either the Say () or Think () blocks. They all print data to the standard output. The only difference is that Say () will print data with a newline character (\n), while Think () does not.

Demo

This programs (tests/aplusb.sb3) takes in two numbers and outputs their sum.

A plus B

$ scratch-run tests/aplusb.sb3
1 2
3
Clone this wiki locally