|
|
Syntax error ...
#280030
07/20/09 15:34
07/20/09 15:34
|
Joined: Apr 2009
Posts: 141
dakilla
OP
Member
|
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
User
|
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
Serious User
|
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.
|
|
|
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
Senior Expert
|
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
Serious User
|
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.
|
|
|
Re: Syntax error ...
[Re: delinkx]
#280156
07/21/09 07:09
07/21/09 07:09
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
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
OP
Member
|
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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|