GDL
About building parametric objects with GDL.
SOLVED!

Are GDL arrays 0 indexed?

Jack D
Booster

I'm asking this since my supervisor is always starts array at 1. 

 

DIM potato[]

   potato[1] = "russet"
   potato[2] = "yukon"
   potato[3] = "red lady"

To be honest, having 1 as the start of the index, kinda weirds me out but at the same time I'm also a bit curious if it is 0 indexed. Does this mean potato[0] does not exist or is potato[0] a none type?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
DGSketcher
Legend

In GDL, arrays are always indexed from [1] or a 2D array would be [1][1]. Your example of potato[0] should throw up an invalid index warning when you check your script.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)

View solution in original post

3 REPLIES 3
Solution
DGSketcher
Legend

In GDL, arrays are always indexed from [1] or a 2D array would be [1][1]. Your example of potato[0] should throw up an invalid index warning when you check your script.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)

ahh thanks! I've been looking for some mention if it's 0 index in the pdf guide but got nothing. Which got me thinking.

Here are the details of using arrays: https://gdl.Graphisoft.com/reference-guide/expressions#DIM_gdlcommand

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest