problem with the block.id

510 views
Skip to first unread message

Davide Longo

unread,
Jan 31, 2017, 6:43:09 AM1/31/17
to Blockly
Hi all,

I have a problem with the block.id.
the ID of the block is automatically created in the creation of the block, where the special characters are also used, and this does not allow to use the block.id as a field of an array (if the generated ID contains for example a comma, I have problems with functions such as split (" , "))

do you have the solution for this ? is possible to change the ID creation for not use the special characters (my best way) ?

thanks at all !

Andrew n marshall

unread,
Jan 31, 2017, 2:32:09 PM1/31/17
to blo...@googlegroups.com
The Block IDs are generated by Blockly.utils.genUid(). The character set is defined in Blockly.utils.genUid.soup_. We include as many characters as possible to keep event messages as short as possible. We hope to eventually pass these over the network as part of collaboration support.  If you limit the characters used in your app, you should increase the length used in Blockly.utils.genUid() to ensure ID conflicts remain statistically impossible.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Davide Longo

unread,
Feb 1, 2017, 4:00:02 AM2/1/17
to Blockly
Hi Andrew,
thanks a lot, your answer helped me for solve the problem!! :)
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.

Andrew Stratton

unread,
Feb 3, 2017, 4:34:57 AM2/3/17
to Blockly
Hi Davide
  I had a similar issue - see https://groups.google.com/forum/#!topic/blockly/jk3T1_e5de0, where % was causing an issue.

  I actually avoided my issue when I moved from a PHP backend (which I only used for institution hosting reasons) to using Node JS - there were other reasons as well.

  However - I did also try encoding the id - but didn't get to use my solution in anger - it did seem to work though.

  You may just get away with keeping the id in quotes...

  Hope this helps
    Andy

P.S. I use ids a lot for linking blocks to other blocks - it works well.

Computer Scratch

unread,
Dec 16, 2022, 1:59:26 AM12/16/22
to Blockly
Can I set the Id of a block with only numbers.
Please reply!!!
Reply all
Reply to author
Forward
0 new messages