/* int LookUpDecimalArray(pSrc,match,wCrit,size) * * ARGUMENT * DEC *pSrc[]; * int size; * DEC *match; * int wCrit; * * DESCRIPTION * The DEC pointed to by match is compared against the array of DEC * values using wCrit as the evaluation criteria. If the criteria is * met, the index of the term matching the criteria is returned. * Otherwise, the error code is returned with and GM_NOTFOUND is stored in * the error indicator. Note that match cannot be GM_NULL on entry. * * SIDE EFFECTS * None. * * RETURNS * Returns error code on error, otherwise index of DEC meeting criteria. * * POSSIBLE ERROR CODES: * * GM_NULLPOINTER * GM_NOTFOUND * GM_ARGVAL * * AUTHOR * Jared Levy * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. * * MODIFICATIONS * * */ #include #include "gm.h" #include "gmsystem.h" int LookUpDecimalArray(pSrc,match,wCrit,size) DEC *pSrc[]; int size; DEC *match; int wCrit; { int i,wRetVal; _MacStart(GM_LOOKARR); /* make sure a comparison can be made */ _MacInVarI(match); if(!pSrc) { _MacErr(GM_NULLPOINTER); _MacRet(GM_NULLPOINTER); } if (size<0) { _MacErr(GM_ARGVAL); _MacRet(GM_ARGVAL); } if (!(wCrit==GM_DEQ||wCrit==GM_DGT||wCrit==GM_DGEQ ||wCrit==GM_DLEQ||wCrit==GM_DLT||wCrit==GM_DNE)) { _MacErr(GM_ARGVAL); _MacRet(GM_ARGVAL); } for (i=0;i=0) {_MacRet(i);} else break; } case GM_DLEQ: { if(wRetVal<=0) {_MacRet(i);} else break; } case GM_DLT: { if(wRetVal<0) {_MacRet(i);} else break; } case GM_DGT: { if(wRetVal>0) {_MacRet(i);} else break; } case GM_DNE: { if(wRetVal!=0) {_MacRet(i);} else break; } } i++; } /* no match by now means none meet criteria */ _MacErr(GM_NOTFOUND); _MacRet(GM_NOTFOUND); }