Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 793 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
. vs -> #148947
08/19/07 07:10
08/19/07 07:10
Joined: Oct 2003
Posts: 312
Lüneburg, Germany
Gnometech Offline OP
Senior Member
Gnometech  Offline OP
Senior Member

Joined: Oct 2003
Posts: 312
Lüneburg, Germany
Hi all!

Ok, this had me confused for a while. I have figured it out but I don't know why it works this way, since the manual states otherwise.

Here is the thing: I have defined the following struct.

Code:

typedef struct
{
PANEL* p;
var row;
var col;
} Card;



When I know try to access the panel pointer, I have to do it in a special way. In the next example "card" is an array of card pointers:

Code:

(card[i])->p = pan_create("bmap = card_base", 1); // works fine
((card[i])->p).pos_x = 25; // does NOT work, instead it overwrites (card[i])->p
((card[i])->p)->pos_x = 25; // works as intended



So it seems in this case I have to use the -> and not the . to access the structure. However, the manual states:

Quote:


In standard C / C++, members of structs are accessed by a dot '.' and members of struct pointers are accessed by an arrow '->'. In lite-C or C-Script the compiler automatically detects whether it's a struct or a struct pointer, and the dot '.' can be used for both.





So, is this a bug? Or was I doing something wrong? Anyway, I am glad this works now, it had me confused for a while. By the way, if I declare a global panel pointer "test" and use this one with test.pos_x etc. everything works.

Gnometech


Download our playable Movement & Interaction Tutorial for 3DGS here:
http://www.puppenheim.org/MITutorial.zip
Re: . vs -> [Re: Gnometech] #148948
08/19/07 13:35
08/19/07 13:35
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
well, yes, it's a pointer to a panel, isn't it? so you obviously have to use -> instead of .

joey.

Re: . vs -> [Re: Joey] #148949
08/19/07 15:06
08/19/07 15:06
Joined: Oct 2003
Posts: 312
Lüneburg, Germany
Gnometech Offline OP
Senior Member
Gnometech  Offline OP
Senior Member

Joined: Oct 2003
Posts: 312
Lüneburg, Germany
Sure, it makes sense, but I thought in Lite-C the . and the -> could both be used. Obviously not in all cases, that was just the point I was trying to make.

As I said I am not sure if this is intended behaviour - the quote from the manual states that both . and -> can be used and this is not true in every case, as the example shows.

Gnometech


Download our playable Movement & Interaction Tutorial for 3DGS here:
http://www.puppenheim.org/MITutorial.zip
Re: . vs -> [Re: Gnometech] #148950
08/19/07 15:50
08/19/07 15:50
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
My guess is that the compiler simply can't always do it right. It has a reason that there exists . as well as -> and depending on what you want, the compiler might decide to do it differently than what you expect.

Maybe it doesn't work in structs - for my. / my-> it works as intended.

Re: . vs -> [Re: FBL] #148951
08/20/07 07:28
08/20/07 07:28
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The replacement of -> by . works for simple objects, but not for objects that are part of a struct. I've changed the manual description accordingly.

Re: . vs -> [Re: jcl] #148952
08/20/07 07:52
08/20/07 07:52
Joined: Oct 2003
Posts: 312
Lüneburg, Germany
Gnometech Offline OP
Senior Member
Gnometech  Offline OP
Senior Member

Joined: Oct 2003
Posts: 312
Lüneburg, Germany
I see, thank you for the clarification. Should've posted it in "Blame the manual" then, I guess.

Thanks and regards,
Gnometech


Download our playable Movement & Interaction Tutorial for 3DGS here:
http://www.puppenheim.org/MITutorial.zip

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1