Appending onto an integer array?
jcerecke
Posts: 40
Has anyone done this before like it says in the NL keywords help on the Arrays page?
"Example:
LENGTH_ARRAY is called to determine the effective length of Array1 and Array2.
This value is set automatically when the arrays are initialized.
Array1 is appended to Array2.
Array2 now contains the values "1, 2, 3, 4, 5, 6, 7" and has an effective length of 7."
Just tried it and it didn't compile...
"Example:
INTEGER Len INTEGER Array1 = {3, 4, 5, 6, 7} INTEGER Array2[10] = {1, 2} Len = MAX_LENGTH_ARRAY(Array1) // Len = 5 Len = MAX_LENGTH_ARRAY(Array2) // Len = 10
LENGTH_ARRAY is called to determine the effective length of Array1 and Array2.
This value is set automatically when the arrays are initialized.
Len = LENGTH_ARRAY(Array1) // Len = 5 Len = LENGTH_ARRAY(Array2) // Len = 2 Array2+ = Array1 Len = LENGTH_ARRAY(Array2) // Len = 7
Array1 is appended to Array2.
Array2 now contains the values "1, 2, 3, 4, 5, 6, 7" and has an effective length of 7."
Just tried it and it didn't compile...
0
Comments
This isn't C# / C++ / Java, etc. NetLinx isn't that powerful, but I'm sure it's more powerful than Cr3stron's language.
That part of the help file must have been written on a Friday at 4 pm. You can't define an array this way:
integer array = {1,2,3}
you need the brackets:
integer array[] = {1,2,3}
and there is no array addition or subtraction that I know of in Netlinx.
Paul