krish-adi / barfi

Python Flow Based Programming environment that provides a graphical programming environment.
https://barfi.readthedocs.io
MIT License
659 stars 71 forks source link

How Can i Implement “for each”、“if”,“swich” function with block #34

Open dyingstraw opened 5 months ago

dyingstraw commented 5 months ago

I just Implement for each just belows,but it does not work。 image

just like execute first set_interface here.

for_block = Block(name='For')
for_block.add_input(name="for_array")
for_block.add_output(name="for_out")
for_block.add_output(name="for_index")
for_block.add_output(name="for_final")
def foreach_fn(self):
    array = self.get_interface("for_array")
    print("enter for:{}",array)
    for index,item in enumerate(array):
        print("enter for item:{}",item)
        **self.set_interface(name="for_out",value=item)** # just here
        self.set_interface(name="for_inex",value=index)
    self.set_interface(name="for_final",value=None)

for_block.add_compute(foreach_fn)

Maybe I can modify the ComputeEngine?

krish-adi commented 2 months ago

do you want to add a switch statement as a block?