# GRC xml file: port declaration order

**URL:** <https://www.ruby-forum.com/t/grc-xml-file-port-declaration-order/227714>\
**Category:** GNU Radio\
**Created:** [March 26, 2013, 11:56am UTC](https://www.ruby-forum.com/t/grc-xml-file-port-declaration-order/227714 "2013-03-26T11:56:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdejong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a9a28c/32.png) [@jdejong](https://www.ruby-forum.com/u/jdejong)\
**Post date:** [March 26, 2013, 11:56am UTC](https://www.ruby-forum.com/t/grc-xml-file-port-declaration-order/227714/1 "2013-03-26T11:56:19Z")

</div>

Hello list,

do message ports have to be declared after the other ports in the  
corresponding GRC xml file? For visual purposes I tried to rearrange  
them because I want the message ports to appear above the stream ports.  
Unfortunately this leads to the effect that stream ports are counted  
incorrectly in the generated python file. Port 0 has index 1 etc. and  
thus the python file can’t be executed.

- Johannes

---

<div class="post-metadata">

**Author:** ![jdejong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a9a28c/32.png) [@jdejong](https://www.ruby-forum.com/u/jdejong)\
**Post date:** [March 26, 2013, 3:55pm UTC](https://www.ruby-forum.com/t/grc-xml-file-port-declaration-order/227714/2 "2013-03-26T15:55:55Z")

</div>

On Tue, Mar 26, 2013 at 6:54 AM, Johannes D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello list,
> 
> do message ports have to be declared after the other ports in the  
> corresponding GRC xml file? For visual purposes I tried to rearrange them  
> because I want the message ports to appear above the stream ports.  
> Unfortunately this leads to the effect that stream ports are counted  
> incorrectly in the generated python file. Port 0 has index 1 etc. and thus  
> the python file can’t be executed.
> 
> - Johannes

I can confirm that this is a problem. I happened to have been working  
on some message passing stuff myself, so I thought I’d try out what  
you were doing.

Try this patch and let me know if that solves your problem and that  
everything behaves like it should:

diff --git a/grc/python/Port.py b/grc/python/Port.py  
index 0703d67..d4afa6c 100644  
— a/grc/python/Port.py  
+++ b/grc/python/Port.py  
@@ -92,6 +92,7 @@ class Port(\_Port, \_GUIPort):  
“”"  
self.\_n = n  
if n[‘type’] == ‘msg’: n[‘key’] = ‘msg’

- 

```
           if n['type'] == 'message': n['key'] = n['name']
          if dir == 'source' and not n.find('key'):
                  n['key'] = str(block._source_count)
                  block._source_count += 1

```

Tom
