Hello
:global aaa {a=1;b=2;c=3;d=4;be=5} :foreach k,v in=$aaa do={:put (“$k=$v”)} result is a=1 b=2 c=3 d=4 e=5
How to shift value in the aray: a=2 b=3 c=4 d=5 e=6 (new value)
The task is to store only the last 5 values. Maybe there are other solutions how to do it?
1st: use local instead of global to prevent issues(local is auto, global is static) 2nd: use “=” inside array index is not needed, use($array->index) better to get or set values This example may help you to solve your issue
:do { :local array {1; 2; 3; 4; 5; 6; 7; 8; 9; 10}; :for i from=0 to=([:len $array]-2) do={ :set ($array->i) ($array->(i+1)); } :put $array; } on-error={:log error "ERROR"}
Output will get
2;3;4;5;6;7;8;9;10;10