Accessing variables

Hi guys,

I have a TOPtoCHOP that I want to use with different indexes. I’m trying to write a script for this, small smaple can be seen below:

dummy = me.var(‘Height’)
dummy = dummy + 5
me.parent().setVar(‘random’, dummy)

Earlier in the code I made a variable called ‘Height’ with this call:
me.parent().setVar(‘Height’, picture.fileHeight)

Now I want to use an X and Y variable to loop through the entire height and width of the picture. My script gives an error saying it can’t convert ‘int’ object to str implicitly
I’m not sure what this means, because as I know the Height is not a string or am I not accessing the variable right?

Thanks

Hi Jip,

I would recommend using storage instead of variables. This is the more modern method in TD and is way more flexible, so in the long term your energy learning this would be better spent.

It’s hard for me to pinpoint the exact error in your code without seeing your whole network, but I made you an example which reads the width & height of a TOP, and then traverses every 5th pixel in width and height, and resets to zero when it has reached the max width & height.
It saves the currentpixelx and currentpixely to storage of the parent every time.

I also placed an Examine DAT which shows you the current contents of the storage of the parent, so you see the stored values changing.
traverse_over_TOP_pixels.tox (1.38 KB)

Thanks for you’re answer, i’ve tried you’re method but it doesn’t seem to work ( I get a error with fetch) I attached my project to this reply, could you maybe take a look at what I did wrong?

Thanks!
Sending.toe (14.2 KB)