04-03-2009 07:59 AM
hello,
I produce array from the Type STRUCT_VALUES the worth one are given about panel array only the first worth one takes over, the rest is filled with wrong worth.
if somebody can say to me perhaps what is wrong
typedef struct{
int i16Phase;
double i32Time;
int i16Count;
double i32Voltage;
} STRUCT_VALUES;
STRUCT_VALUES WriteArrayFile( STRUCT_VALUES ARRAY[ 10000 ] )
{
STRUCT_VALUES tmpValue;
GetCtrlIndex(handle, PANEL_phase, &tmpValue.i16Phase );
GetCtrlVal( handle, PANEL_time, &tmpValue.i32Time );
GetCtrlVal( handle, PANEL_counte, &tmpValue.i16Count );
GetCtrlVal( handle, PANEL_voltage, &tmpValue.i32Voltage );
return( tmpValue);
}
Solved! Go to Solution.
04-03-2009 10:33 AM
(ho, my eyes, the goggles, they do nothing...)
well, there is basically a lot of wrong stuff inside this code snippet. if i understand your question correctly, you want to fill an array of structures with values.
1) your function receives the array in a parameter. the parameter is named ARRAY. inside the function, i do not see any reference to ARRAY. how do you think the array will be populated with values if you don't use it at all ?
2) your array (named ARRAY) is 10000 elements wide. but, besides not using ARRAY, nowhere you are using an index into a variable. there is no loop, no square brackets (which reads like [ ]), no indexing... how do you want to populate your array if you don't use an index to set the values somewhere inside this array ?
3) your function returns a structure. it returns only one structure, not an array of structures. so, for sure, only the first values are correct, anything behind the first is not part of anything returned by the function.
4) i am really sorry, and i would like you to excuse me before reading this. i will be a little bit rude and impolite, so please forgive me...
what do you think of taking a real programming course ? parameter passing, arrays, (and by the way, all the questions you ask since yesterday) are no problem when dealt with a little "programming common sense". i don't know what your level in programming is, nor what you do in life, but you just can't write a program without learning a little bit about programming before. it's like building a bridge: if anybody was building a bridge without first learning about structural engineering, its bridge would certainly collapse.please take a good and thorough programming course, and all your problems will go away.
(as a side note: if everybody could claim being a civil engineer and build bridges, we would see bridges falling everyday, and the population would not be very happy about that. this is the current state of computing: anybody can claim being a programmer, and we see programs falling everyday. unfortunately, no one cares... and this is causing great harm to the computing community)
04-03-2009 10:43 AM
i don't know what your level in programming is, nor what you do in life, but you just can't write a program without learning a little bit about programming before.
the problem is solved by myself.
to your question. my programming level is beginner.
I do not program yet long and what we have programmed up to now was in Java.
but we program for a few days with this program and I must only also familiarize myself there.