cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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 | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
dushyant
Enthusiast
Hi runxel

Ok, I get the idea. Thanks a lot!
Learn and get certified!

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!