Jump to content


Photo

Global Array?


  • Please log in to reply
5 replies to this topic

#1 Sydious

Sydious

    GMC Member

  • GMC Member
  • 264 posts

Posted 20 December 2009 - 10:41 PM

is this able to be done?


global.name[0] = blah,blah??

a global array?
  • 0

#2 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5593 posts
  • Version:GM:Studio

Posted 20 December 2009 - 10:41 PM

yes, it is possible

EDIT: .. you know .. you could just have tried

Edited by FoxInABox, 20 December 2009 - 10:42 PM.

  • 0

#3 Sydious

Sydious

    GMC Member

  • GMC Member
  • 264 posts

Posted 20 December 2009 - 10:42 PM

yes, it is possible


thx. didn't want to takle my idea before I knew if this was correct.
  • 0

#4 Sydious

Sydious

    GMC Member

  • GMC Member
  • 264 posts

Posted 21 December 2009 - 02:36 PM

I was successful with global.name[0]

I can't seem to get globalvar name[0] to work. Is that not possible or am I setting it up wrong?
  • 0

#5 jabelar

jabelar

    GMC Member

  • New Member
  • 2980 posts

Posted 21 December 2009 - 07:13 PM

I was successful with global.name[0]

I can't seem to get globalvar name[0] to work. Is that not possible or am I setting it up wrong?


With the globalvar you should just put the name of the array, not the [0] part. So I think the following should work, even if name is supposed to be an array:
globalvar name;
The reason it works is that Game Maker is very tolerant of variable declarations and so a variable without an index can be used with an index later. In fact you can use name as equivalent to name[0] after you have been using it as an array.

Anyway, you don't have to do anything to say that it is an array when using the globalvar or var statement.

Edited by jabelar, 21 December 2009 - 07:13 PM.

  • 0

#6 Sydious

Sydious

    GMC Member

  • GMC Member
  • 264 posts

Posted 21 December 2009 - 07:45 PM

I was successful with global.name[0]

I can't seem to get globalvar name[0] to work. Is that not possible or am I setting it up wrong?


With the globalvar you should just put the name of the array, not the [0] part. So I think the following should work, even if name is supposed to be an array:
globalvar name;
The reason it works is that Game Maker is very tolerant of variable declarations and so a variable without an index can be used with an index later. In fact you can use name as equivalent to name[0] after you have been using it as an array.

Anyway, you don't have to do anything to say that it is an array when using the globalvar or var statement.


Great. Thanks for your help.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users