2022-09-0806:30 AM - last edited on 2022-09-2601:41 PM by dkassai
I'm trying to define an array by an integer. I want my array to have an equal amount of fields as an integer. I want to be able to use the array fields to define positions of elements so they need to hold the values while more are added or removed based on the integer.
This is what I have currently, however it locks the value to 0 as I would expect. I'm just not sure how to achieve what I'm after.
if (glob_modpar_name = "num_steps") or (glob_modpar_name = "total_distance") then
for i=1 to num_steps2
num_position_x2[i] = 0
num_position_y2[i] = 0
You will need to shadow the parameters. I have prepared a small but working example, which can be easily extended to suit all your needs.
if GLOB_MODPAR_NAME = "n_steps" then
if n_steps_shadow < n_steps then
! We have more steps than before
for i=(n_steps_shadow+1) to n_steps
! init those values
x_pos[i] = 0.0
! Less steps then before
for i=1 to n_steps
_newx[i] = x_pos[i]
x_pos = EMPTYARRAY
x_pos = _newx
n_steps_shadow = n_steps
x_pos = x_pos,
n_steps_shadow = n_steps_shadow
Mostly AC 26 on Mac | Author of SelfGDL | Developer of the GDL plugin for Sublime Text | «Furthermore, I consider that Carth... yearly releases must be destroyed»