Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
0f187fc3
Commit
0f187fc3
authored
Nov 10, 2014
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add starting blocks to JS generator/interpreter demos.
parent
0798e24e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
demos/generator/index.html
demos/generator/index.html
+51
-0
demos/interpreter/index.html
demos/interpreter/index.html
+51
-0
No files found.
demos/generator/index.html
View file @
0f187fc3
...
...
@@ -63,9 +63,60 @@
</category>
</xml>
<xml
id=
"startBlocks"
style=
"display: none"
>
<block
type=
"controls_if"
inline=
"false"
x=
"20"
y=
"20"
>
<mutation
else=
"1"
></mutation>
<value
name=
"IF0"
>
<block
type=
"logic_compare"
inline=
"true"
>
<field
name=
"OP"
>
EQ
</field>
<value
name=
"A"
>
<block
type=
"math_arithmetic"
inline=
"true"
>
<field
name=
"OP"
>
MULTIPLY
</field>
<value
name=
"A"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
6
</field>
</block>
</value>
<value
name=
"B"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
7
</field>
</block>
</value>
</block>
</value>
<value
name=
"B"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
42
</field>
</block>
</value>
</block>
</value>
<statement
name=
"DO0"
>
<block
type=
"text_print"
inline=
"false"
>
<value
name=
"TEXT"
>
<block
type=
"text"
>
<field
name=
"TEXT"
>
Don't panic
</field>
</block>
</value>
</block>
</statement>
<statement
name=
"ELSE"
>
<block
type=
"text_print"
inline=
"false"
>
<value
name=
"TEXT"
>
<block
type=
"text"
>
<field
name=
"TEXT"
>
Panic
</field>
</block>
</value>
</block>
</statement>
</block>
</xml>
<script>
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainWorkspace
,
document
.
getElementById
(
'
startBlocks
'
));
function
showCode
()
{
// Generate JavaScript code and display it.
...
...
demos/interpreter/index.html
View file @
0f187fc3
...
...
@@ -71,9 +71,60 @@
<category
name=
"Functions"
custom=
"PROCEDURE"
></category>
</xml>
<xml
id=
"startBlocks"
style=
"display: none"
>
<block
type=
"variables_set"
inline=
"true"
x=
"20"
y=
"20"
>
<field
name=
"VAR"
>
n
</field>
<value
name=
"VALUE"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
1
</field>
</block>
</value>
<next>
<block
type=
"controls_repeat_ext"
inline=
"true"
>
<value
name=
"TIMES"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
4
</field>
</block>
</value>
<statement
name=
"DO"
>
<block
type=
"variables_set"
inline=
"true"
>
<field
name=
"VAR"
>
n
</field>
<value
name=
"VALUE"
>
<block
type=
"math_arithmetic"
inline=
"true"
>
<field
name=
"OP"
>
MULTIPLY
</field>
<value
name=
"A"
>
<block
type=
"variables_get"
>
<field
name=
"VAR"
>
n
</field>
</block>
</value>
<value
name=
"B"
>
<block
type=
"math_number"
>
<field
name=
"NUM"
>
2
</field>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block
type=
"text_print"
inline=
"false"
>
<value
name=
"TEXT"
>
<block
type=
"variables_get"
>
<field
name=
"VAR"
>
n
</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</xml>
<script>
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainWorkspace
,
document
.
getElementById
(
'
startBlocks
'
));
var
myInterpreter
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment