@@ -182,7 +182,7 @@ Blockly.Blocks.array_get = {
182182 this . setTooltip ( Blockly . MSG_ARRAY_GET_TOOLTIP ) ;
183183 this . setColour ( colorPalette . getColor ( 'variables' ) ) ;
184184 this . appendValueInput ( 'NUM' )
185- . appendField ( 'Array ' )
185+ . appendField ( 'array ' )
186186 . appendField ( new Blockly . FieldTextInput ( 'list' ) , 'VAR' )
187187 . appendField ( 'element' ) ;
188188 this . setInputsInline ( true ) ;
@@ -192,6 +192,8 @@ Blockly.Blocks.array_get = {
192192
193193Blockly . propc . array_get = function ( ) {
194194 var varName = this . getFieldValue ( 'VAR' ) ;
195+ varName = varName . replace ( " " , "_" ) ;
196+ varName = varName . replace ( / \W / g, "" ) ;
195197 var element = Blockly . propc . valueToCode ( this , 'NUM' , Blockly . propc . ORDER_NONE ) || '0' ;
196198 var list = Blockly . propc . global_vars_ ;
197199
@@ -210,7 +212,7 @@ Blockly.Blocks.array_init = {
210212 this . setTooltip ( Blockly . MSG_ARRAY_INIT_TOOLTIP ) ;
211213 this . setColour ( colorPalette . getColor ( 'variables' ) ) ;
212214 this . appendDummyInput ( )
213- . appendField ( 'Array initialize' )
215+ . appendField ( 'array initialize' )
214216 . appendField ( new Blockly . FieldTextInput ( 'list' ) , 'VAR' )
215217 . appendField ( "with" )
216218 . appendField ( new Blockly . FieldTextInput ( '10' ,
@@ -224,6 +226,8 @@ Blockly.Blocks.array_init = {
224226
225227Blockly . propc . array_init = function ( ) {
226228 var varName = this . getFieldValue ( 'VAR' ) ;
229+ varName = varName . replace ( " " , "_" ) ;
230+ varName = varName . replace ( / \W / g, "" ) ;
227231 var element = this . getFieldValue ( 'NUM' ) || '10' ;
228232
229233 Blockly . propc . global_vars_ [ '__ARRAY' + varName ] = 'int ' + varName + '[' + element + '];' ;
@@ -237,7 +241,7 @@ Blockly.Blocks.array_fill = {
237241 this . setTooltip ( Blockly . MSG_ARRAY_FILL_TOOLTIP ) ;
238242 this . setColour ( colorPalette . getColor ( 'variables' ) ) ;
239243 this . appendDummyInput ( )
240- . appendField ( 'Array fill' )
244+ . appendField ( 'array fill' )
241245 . appendField ( new Blockly . FieldTextInput ( 'list' ) , 'VAR' )
242246 . appendField ( "with values" )
243247 . appendField ( new Blockly . FieldTextInput ( '10,20,30,40,50' ) , 'NUM' ) ;
@@ -248,6 +252,8 @@ Blockly.Blocks.array_fill = {
248252
249253Blockly . propc . array_fill = function ( ) {
250254 var varName = this . getFieldValue ( 'VAR' ) ;
255+ varName = varName . replace ( " " , "_" ) ;
256+ varName = varName . replace ( / \W / g, "" ) ;
251257 var varVals = this . getFieldValue ( 'NUM' ) ;
252258 varVals = varVals . replace ( / [ ^ 0 - 9 , -\. ] / g, "" ) ;
253259 varVals = varVals . replace ( / , \. / g, ",0." ) ;
@@ -308,7 +314,7 @@ Blockly.Blocks.array_set = {
308314 this . setTooltip ( Blockly . MSG_ARRAY_SET_TOOLTIP ) ;
309315 this . setColour ( colorPalette . getColor ( 'variables' ) ) ;
310316 this . appendValueInput ( 'NUM' )
311- . appendField ( 'Array ' )
317+ . appendField ( 'array ' )
312318 . appendField ( new Blockly . FieldTextInput ( 'list' ) , 'VAR' )
313319 . appendField ( 'element' ) ;
314320 this . appendValueInput ( 'VALUE' )
@@ -321,6 +327,8 @@ Blockly.Blocks.array_set = {
321327
322328Blockly . propc . array_set = function ( ) {
323329 var varName = this . getFieldValue ( 'VAR' ) ;
330+ varName = varName . replace ( " " , "_" ) ;
331+ varName = varName . replace ( / \W / g, "" ) ;
324332 var element = Blockly . propc . valueToCode ( this , 'NUM' , Blockly . propc . ORDER_NONE ) || '0' ;
325333 var value = Blockly . propc . valueToCode ( this , 'VALUE' , Blockly . propc . ORDER_NONE ) || '0' ;
326334 var list = Blockly . propc . global_vars_ ;
@@ -347,7 +355,7 @@ Blockly.Blocks.array_clear = {
347355 this . setTooltip ( Blockly . MSG_ARRAY_CLEAR_TOOLTIP ) ;
348356 this . setColour ( colorPalette . getColor ( 'variables' ) ) ;
349357 this . appendDummyInput ( )
350- . appendField ( 'Array clear' )
358+ . appendField ( 'array clear' )
351359 . appendField ( new Blockly . FieldTextInput ( 'list' ) , 'VAR' ) ;
352360 this . setPreviousStatement ( true ) ;
353361 this . setNextStatement ( true ) ;
@@ -356,6 +364,8 @@ Blockly.Blocks.array_clear = {
356364
357365Blockly . propc . array_clear = function ( ) {
358366 var varName = this . getFieldValue ( 'VAR' ) ;
367+ varName = varName . replace ( " " , "_" ) ;
368+ varName = varName . replace ( / \W / g, "" ) ;
359369 var list = Blockly . propc . global_vars_ ;
360370
361371 if ( Object . keys ( list ) . indexOf ( '__ARRAY' + varName ) < 0 ) {
0 commit comments