Example: Using Braces to Clarify Flow
This example shows the use of braces to clarify the flow and prevent mistakes:
if(idJDBReturn != JDEDB_PASSED) { /* If not add mode, record must exist */ if ((lpdsInternal->cActionCode != ADD_MODE) && (lpdsInternal->cActionCode != ATTACH_MODE)) { /* Issue Error 0002 - Work Order number invalid */ jdeStrncpy((JCHAR*)(lpdsInternal->szErrorMessageID), (const JCHAR*)_J(0002), DIM(lpdsInternal->szErrorMessageID)-1); lpdsInternal->idFieldID = IDERRmnOrderNumber_15; idReturnCode = ER_ERROR; } } else { /* If in add mode and the record exists, issue error and exit */ if (lpdsInternal->cActionCode == ADD_MODE) { /* Issue Error 0002 - Work Order number invalid */ jdeStrncpy((JCHAR*)(lpdsInternal->szErrorMessageID), (const JCHAR*)_J(0002), DIM(lpdsInternal->szErrorMessageID)-1); lpdsInternal->idFieldID = IDERRmnOrderNumber_15; idReturnCode = ER_ERROR; } else { /* * Set flag used in determining if the F4801 record should be sent * in to the modules */ lpdsInternal->cF4801Retrieved = _J('1'); } }