Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,227 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: typedef struct [Re: Uhrwerk] #238156
11/25/08 08:47
11/25/08 08:47
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ive never been able to figure it out, but you 'should' use the following code styling then dealing with arrayed structs.
Some functions work OK without the seemingly exessive brackets, but other need them. So use em all the time and all will be well.

str_cpy(our_players[i].playername,current_player); <<what you wanted
str_cpy((our_players[i]).playername,current_player); << what you need
Same again in case its not clear as formatted.
Code:
str_cpy(  our_players[i].playername ,current_player);   <<what you wanted
str_cpy( (our_players[i]).playername,current_player);   <<what you need
It seems some functions get messed up when trying to access (mostly to change)
individual elements of arrayed structures, Ive had this issue with arrayed strings myself.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: typedef struct [Re: EvilSOB] #238160
11/25/08 08:52
11/25/08 08:52
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
ok.. thats an ambiguity problem by the compiler smile the extra brakets make sure its under scope.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: typedef struct [Re: delinkx] #238163
11/25/08 08:59
11/25/08 08:59
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I guessed something like that, it seems that it only affect some engine functions,
and even then some affected functions get tangled if you dont use the brackets
when its parameter 1, but are fine when its parameter 2.

So I now use the brackets ALL the time when arraying structs to avoid issues.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: typedef struct [Re: EvilSOB] #238214
11/25/08 17:50
11/25/08 17:50
Joined: Sep 2005
Posts: 75
CA, Orange County
Gerrit Offline OP
Junior Member
Gerrit  Offline OP
Junior Member

Joined: Sep 2005
Posts: 75
CA, Orange County
Sorry but that still doesn't work.
When I execute
str_cpy((our_players[i]).playername,current_player); i get the following error:
"invalid argument in Event: STRING"

I did define playername as a string in the structure but also tried defining as a char[30] but same result...
I am really pulling my hair out about this.
Gerrit

Re: typedef struct [Re: Gerrit] #238219
11/25/08 19:37
11/25/08 19:37
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
str_cpy((our_players[i]).playername,current_player); IS correct, but it can only be use after
the our_players[i].playername has been "str_create"ed at least once.
EG.
Code:
var i = 0;
typedef struct
{
   int score;
   STRING* score_str;
   STRING* playername;
} our_player;

our_player our_players[10]; 

STRING* current_player = "Me";

function main()
{
   //initialising,  run once only, before any other struct usage
   for(i=0; i<10; i++)   
   {
      our_players[i].score = 0;
      our_players[i].score_str  = str_create("000");
      our_players[i].playername = str_create("Empty");  //or str_create(""); is OK too
   }
   ...
   ...
   //using,  this eg is setting up player at element 0 to be current_player
   our_players[i].score = 0;
   str_cpy((our_players[i]).score_str,"000");
   str_cpy((our_players[i]).playername, current_player);
   ...
   ...
   ...
   while(1)   wait(1);
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: typedef struct [Re: EvilSOB] #238220
11/25/08 19:51
11/25/08 19:51
Joined: Sep 2005
Posts: 75
CA, Orange County
Gerrit Offline OP
Junior Member
Gerrit  Offline OP
Junior Member

Joined: Sep 2005
Posts: 75
CA, Orange County
EvilSOB,
Thank you very much that did indeed work. I know that you noted the str_create before but in my hurry to test I overlooked that.
Again thank you very much I did learn some new stuff today.

Best regards
Gerrit

Re: typedef struct [Re: Gerrit] #238287
11/26/08 07:01
11/26/08 07:01
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
good stuff. glad to be of help


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

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