GDL
About building parametric objects with GDL.

Removing an array key (with value)

dushyant
Enthusiast
Hi

As a dictionary key can be removed using the function REMOVEKEY (dictionary.key), is there a way to remove an array's key (with value)?

I tried:
myDict.myArray[1] = 1
REMOVEKEY(myDict.myArray[1]) 
but that does not seem to remove it.

Thanks
2 REPLIES 2
runxel
Legend
Sadly, there is no native way to delete/pop items from an array. This makes it necessary to do a bit of juggling.


dim arr[]
  arr[1] = 0.1
  arr[2] = 0.2
  arr[3] = 0.3

! index of the item you want to delete
todelete = 2

dim new_arr[]
check = 0
for i = 1 to vardim1(arr)-1
	if i = todelete then check = 1
	new_arr = arr[i+check]
next i

arr = new_arr

print arr   !>>> will print:  "0.1  0.3"
Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
dushyant
Enthusiast
Hi runxel

Ok, I get the idea. Thanks a lot!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!