From 04d6d119c076a42fb5777bb3f272d8256f2de499 Mon Sep 17 00:00:00 2001 From: Monica Kozbial Date: Thu, 9 Jun 2016 18:09:37 -0700 Subject: [PATCH] Add indexing setting for JavaScript Generation (#419) Adding setting to allow for switching between zero and one based indexing for Blockly Blocks such that the generated code will use this flag to determine whether one based or zero based indexing should be used. One based indexing is enabled by default. --- generators/javascript.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generators/javascript.js b/generators/javascript.js index 5bd49f9d2..cde1709e5 100644 --- a/generators/javascript.js +++ b/generators/javascript.js @@ -103,6 +103,12 @@ Blockly.JavaScript.ORDER_ASSIGNMENT = 16; // = += -= *= /= %= <<= >>= ... Blockly.JavaScript.ORDER_COMMA = 17; // , Blockly.JavaScript.ORDER_NONE = 99; // (...) +/** + * Allow for switching between one and zero based indexing, one based by + * default. + */ +Blockly.JavaScript.ONE_BASED_INDEXING = true; + /** * Initialise the database of variable names. * @param {!Blockly.Workspace} workspace Workspace to generate code from.