question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manual execution of blocks

See original GitHub issue

I’m trying to generate arduino C code using scratch block. I can’t store generated code because of vm architecture. For example, this is code for builtin ‘if’ statement

if (args, util) {
        const condition = Cast.toBoolean(args.CONDITION);
        if (condition) {
            util.startBranch(1, false);
        }
}

I want to make something like this:

if (args, util) {
        const condition = Cast.toString(args.CONDITION);
        const body = recursive_call_for_inner_blocks(inner_blocks);
        return `if (${condition}) { ${body} }`;
}

How can I do this? Maybe there is a better way to generate code using scratch blocks?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fsihcommented, Mar 19, 2020

@caxapexac scratch-blocks was originally branched from Blockly, which does convert blocks into code. It may be easier for you to start there: https://developers.google.com/blockly

1reaction
takaokoujicommented, Mar 19, 2020

@caxapexac

Can you give me examples please?

It’s Smalruby ( https://github.com/smalruby/smalruby3-gui/ and https://smalruby.jp/smalruby3-gui/ ) that is forked from scratch-gui. Smalruby can generate from scratch’s block to ruby code. And it can convert ruby code to scratch’s blocks.

Related code is here:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual blocks - Airplane Docs
Blocks have two modes: Auto (default): Blocks execute automatically—when the previous block has completed, the next block will start running right away. Manual: ......
Read more >
Block statement - jOOQ
The most basic building block in procedural languages is the block statement, which allows for creating scope (except for T-SQL, which has no...
Read more >
Evaluating Code Blocks (The Org Manual)
Evaluating Code Blocks (The Org Manual) ... By default, Org enables only Emacs Lisp code blocks for execution. See Languages to enable other...
Read more >
Order of execution of different Stan blocks - Modeling
Hi there, I have a question related to the sequence that different blocks in Stan are executed. Lets say I have the following...
Read more >
Function Block | Manualzz
You define execution order by wiring function blocks together and indicating the data flow of any feedback wires, if necessary. If function blocks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found