How does nested for-loops work in the Vuo API?

I have tried a bit with a few different approaches, but can't seem to get it right. This works as expected:

void nodeEvent
(
        VuoInputData(VuoInteger) testI,
        VuoOutputData(VuoInteger) iAmount,
)
{
    for(int i = 1; i <= testI; ++i){
        *iAmount = i;
 
    }
 
}

While this (or similar) seems to get stuck in an infinite loop where force quitting is the only option. Is it something fundamental I'm missing?

void nodeEvent
(
        VuoInputData(VuoInteger) testI,
        VuoInputData(VuoInteger) testJ,
        VuoOutputData(VuoInteger) iAmount,
        VuoOutputData(VuoInteger) jAmount
)
{
    for(int i = 1; i <= testI; ++i){
        *iAmount = i;
        for(int j = 1; i <= testJ; ++j){
            *jAmount = j;
        }
    }
 
}

When I run the node, I'm triggering manually so it shouldn't blow up because of the refresh rate. I've also tested with Processing if it was something stupid I did syntax wise that would end up with such a result. I've also tried with i = 0; i < target; etc.

Comments

Upon even closer inspection,

MartinusMagneson's picture
Submitted by

Upon even closer inspection, the sloppy loop wasn't really the problem (it was a problem though, a stupid one at that)!

I was trying to get a layer width by dividing two integers:

VuoReal real = intA / intB;

This worked kind of, as long as intA was an integer. If intA fell below 1 it would just end up in 0s, cascading down the code which made the for loop look like the culprit, putting out the same number for every iteration. Creating a new VuoReal that got the value from the integer input solved it.