krish-adi / barfi

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

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

Open dyingstraw opened 6 months ago

dyingstraw commented 6 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 3 months ago

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