| ??? 08/08/01 16:11 Read: times |
#13933 - RE: initialising values of structure |
In addition to what Chris mentioned, you might want to consider the following change:
#define MAX_TESTS 30 struct param{ char mode; float factor; int aspVolume; char temperature; char filter1; char filter2; char unit; float nvMin; float nvMax; char decimal; int reagVolume; int sampleVolume; float linLim; float blankMin; float blankMax; int delayT; int rateT; char noOfReadings; float absMin; char printCurve; char shortName[SHORTNAMELENGTH+1];/* +1 is for NULL Character */ char fullName[FULLNAMELENGTH+1];/* +1 is for NULL Character */ float standard; float blankOD; float standardOD; unsigned char DACgainSet[2]; unsigned char calibrationDone; unsigned char relayStatus[2]; }; struct param[MAX_TESTS] xdata saveTestParam _at_ 0x8000; Note that the [TEST] arrays has been removed from each item in the structure and that the structure is now defined as param[MAX_TESTS]. This means that, for example, param[0].mode is the mode information for test zero rather than param.mode[0]. It is generally "cleaner" to have one structure for each test rather than a single structure made up of arrays that hold that data for each test, although in reality it makes no difference. You can initialize the above as described by Chris, or you can initialize it in code: for(x=0; x < MAX_TESTS; x++) { param[x].mode = 0; param[x].factor =0; .... etc. } Whether it's best to initialize it in code as just mentioned or initialize the structure as described by Chris would depend on the values you are initializing the structure to. If most of the members of each structure are going to assume the same value (all zeros, etc.) then it'd probably be best to do it in code. If each of the tests has a completely different set of values it'd probably be best to do it as described by Chris. Craig Steiner |
| Topic | Author | Date |
| initialising values of structure | 01/01/70 00:00 | |
| RE: initialising values of structure | 01/01/70 00:00 | |
| RE: initialising values of structure | 01/01/70 00:00 | |
| RE: initialising values of structure | 01/01/70 00:00 | |
| RE: initialising values of structure | 01/01/70 00:00 | |
RE: initialising values of structure | 01/01/70 00:00 |



