# Run a top block within a block!

**URL:** <https://www.ruby-forum.com/t/run-a-top-block-within-a-block/230115>\
**Category:** GNU Radio\
**Created:** [May 31, 2014, 6:12am UTC](https://www.ruby-forum.com/t/run-a-top-block-within-a-block/230115 "2014-05-31T06:12:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 31, 2014, 6:12am UTC](https://www.ruby-forum.com/t/run-a-top-block-within-a-block/230115/1 "2014-05-31T06:12:48Z")

</div>

Hi GNURadiores,

I was thinking about how to change dynamically the blocks connected in  
my  
top block when it’s running!  
After a long time, I reach to this point that I may have a top block is  
running within _a block_! (Also another top block runs\* the block\*  
itself.

is that possible?  
If it is, I could change the top block which is in a block.

Best,  
Mostafa

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 31, 2014, 6:34am UTC](https://www.ruby-forum.com/t/run-a-top-block-within-a-block/230115/2 "2014-05-31T06:34:32Z")

</div>

On Sat, May 31, 2014 at 12:11 PM, Mostafa A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi GNURadiores,  
> I was thinking about how to change dynamically the blocks connected in my  
> top block when it’s running!

What do you want to change; the block parameters, or the links  
connecting  
the blocks (which is the flowgraph itself)?  
Basically both are possible, you may need to enhance your flowgraph in  
python code by hand. During execution, lock the flowgraph, modify it  
accordingly, and then unlock it to proceed with the flowgraph execution.

> After a long time, I reach to this point that I may have a top block is  
> running within _a block_!

Probably you are referring to “hierarchical block” ..?

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [June 1, 2014, 8:31am UTC](https://www.ruby-forum.com/t/run-a-top-block-within-a-block/230115/3 "2014-06-01T08:31:35Z")

</div>

On Sat, May 31, 2014 at 5:53 PM, Mostafa A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi Activecat,  
> I wanna change both block parameters and their connections also adding or  
> removing some blocks.  
> This is interesting if it’s possible to build a flowgraph within the  
> _work_ function of a block which allows me to change a part of the main  
> flowgraph!

In my knowledge, hierarchical blocks do not have “work()” function.  
They are usually coded in python, consisting “self.connect()” to connect  
up  
its building blocks.

> However, the problem is the source and sink for the flowgraph within the  
> block (or _work function)._ I think this also possible to have a source  
> (sink) which simply gives a pointer, which points to the input(output) of  
> the _block(with this dynamic flowgraph)_ and a number of items to produce  
> (consume).
> 
> This is more than just a hier\_block.

I don’t really understand your statements but I hope you could  
accomplish  
what you want.  
Thanks.
