void someFunction(int *num1, int *num2)
{
*num1 = *num1 + 1;
*num2 = *num2 + 2;
}
function someFunction(num1, num2)
return {
num1: num1 + 1
num2: num2 + 2
}
end function
num1 = 1
num2 = 2
a = someFunction(num1, num2)
num1 = a.num1
num2 = a.num2
Sub someSub(num1 as Object, num2 as Object)
num1.setInt(num1 + 1)
num2.setInt(num2 + 2)
End Sub
num1 = CreateObject("roInt")
num2 = CreateObject("roInt")
num1.setInt(1)
num2.setInt(2)
someSub(num1,num2)
print num1,num2
2 4
"renojim" wrote:
If you use the roInt object type and the ifInt interface you can modify the num1 and num2 in place:Sub someSub(num1 as Object, num2 as Object)
num1.setInt(num1 + 1)
num2.setInt(num2 + 2)
End Sub
To use it:num1 = CreateObject("roInt")
num2 = CreateObject("roInt")
num1.setInt(1)
num2.setInt(2)
someSub(num1,num2)
print num1,num2
Produces:2 4
I'm not saying this is really a better way to do it since the first time you forget to use the setInt interface (e.g., num1 += 1 or just initializing it without setInt) you turn it into an Integer and it's no longer an roInt object and someSub will no longer modify it in place.
-JT
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!