Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Syntax error ... #280030
07/20/09 15:34
07/20/09 15:34
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
i have resently been doing the Aum 83 struct workshop and i have hit a major problem:

str_cpy(name_str, Gun[counter].name);

This line produces a syntax error. I can not see anything wrong with it, they are both strings, and on of them is in a struct. ...have i done something completely wrong?


One day there will be an unfixable bug,
That day is not today.
Re: Syntax error ... [Re: dakilla] #280054
07/20/09 20:24
07/20/09 20:24
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline
User
Schmerzmittel  Offline
User

Joined: Aug 2005
Posts: 512
Bayern
Can you post the Script? And what error? Screenshot or something would help.

Last edited by Schmerzmittel; 07/20/09 20:25.

A7 Com V7.80
Re: Syntax error ... [Re: Schmerzmittel] #280118
07/21/09 00:37
07/21/09 00:37
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
look for counter, what does or is counter?
Variable? String? Define...(most likely not that)?


Since gun[counter].name
The red, I have never seen that...

name is a defined variable, gun is an entity.

maybe remove counter and see how that works without it.

Last edited by DevoN; 07/21/09 00:37.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Syntax error ... [Re: DLively] #280133
07/21/09 02:28
07/21/09 02:28
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
it's called an indexer for an array


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: Syntax error ... [Re: Michael_Schwarz] #280138
07/21/09 03:36
07/21/09 03:36
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
how can you store an array through an entity?

gun1
gun2
gun3

like that?

Then why isnt that workin?


Edit:

Its not an entity* its an Array to begin with =P



So what we need, is not the line of code, but what then engine is telling you in the error report; what is wrong with that code..?

Last edited by DevoN; 07/21/09 03:40.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Syntax error ... [Re: DLively] #280147
07/21/09 05:00
07/21/09 05:00
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
here gun is a struct of entity (thats wat we assume).

@dakilla: post more code and the error u getting.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Syntax error ... [Re: delinkx] #280156
07/21/09 07:09
07/21/09 07:09
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Once you try to access an element of an array, you need to separate
its properties from the container, like so

str_cpy(name_str, (Gun[counter]).name);


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Syntax error ... [Re: EvilSOB] #280236
07/21/09 16:00
07/21/09 16:00
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
kk, it isnt a very long script, so ill post up the whole thing:


STRING* name_str = "#30";
STRING* sort_str = "#25";
STRING* inventwho_str = "#20";
var db_inventdate;


typedef struct
{
STRING* name;
STRING* sort;
STRING* inventwho;
var inventdate;
}Gun;


PANEL* gun_pan =
{
digits (280, 120, "Gun name: %s ", *, 1, name_str);
digits (280, 135, "Type: %s ", *, 1, sort_str);
digits (280, 150, "Invented by: %s", *, 1, inventwho_str);
digits (280, 165, "Invented in: %.0f", *, 1, db_inventdate);
flags = SHOW;
}

Gun database[1000];

STRING* temp_str = "#25";

var i = 0;

function main()
{
var file_handle;
file_handle = file_open_read("guns.txt");
while (i < 1000)
{
if (file_str_read(file_handle, database[i].name) == -1)
{
break;
}
else
{
file_str_read(file_handle, temp_str);
database[i].name = str_create("");
file_str_read(file_handle, database[i].name);
file_str_read(file_handle, temp_str);
database[i].inventdate = str_to_num(temp_str);
file_str_read(file_handle, temp_str);
database[i].sort = str_create("");
file_str_read(file_handle, temp_str);
file_str_read(file_handle, database[i].sort);
database[i].inventwho = str_create("");
file_str_read(file_handle, temp_str);
file_str_read(file_handle, database[i].inventwho);
i++;
}

}
file_close(file_handle);
}

function info_startup()
{
wait (-1);
var counter;
while (1)
{
if (key_cud)
{
while (key_cud) {wait (1);}
counter++;
}
if (key_cuu)
{
while (key_cuu) {wait (1);}
counter--;
}

counter = clamp(counter, 0, i-1);
str_cpy(name_str, Gun[counter].name);
// I havent done the others yet, as it's pointless until i fix the name.
wait (1);
}
}


One day there will be an unfixable bug,
That day is not today.
Re: Syntax error ... [Re: dakilla] #280237
07/21/09 16:39
07/21/09 16:39
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Code:
typedef struct
{
STRING* name;
STRING* sort;
STRING* inventwho;
var inventdate;
}_gun;

_gun Gun[20];                  // Create 20 Guns (Struct)

....

for (i=0; i<20; i++)
{
    Gun[i].name = str_create("")   // after that you can use str_cpy....
}



Last edited by Widi; 07/21/09 16:40.

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