Simple and useful suggestion.
append() method from array object could return the index of the element added.
array.append() returning index
Moderator: POL Developer
Re: array.append() returning index
What about your own user function?
arrays.inc
arrays.inc
Code: Select all
function AppendToArrayEx(byref x_array, byref x_data)
x_array.Append(x_data);
return x_array.Size();
endfunction
Re: array.append() returning index
I know the name is "append", but I though it could add at index different from 1 + the last one.
For example, having this array:
1 = used,
2 = used,
3 = empty,
4 = used,
5 = used,
6 = empty,
7 = used,
I though append(some value) would add at index 3, not at index 8.
For example, having this array:
1 = used,
2 = used,
3 = empty,
4 = used,
5 = used,
6 = empty,
7 = used,
I though append(some value) would add at index 3, not at index 8.
Re: array.append() returning index
no it would not add to those values. It will only add at the end... at 8 in your example.
Re: array.append() returning index
This would be horribly slow on a large array
Code: Select all
function InsertInAvailableArraySlot(byref x_array, byref x_data)
foreach indice in ( x_array )
if ( indice == error || !indice )
x_array[_indice_iter] = x_data;
return _indice_iter;
endif
endforeach
x_array.Append(x_data);
return x_array.Size();
endfunction