// Short example to demonstrate principles discussed
// Note: *'_ signals a Nassi-Schneidermann statement
sSample_data *psSampleData; // pntr to sample data struct
int iErrCode; // return code from sampling routine
//*'_C getch - read the reply from the keyboard
char cReply = getch();
//*'_I Does the operator want another sample
if (toupper(cReply) == 'Y') {
//*'_Y Continue, read another sample, etc
psSampleData = psSampleData; // init pntr to buffer
//*'_C GetNextSample - read another sample
iErrCode = GetNextSample(psSampleData);
END_if
else {
//*'_N Terminate the process
iErrCode = 0;
END-else
//*'_Endif Does the operator want another sample
//*'_CS What was the return code (from GetNextSample)
switch (iErrCode) {
//*'_0 Return code = 0, finished with samples
case SMPL_DONE :
break;
//*'_1 Everything OK, store sample
case SMPL_OK :
break;
//*'_9 Default! Abort sample process
default :
break;
END_switch
//*'_Endcase What was the return code (from GetNextSample)