rendered paste body// -------------------------------------------------------------------------------------------------------------------------------------
// Function: AllenVM_CPU_BASE_CMP_GT();
// Purpose: Greater than.
// Returns: 0/1 wether false/true.
// -------------------------------------------------------------------------------------------------------------------------------------
static int AllenVM_CPU_BASE_CMP_GT(struct AllenInterp *i, int argc, char **argv, void *pd) {
char buf[TBASE_CMP_BSIZE]; register int p,op,x,y; register float c=1; // Buffer and parameters.
for(p=1,op=1; p<argc; ++p) { if (!strcmp(argv[p],TBASE_CMP_SEP)) break; } // Get parameters.
if(p!=argc) { // Lists comparison.
for(x=1; x<p; ++x) for(y=p+1; y<argc; ++y) // - Loop through parameters.
if(atof(argv[x]) <= atof(argv[y])) { c=0; break; }} // - Make comparison.
else { // Forward comparison.
for(x=2; x<p; ++x) { // - Loop through parameters.
if(atof(argv[x])==0) { // Check if we want to change.
if(!strcmp(TBASE_CMP_GT, argv[x])) { op = 1; continue; } // Change operator: Greater than.
if(!strcmp(TBASE_CMP_LT, argv[x])) { op = 2; continue; } // Change operator: Less than.
if(!strcmp(TBASE_CMP_EQ, argv[x])) { op = 3; continue; } // Change operator: Equal to.
if(!strcmp(TBASE_CMP_NQ, argv[x])) { op = 4; continue; } // Change operator: Not equal.
if(!strcmp(TBASE_CMP_GEQ, argv[x])) { op = 5; continue; } // Change operator: Greater or equal.
if(!strcmp(TBASE_CMP_LEQ, argv[x])) { op = 6; continue; } // Change operator: Less or equal.
}
switch(op) { // Look current operator.
case 1: if(atof(argv[1]) <= atof(argv[x])) { c=0; } break; // Operate: Greater than.
case 2: if(atof(argv[1]) >= atof(argv[x])) { c=0; } break; // Operate: Less than.
case 3: if(atof(argv[1]) != atof(argv[x])) { c=0; } break; // Operate: Equal to.
case 4: if(atof(argv[1]) == atof(argv[x])) { c=0; } break; // Operate: Not equal.
case 5: if(atof(argv[1]) < atof(argv[x])) { c=0; } break; // Operate: Greater or equal.
case 6: if(atof(argv[1]) > atof(argv[x])) { c=0; } break; // Operate: Less or equal.
}}}
snprintf(buf,TBASE_CMP_BSIZE,"%f", c); // Copy result to buffer as float.
AllenVM_InterpSetResult(i,buf); // Set interpreter result.
return Allen_VM_OK; // Everything ok.
}