Getting my head around multi-dimensional arrays
normschaef
Posts: 17
All:
So I'm working with two-dimensional arrays and I think I've got a good handle on the correct syntax. Just checking with the forum to make sure.
Ex.
To implement I think my code should look like:
Does that look close?
Thanks,
Norm
So I'm working with two-dimensional arrays and I think I've got a good handle on the correct syntax. Just checking with the forum to make sure.
Ex.
Camera1Position [2][4] = //two rows, four columns { {4500,250,49,1523}, //row 1 - focus, pan, tilt, zoom {4500,358,66,1523} }
To implement I think my code should look like:
SEND_COMMAND camera1, "'Focus = ',Camera1Position[1][1],'Pan=',Camera1Position[1][2],'Tilt=',Camera1Position[1][3],'Zoom=',Camera1Position[1][4]"
Does that look close?
Thanks,
Norm
0
Comments
Yep, you're getting it. You could rewrite the command like this into a funciton.
On a side note: If your intention is to have the text look like this:
"Focus=4500Pan=250 etc..."
You will need to put the variables into an ITOA() function "Integer To ASCII"
otherwise you're going to get some goofy resuls since it will send a literal 4500 decimal.
So it will look like this:
and for more fun. to prevent the function from accidntally prducing an error you could put a couple traps to prevent bad indexes. In your example you have 2 cameras. So if you accidentally sent the cam_id as 3, it would produce an error (index too large) since you don't have a 3rd row in your array. Also if you accidntally sent cam_id as zero you'd get a zero index error. So put in these traps.
okay - enough fun for now.
e