Arrays?
Posted: 07 Dec 2018, 22:07
I could not find any documentation regarding arrays (either numeric or string). Do they exist?
Community of Astroart users
https://www.astroart-forum.net/forum/
https://www.astroart-forum.net/forum/viewtopic.php?f=5&t=176
Code: Select all
filters = "LRRGGBB"
For i = 1 to Len(filters)
Print filters[i]
Next i
Code: Select all
Dim arr(10)
For i = 1 to 10
arr(i) = i*i
Next i
For i = 1 to 10
Print arr(i)
Next i
Code: Select all
Dim arr = {4, 5*5, "hel"+"lo", 0.5, Sqr(64)}
For i = 0 to 4
Print arr(i)
Next i
How do one get the dimension of an array? Don't want to hardcode size in the script I am creating.Forum_2015 wrote: ↑07 Dec 2018, 22:07For character arrays, you may use strings:
for string arrays, you may use the { } syntax, see the example:Code: Select all
filters = "LRRGGBB" For i = 1 to Len(filters) Print filters[i] Next i
Menu / Demos / Basic 4
for generic arrays, the standard Dim keyword is supported, but this feature is currently experimental (5.42 or newer). It works well, but there are two limitations: all arrays are global, whole arrays cannot be passed as function parameters.
Some examples:
arrays will be actually released as "lists", the following example is quite nice:Code: Select all
Dim arr(10) For i = 1 to 10 arr(i) = i*i Next i For i = 1 to 10 Print arr(i) Next i
Code: Select all
Dim arr = {4, 5*5, "hel"+"lo", 0.5, Sqr(64)} For i = 0 to 4 Print arr(i) Next i
Code: Select all
Dim arr = {4, 5*5, "hel"+"lo", 0.5, Sqr(64)}
For i = 0 to arr.Dim() <==== error, also tried "Dim", "Len()", "Len", .... and many more options
Print arr(i)
Next i