Staredit Network > Forums > SC2 Assistance > Topic: [SOLVED] Simple Array question
[SOLVED] Simple Array question
This topic is locked. You can no longer write replies here.
Jan 2 2011, 8:07 pm
By: payne  

Jan 2 2011, 8:07 pm payne Post #1

:payne:

I'm just wondering: if I set a variable to have 1 array, will it have only Var[0], or will it have Var[0] and Var[1] ?

Post has been edited 1 time(s), last time on Jan 3 2011, 5:59 pm by payne.



None.

Jan 2 2011, 8:31 pm Roy Post #2

An artist's depiction of an Extended Unit Death

I believe setting the array size in Galaxy includes the index of the array length, which is kind of dumb because it doesn't work like that for any language of which I am aware.

So it would have Var[0] and Var[1].

If you try to set an index out of bounds directly, Galaxy will change it to the last index in the array. For example, if you tried putting Var[2], the editor will recognize it as out of bounds and set it to Var[1] when you hit "Ok."

Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.




Jan 2 2011, 9:15 pm payne Post #3

:payne:

Quote from Roy
Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.
Based on what you're saying, array size of 1 gives a variable 2 arrays, and it would thus not be just a normal variable. ;o



None.

Jan 2 2011, 10:20 pm Ahli Post #4

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.


edit:
this is wrong. next post is the correct answer.

Post has been edited 1 time(s), last time on Jan 2 2011, 11:05 pm by Ahli.




Jan 2 2011, 10:23 pm Roy Post #5

An artist's depiction of an Extended Unit Death

Quote from Ahli
When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.
In most languages, this is the case. This is wrong for Galaxy. myArrayVariable[10] ranges from 0 to 10, and the actual array length would be 11.

Quote from payne
Quote from Roy
Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.
Based on what you're saying, array size of 1 gives a variable 2 arrays, and it would thus not be just a normal variable. ;o
Yeah, I'm saying that if you wanted an array of size 1, you should just make a non-array variable. The smallest array you can have in Galaxy will be of size 2 (index 0 and index 1).




Jan 2 2011, 11:04 pm Ahli Post #6

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Quote from Roy
Quote from Ahli
When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.
In most languages, this is the case. This is wrong for Galaxy. myArrayVariable[10] ranges from 0 to 10, and the actual array length would be 11.
My mind just blew up?!
ok, so now I'm stopping to waste space ;D




Jan 3 2011, 3:47 am payne Post #7

:payne:

So if I have 2 arrays for a variable, it'll create Var[0], [1], and [2], thus letting me use [Triggering Player] ?
So this is wrong?



None.

Jan 3 2011, 4:11 pm Roy Post #8

An artist's depiction of an Extended Unit Death

Quote from payne
So if I have 2 arrays for a variable, it'll create Var[0], [1], and [2], thus letting me use [Triggering Player] ?
Two arrays? A multi-dimensional array, you mean? Or an array of size 2? If it's an array of size 2, then yes, it will have Var[0], Var[1] and Var[2]. You can use (Triggering Player) or any other integer function. Of course, you'll have to watch for out-of-bounds exceptions when doing this.

Quote from payne
So this is wrong?
Yes, it is inaccurate. It's making the assumption that Galaxy's arrays work like arrays from other programming languages.




Jan 3 2011, 5:58 pm payne Post #9

:payne:

Ok, thanks.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:27 am]
m.0.n.3.y -- Maybe because it's an EUD map?
[03:27 am]
m.0.n.3.y -- Can't upload maps to the DB. Error says "The action you have performed caused an Error". Any word?
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
Please log in to shout.


Members Online: CarpetCleaningWokin, Roy