Nesting structs/arrays (Solved)

Started by strazer, Sat 15/05/2004 22:24:40

Previous topic - Next topic

strazer

Here's an example:

Global script

struct Type1 {
   int list;
   int position;
};
Type1 letter[2];

struct Type2 {
   int entries[20];
};
Type2 lists[10];

on_key_press

// init values for this example
letter[1].list = 1;
letter[1].position = 5;
lists[1].entries[5] = 666;

int result = lists[letter[1].list].entries[letter[1].position];
Display("%d", result); // returns 0

int templist = letter[1].list;
int tempposition = letter[1].position;
result = lists[templist].entries[tempposition];
Display("%d", result); // returns 666

It's not a problem since there's an easy workaround, but I'm curious as to why it behaves this way?

EDIT: Fixed since v2.62 Beta 1

stuh505

heh, that is wierd.  funny thing is, this works:

int result = lists[letter[1].list].entries[5];
Display("%d", result); // returns 666

Scorpiorus

Hehe, yet another reason why arrays and structs are unofficial.

Pumaman

Interesting, I'll look into it.

SMF spam blocked by CleanTalk