bartbutenaers / node-red-contrib-blockly

A Node Red node for visual programming a function using Blockly
Apache License 2.0
91 stars 22 forks source link

[FeatureRequest]Add Parseint #21

Closed cymplecy closed 5 years ago

cymplecy commented 6 years ago

When dealing with colours in RGB hex format #FF00FF for magenta etc, I find myself needing to translate them into seperate R, G and B values.

In current JS function mode I do stuff like this

var r = msg.payload.substring(1,3);
r = parseInt(r, 16).toString();
....

but currently if I want to do the same in Blockly I have to write my own function to replace parseInt (which I've done successfully)

So I'm wondering if

Does core Blockly already have such a function written?

If it doesn't - can one be written (obviously yes)

But either way, should some requests like this be added into the Blockly node or should it stick to basic functions and methods.?

e.g just because we can do it - should we do it?

Simon

bartbutenaers commented 6 years ago

The IoBroker project already had added some converter blocks.

Remark: we will have to discuss whether I need to generate parseInt(...) or 'Number(...). See here for explanation.

cymplecy commented 6 years ago

Maybe don't expose parseInt or Number directly - just have a block with 2 dropdowns - xxx hex/dev/binary to hex/dec/binary

Just keep to dec, hex and binary (octal is so 1970's :) )

accept 0x and # (or no prefix) as valid hex prefixes - similar for binary

cymplecy commented 5 years ago

Withdrawn