Hello, I'm new to DXL and have a simple question. I just want to add all elements of one array to another array. Something like this:
for (int i=0; i < sizeof(array); i++) { array1[i] += array2[i] } Is their a way to do this in DXL? Thanks! Mosep - Tue Jul 22 08:44:07 EDT 2014 |
Re: Adding an Array to Another Array New to DXL? I recomend you use the module tools menu to "browse" for dxl. Get a hard copy of one, then run it, and try to figure out how the code produced the results you see. DXL "arrays" are pretty weak. You MUST determine their actual size when you declare them. They cannot be used as output of a function since when delcared in the function, the space is removed from the stack when the function ends. Take a look at "Skip" lists; pretty straight forward replacement for "array"s.
Back to your problem.
Your "+=" reference would work if both arrays were type "int" and you wanted to add array2 to array1. Declaring "i" inside the loop control statement isn't going to work. -Louie |
Re: Adding an Array to Another Array llandale - Tue Jul 22 16:36:36 EDT 2014 New to DXL? I recomend you use the module tools menu to "browse" for dxl. Get a hard copy of one, then run it, and try to figure out how the code produced the results you see. DXL "arrays" are pretty weak. You MUST determine their actual size when you declare them. They cannot be used as output of a function since when delcared in the function, the space is removed from the stack when the function ends. Take a look at "Skip" lists; pretty straight forward replacement for "array"s.
Back to your problem.
Your "+=" reference would work if both arrays were type "int" and you wanted to add array2 to array1. Declaring "i" inside the loop control statement isn't going to work. -Louie Thanks! That was very helpful. |