Posted
·
Edited by MrMarx Adding information about why use getarg(1) as argument on copyarray.
I use the following:
function script funCopyInstanceMaps {
// Given instance name, and a reference to an Array,
// copy the array of maps to this new array.
.@instance_name$ = getarg(0);
.@which_maps$ = "$@maps_this_run_" + .@instance_name$ + "$";
.@map_count = getarraysize(getd(.@which_maps$));
copyarray(getarg(1), getd(.@which_maps$), .@map_count);
return;
}
Should be similar to your case. Usage of copyarray is documented in the script_commands.txt and there are examples on samples folder. Should work in your case with some tweaking for your situation, I suppose? Can have guard clauses on the amount of data to copy if desired.
I have getarg(1) as argument on copyarray because this is the variable I want to store the copy of the array by using getd on variable I'm obtaining dynamically on the string written in .@which_maps$.
How do I copy an array using `setd`?
in Script Support
Posted · Edited by MrMarx
Adding information about why use getarg(1) as argument on copyarray.
I use the following:
function script funCopyInstanceMaps { // Given instance name, and a reference to an Array, // copy the array of maps to this new array. .@instance_name$ = getarg(0); .@which_maps$ = "$@maps_this_run_" + .@instance_name$ + "$"; .@map_count = getarraysize(getd(.@which_maps$)); copyarray(getarg(1), getd(.@which_maps$), .@map_count); return; }
Should be similar to your case. Usage of copyarray is documented in the script_commands.txt and there are examples on samples folder. Should work in your case with some tweaking for your situation, I suppose? Can have guard clauses on the amount of data to copy if desired.
I have getarg(1) as argument on copyarray because this is the variable I want to store the copy of the array by using getd on variable I'm obtaining dynamically on the string written in .@which_maps$.