Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in code demo #15

Closed
GoogleCodeExporter opened this issue Dec 6, 2015 · 4 comments
Closed

Run in code demo #15

GoogleCodeExporter opened this issue Dec 6, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Is there a way to run code, built in "code demo", and view result of program 
execution?

Original issue reported on code.google.com by roman.ku...@gmail.com on 5 Jun 2012 at 6:40

@GoogleCodeExporter
Copy link
Author

I've make a working 'Run in code demo' example in 
http://www.gasolin.idv.tw/public/blockly/demos/code/index.html

all you need is:

1. add a link in demo page

<a href="javascript: return false;" onclick="javascript:runJS()">Run in 
Javascript</a>

2. add a runJS() function below the init(blockly) function

function runJS() {
  console.log("run");
  tabClick("tab_javascript");
  var x=document.getElementById('content_javascript');
  console.log(x.innerHTML);
  eval(x.innerHTML);
}

click the link will be switched to javascript tab and run the script.

Original comment by gasolin on 7 Jun 2012 at 5:34

@GoogleCodeExporter
Copy link
Author

a modified version will just run the code without switch to JS tab

function runJS() {
  eval(Blockly.Generator.workspaceToCode('JavaScript'))
}

Original comment by gasolin on 9 Jun 2012 at 5:57

@GoogleCodeExporter
Copy link
Author

Good idea, and one that gets mentioned a lot by visitors.  I've pushed revision 
225 which adds a run button and does basic error trapping.

However, unlike the more limited and more complicated execution in the maze 
demo, it does not detect infinite loops and it does not highlight the executed 
blocks.  Doing so would result in unreadable JS code filled with callbacks and 
serial numbers.

Original comment by neil.fra...@gmail.com on 9 Jun 2012 at 7:40

  • Changed state: Fixed
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Have you looked at doing the same thing for playground.html?

Original comment by jkrid...@gmail.com on 17 Sep 2013 at 8:29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant