Initiate Arrays, Lists, etc.

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
User avatar
Calloway
Posts: 89
Joined: Apr 30th, '18, 00:28
Location: Eastern United States

Initiate Arrays, Lists, etc.

Post by Calloway » Nov 13th, '18, 01:03

Is there any set way to set a variable to an array of a certain size or a list of the same stature?
Or pretty much anything that isn't a string or number (for example, a table)

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Initiate Arrays, Lists, etc.

Post by JohnM » Jun 3rd, '19, 13:29

You can create a fixed size Array object with ten elements like this:

Code: Select all

print (newArray 10)
If you add a third parameter, the Array is filled with that value:

Code: Select all

print (newArray 10 'ha!')
Finally, you can turn an Array into a List like this:

Code: Select all

print (toList (newArray 10 'ho!'))

User avatar
Calloway
Posts: 89
Joined: Apr 30th, '18, 00:28
Location: Eastern United States

Re: Initiate Arrays, Lists, etc.

Post by Calloway » Jun 5th, '19, 19:00

Thank you again, although I don't understand why not just have a Initiate Array block?
But thanks to how you made GP it's as easy as just adding a few lines to the library and it's there so thank you for that too :D

Post Reply