campo-sirio/gfm/lookarr.c
alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

123 lines
2.1 KiB
C
Executable File

/* 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 <stdio.h>
#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<size;i++) {
_MacInVarI(pSrc[i]);
}
/* initialize the offset into the array of pointers */
i=0;
while(i<size) {
wRetVal=CompareDecimal(pSrc[i], match);
switch(wCrit) {
case GM_DEQ: {
if(wRetVal==0)
{_MacRet(i);}
else
break;
}
case GM_DGEQ: {
if(wRetVal>=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);
}