Sry, I know I've still to learn a lot about structs/pointer/etc. Somewhen I will go through a good book... till then there are questions like the following, for some of you sounding stupid or at least obviously/simple ... anyway:
--------------
this works, native:
function demonstration(var my_own_var) {
...
my_own_var = 37; // do whatever I want with it, nobody cares
...
}
...
var number_for_everyone = 1;
demonstration(number_for_everyone);
...
number_for_everyone = 7;
demonstration(number_for_everyone);
...
demonstration(number_for_everyone);
...
this not:
function demonstration(ANY_STRUCT my_own_struct) {
...
my_own_struct.x = 37; // do whatever I want with it, nobody cares?
...
}
...
ANY_STRUCT struct_for_everyone;
struct_for_everyone.x = 1;
demonstration(struct_for_everyone);
...
Compiler:
Syntax error: can not push STRUCT@69Why?I only know this way round:
function demonstration(ANY_STRUCT* temp_my_own_struct) {
ANY_STRUCT my_own_struct;
my_own_struct.x=temp_my_own_struct.x;
...
my_own_struct.x = 37; // do whatever I want with it, nobody cares!
...
}
...
ANY_STRUCT struct_for_everyone;
struct_for_everyone.x = 1;
demonstration(struct_for_everyone);
...
Any better solutions?At least a possibility to copy the whole dataset of a struct into a new one. Like
vec_set but for every struct? (okay, I could write an own function or define for it...)
Regards,
Clemens