# Question on tags - offsets

**URL:** <https://www.ruby-forum.com/t/question-on-tags-offsets/242370>\
**Category:** GNU Radio\
**Created:** [June 19, 2015, 4:51am UTC](https://www.ruby-forum.com/t/question-on-tags-offsets/242370 "2015-06-19T04:51:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 19, 2015, 4:51am UTC](https://www.ruby-forum.com/t/question-on-tags-offsets/242370/1 "2015-06-19T04:51:57Z")

</div>

Hi,

A quick question on tags.

I’m coding a custom block in python and my forecast function is like so:

def forecast(self, noutput\_items, ninput\_items\_required):  
#setup size of input\_items[i] for work call  
for i in range(len(ninput\_items\_required)):  
ninput\_items\_required[i] = 64

If my understanding is correct, every 64 items, the block’s work  
function  
is called.

Each time work is called, I want to add a tag to the first of the 64  
elements that come in (the _value_ of my tag is a list). So I used:

lst = (1, 2, 3, 4) #example

```
    item_index = 0
    offset = self.nitems_written(0) + item_index
    key = pmt.string_to_symbol("example")
    value = pmt.to_pmt(lst)

    self.add_item_tag(0, offset, key, value)

```

This works. I can see the tag being added when I use a QT time sink.

But when I add some print statements and check what I noticed is that  
tags  
are being added at indicies 0, 8192, 16384 etc. Basically multiples of  
8192  
which is the full length of the input buffer in0 = input\_items[0].

Shouldn’t self.nitems\_written(0) be 64 each time?

What I really want is tags being added at 0, 64, 128 etc. I’m sure I’m  
missing something pretty silly.

Thanks  
Anil

---

<div class="post-metadata">

**Author:** ![anil\_y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@anil\_y](https://www.ruby-forum.com/u/anil_y)\
**Post date:** [June 19, 2015, 7:30am UTC](https://www.ruby-forum.com/t/question-on-tags-offsets/242370/2 "2015-06-19T07:30:19Z")

</div>

Dear Anil,

Not every 64 items,but work() function is called if there are more than  
64  
items in the input stream (buffer).

Regards,  
Jeon.

2015-06-19 11:51 GMT+09:00 Anil K. Yerrapragada  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> :
