transforming blockly logic

81 views
Skip to first unread message

arshad dar

unread,
May 6, 2020, 1:11:32 PM5/6/20
to Blockly
i need to transform logic written in blockly, the idea is user will write logic and i need to analyze that make some changes to block e.g based on certain in existing logic i have to replace if with an map. is there any easy way to do that?

Daniel Ehren

unread,
May 7, 2020, 5:52:25 AM5/7/20
to Blockly
Hello,

Im have some understanding problems. What does 'map' mean in this context?

So what I think is, that you want to implement an extended propositional logic in Blockly and evaluate partial expressions by changing the blocks, right? 

arshad dar

unread,
May 7, 2020, 8:04:25 AM5/7/20
to Blockly

problem.PNG

thank you for your response

by map i mean dictionary 

if you look at the image the left side is the original logic written by user and on the right side is the what i need to generate. there is one if statement comparing customer variable with some other variable, whenever i encounter this  condition in  logic i need remove if and convert it to map, the customer variable will be its key and values will be statements inside the if that mutate data. the image show the simple use case we can have if connected with logical and whose one comparison may have customer variable other comparison may not have customer variable. in that case i have to convert one part to map and keep other part as it is.

Daniel Ehren

unread,
May 7, 2020, 10:55:05 AM5/7/20
to Blockly
Okay, so aside from the useness of this implementation, which I still dont unterstand.

"is there any easy way to do that?"

Easy is relative, but I would definitly say no, because this is not the way how Blockly is thought to works. Blockly is designed to make consistent blocks which are interpretated after through Generators. This is because manipulating Strings is a lot more easier than complex DOM Objects.   

But there will be definitly a possible solution, which will cost a lot of effort. There are no limits set by Blockly Developers, but overwriting functions which works on a deep layer usually brings more problems at programming. But mostly of the things you will needed are documented. 

Coda Highland

unread,
May 7, 2020, 1:10:58 PM5/7/20
to blo...@googlegroups.com
I'd like to ask a bit broader of a question: What's your use case? Is this something that needs to be automatically transformed in realtime whenever someone puts it in? Or are you trying to migrate older user scripts to use new features?

If this is something that can be processed offline, or just once when loading the XML into the workspace, then this is definitely something you can do without having to modify Blockly at all -- you can do this entirely through XML manipulation. I won't say it's necessarily an easy task -- it's certainly going to be tedious -- but it shouldn't be TOO terribly ugly.

/s/ Adam

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/4191eb23-1cb7-4a7e-a9c8-6d2b273e2d0f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages