// this must be generated. (see 'procedures_defreturn')function do_something()
{
}
function do_something()
{
if(true) {
}}
var randomNameVar1 = {"name":"John", "married":false, "age":35, kids:["Anne", "Laura", "Zach"]};
var x1 = "";
function do_something() {
if(true) {
var i;
for (i in randomNameVar1.kids) { x += randomNameVar1.kids[i] + "<br>"; }
}
}just have to make a BLOCK that has a LOCAL variable and return it as result
var board = new five.Board();
board.on("ready", function () {
var ROOD;
ROOD = new five.Led("A2");
ROOD.on();
});
Blockly.JavaScript['test_dropdown1'] = function(block) {
var digitalIOPoort;
var actie1;
var dropdown_ledkleur = block.getFieldValue('LEDKLEUR');
var dropdown_led_stat2 = block.getFieldValue('LED_STAT2');
switch (dropdown_ledkleur) {
case "ROOD":
digitalIOPoort = "\"A2\"";
break;
case "GROEN":
digitalIOPoort = "\"A1\"";
break;
case "BLOU":
digitalIOPoort = "\"A0\"";
break;
default:
digitalIOPoort = 13;
}
var code = "";
code += "\nvar " + dropdown_ledkleur + ";\n"
code += dropdown_ledkleur + " = new five.Led(" + digitalIOPoort + ");\n";
if (dropdown_led_stat2 == 'AAN') {
actie1 = ".on();";
} else if (dropdown_led_stat2 == 'UIT') {
actie1 = ".off();";
} else if (dropdown_led_stat2 == 'KNIPPER') {
actie1 = ".blink(500);";
} else if (dropdown_led_stat2 == 'FADEIN') {
actie1 = ".fadeIn();\n";
actie1 += "this.wait(1000, function() {\n";
actie1 += " " + dropdown_ledkleur + ".fadeOut();\n";
actie1 += "});";
} else if (dropdown_led_stat2 == 'FADEOUT') {
actie1 = ".fadeOut();\n";
actie1 += "this.wait(1000, function() {\n";
actie1 += " " + dropdown_ledkleur + ".fadeIn();\n";
actie1 += "});";
}
code += dropdown_ledkleur + actie1 + "\n";
return code;
};
var board = new five.Board();
var ROOD1; // this must be global
var ROOD2; // this must be global
board.on("ready", function () {
ROOD1 = new five.Led("A2");
ROOD1.on();
ROOD2 = new five.Led("A3");
ROOD2.on();
});
{ "type": "led_on_off", "message0": "turn LED %1 %2", "args0": [ { "type": "field_variable", "name": "NAME", "variable": "led1" }, { "type": "field_dropdown", "name": "STATE", "options": [ [ "on", "OPT_ON" ], [ "off", "OPT_OFF" ] ] } ], "previousStatement": null, "nextStatement": null, "colour": 230, "tooltip": "", "helpUrl": "" }
{ "type": "led_create", "message0": "LED %1 on pin %2", "args0": [ { "type": "field_variable", "name": "NAME", "variable": "led1" }, { "type": "field_dropdown", "name": "TYPE", "options": [ [ "A2", "A2" ], [ "A3", "A3" ], [ "A4", "A4" ] ] } ], "previousStatement": null, "nextStatement": null, "colour": 230, "tooltip": "", "helpUrl": "" }
--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/ecvPPnxp5vY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.
Blockly.Arduino.definitions_['define_custom_read'] = '#include <Servo.h>\n';#include <Servo.h>
Servo servo_1;
void setup()
{
servo_1.attach(1);
}
var globalVar1 = "var myServo = 'test1';";
Blockly.Arduino.definitions_["globalvar_my_test"] = globalVar1;
var myServo = 'test1'; // global variable generated :))
Servo servo_1;
void setup()
{
servo_1.attach(1);
}