bool C_coretestBase::TestDouble(int callbackID, const Json::Value& parameters) { Json::Value testDouble_JSON; FetchObject(parameters, "testDouble", testDouble_JSON); double testDouble; FetchDouble(testDouble_JSON, testDouble); TestDouble(callbackID, testDouble); return true; }
short Validate(HWND dp, short *item, double *dx, Boolean useAlert) { short numberErr = noErr; int32 x = 0; // returned long short loop = 1; const double propDoubles[] = { 0, 0, 0 /* iPropBigNudgeH, kNudgeMin, kNudgeMax, iPropBigNudgeV, kNudgeMin, kNudgeMax, iPropRulerOriginH, kOriginMin, kOriginMax, iPropRulerOriginV, kOriginMin, kOriginMax, iPropGridMajor, kGridMin, kGridMax */ }; const short numPropDoubles = (propDoubles[0] > 0) ? ((sizeof(propDoubles) / sizeof(double)) / 3) : 0; const long propNumbers[] = { dESource1, kMin, kMax, dESource2, kMin, kMax, dESource3, kMin, kMax, dESource4, kMin, kMax, }; const short numPropNumbers = (propNumbers[0] > 0) ? ((sizeof(propNumbers) / sizeof(long)) / 3) : 0; const short foundIt = -1; // flag that we found it // first loop through doubles, looking for match while (loop <= numPropDoubles && loop != foundIt) { if (propDoubles[loop*3-3] == *item) { numberErr = FetchDouble (dp, *item, propDoubles[loop*3-2], // max propDoubles[loop*3-1], // min dx); // returned double if (numberErr != noErr && useAlert) { // out of bounds problem. Report and change focus back. AlertDouble (dp, *item, propDoubles[loop*3-2], // max propDoubles[loop*3-1], // min dx, // value AlertID, // global alert dialog numberErr); // error we found *item = 0; } loop = foundIt; // found it! } else loop++; // next } if (loop != foundIt) loop = 1; // reset // now loop through longs, looking for match while (loop <= numPropNumbers && loop != foundIt) { if (propNumbers[loop*3-3] == *item) { numberErr = FetchNumber (dp, *item, propNumbers[loop*3-2], // max propNumbers[loop*3-1], // min &x); // returned long if (numberErr != noErr && useAlert) { // out of bounds problem. Report and change focus back. AlertNumber (dp, *item, propNumbers[loop*3-2], // max propNumbers[loop*3-1], // min &x, // value AlertID, // global alert dialog numberErr); // error we found *item = 0; } *dx = (double)x; // coerce long as returned double loop = foundIt; // found it! } else loop++; // next } return numberErr; }