Question on a Feature

Issue #41 resolved
Turgut Guneysu created an issue

Hi John,

Is there any way to access Javascript code from microBlocks, similar to SNAP! ?

Comments (2)

  1. John Maloney repo owner

    No, because the MicroBlocks IDE isn’t implemented in JavaScript.

    However, there is a way to interact with MicroBlocks from JavaScript. If you turn on “show advanced blocks” and start the “Mozilla WebThing server” you can use HTTP requests to get/set variables and send/receive broadcasts. Here’s a summary of the URL scheme:

    MicroBlocks HTTP Server
    
    /mb/ - this help text
    /mb/getBroadcasts - get broadcasts from board, (URL-encoded strings, one per line)
    /mb/broadcast/URL_encoded_message - broadcast message to board
    /mb/getVar/URL_encoded_var_name - get variable value
    /mb/setVar/URL_encoded_var_name/value - set variable value
      (value is: true, false, INTEGER, or a url_encoded_string)
    

    You can print this summary in the browser by typing:

    http://127.0.0.1:6473/mb/
    

    in the URL field of your browser. Note that variable names containing spaces or other non URL-safe characters must be URL encoded (e.g. a space is encoded as %20).

  2. Log in to comment