Exec_stat MCAtan2::eval(MCExecPoint &ep) { if (s1->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ATAN2_BADS1, line, pos); return ES_ERROR; } real8 n1 = ep.getnvalue(); if (s2->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ATAN2_BADS2, line, pos); return ES_ERROR; } real8 n2 = ep.getnvalue(); MCS_seterrno(0); ep.setnvalue(atan2(n1, n2)); if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue())) { MCS_seterrno(0); MCeerror->add (EE_ATAN2_DOMAIN, line, pos); return ES_ERROR; } return ES_NORMAL; }
Exec_stat MCRound::eval(MCExecPoint &ep) { real8 factor = 1.0; if (digit != NULL) { if (digit->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ROUND_BADSOURCE, line, pos); return ES_ERROR; } // eliminate precision error by using more than exact power of 10, // 6.0 is empirically derived on Intel. Other rounding algorithms // don't work with negative numbers and/or are very slow. factor = pow(10 + DBL_EPSILON * 6.0, ep.getnvalue()); } if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ROUND_BADSOURCE, line, pos); return ES_ERROR; } real8 value = ep.getnvalue() * factor; if (value < 0.0) value = ceil(value - 0.5); else value = floor(value + 0.5); ep.setnvalue(value / factor); return ES_NORMAL; }
Exec_stat MCTrunc::eval(MCExecPoint &ep) { if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_TRUNC_BADSOURCE, line, pos); return ES_ERROR; } if (ep.getnvalue() < 0.0) ep.setnvalue(ceil(ep.getnvalue())); else ep.setnvalue(floor(ep.getnvalue())); return ES_NORMAL; }
Exec_stat MCLog10::eval(MCExecPoint &ep) { if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_LOG10_BADSOURCE, line, pos); return ES_ERROR; } MCS_seterrno(0); ep.setnvalue(log(ep.getnvalue()) / log(10.0)); if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue())) { MCS_seterrno(0); MCeerror->add (EE_LOG10_DOMAIN, line, pos); return ES_ERROR; } return ES_NORMAL; }
Exec_stat MCExp2::eval(MCExecPoint &ep) { if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_EXP2_BADSOURCE, line, pos); return ES_ERROR; } MCS_seterrno(0); ep.setnvalue(pow(2.0, ep.getnvalue())); if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue())) { MCS_seterrno(0); MCeerror->add (EE_EXP2_DOMAIN, line, pos); return ES_ERROR; } return ES_NORMAL; }
Exec_stat MCCompound::eval(MCExecPoint &ep) { if (rate->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_COMPOUND_BADRATE, line, pos); return ES_ERROR; } real8 rn = ep.getnvalue(); if (periods->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_COMPOUND_BADPERIODS, line, pos); return ES_ERROR; } real8 pn = ep.getnvalue(); ep.setnvalue(pow(1.0 + rn, pn)); return ES_NORMAL; }
Exec_stat MCAnnuity::eval(MCExecPoint &ep) { if (rate->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ANNUITY_BADRATE, line, pos); return ES_ERROR; } real8 rn = ep.getnvalue(); if (periods->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ANNUITY_BADPERIODS, line, pos); return ES_ERROR; } real8 pn = ep.getnvalue(); ep.setnvalue((1.0 - pow(1.0 + rn, -pn)) / rn); return ES_NORMAL; }
Exec_stat MCAbsFunction::eval(MCExecPoint &ep) { if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ABS_BADSOURCE, line, pos); return ES_ERROR; } ep.setnvalue(fabs(ep.getnvalue())); return ES_NORMAL; }
Exec_stat MCStatRound::eval(MCExecPoint &ep) { real8 factor = 1.0; if (digit != NULL) { if (digit->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ROUND_BADSOURCE, line, pos); return ES_ERROR; } factor = pow(10 + DBL_EPSILON * 6.0, ep.getnvalue()); } if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add (EE_ROUND_BADSOURCE, line, pos); return ES_ERROR; } real8 value = ep.getnvalue() * factor; if (value < 0.0) { value -= 0.5; if (fmod(value, 2.0) == -1.0) value += 1.0; else value = ceil(value); } else { value += 0.5; if (fmod(value, 2.0) == 1.0) value -= 1.0; else value = floor(value); } ep.setnvalue(value / factor); return ES_NORMAL; }
// MW-2007-07-03: [[ Bug 5123 ]] - Strict array checking modification // Here the source can be an array or number so we use 'tona'. Exec_stat MCSubtract::exec(MCExecPoint &ep) { #ifdef /* MCSubtract */ LEGACY_EXEC MCVariable *t_dst_var; MCVariableValue *t_dst_ref; t_dst_ref = NULL; if (source->eval(ep) != ES_NORMAL || ep.tona() != ES_NORMAL) { MCeerror->add(EE_SUBTRACT_BADSOURCE, line, pos); return ES_ERROR; } if (overlap) ep . grab(); if (destvar != NULL && destvar -> evalcontainer(ep, t_dst_var, t_dst_ref) != ES_NORMAL) { MCeerror->add(EE_SUBTRACT_BADDEST, line, pos); return ES_ERROR; } if (t_dst_ref != NULL && t_dst_ref -> is_array()) { if (t_dst_ref->factorarray(ep, O_MINUS) != ES_NORMAL) { MCeerror->add(EE_SUBTRACT_BADARRAY, line, pos); return ES_ERROR; } return ES_NORMAL; } if (ep.getformat() == VF_ARRAY) { MCeerror->add(EE_SUBTRACT_MISMATCH, line, pos); return ES_ERROR; } // Variable case real8 n1 = ep.getnvalue(); if (t_dst_ref != NULL) { real8 n2; if (!t_dst_ref -> get_as_real(ep, n2)) { MCeerror -> add(EE_SUBTRACT_BADDEST, line, pos); return ES_ERROR; } t_dst_ref -> assign_real(n2 - n1); if (t_dst_var != NULL) t_dst_var -> synchronize(ep, True); return ES_NORMAL; } // Chunk case if (dest->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add(EE_SUBTRACT_BADDEST, line, pos); return ES_ERROR; } real8 n2 = ep.getnvalue(); ep.setnvalue(n2 - n1); if (dest->set(ep, PT_INTO) != ES_NORMAL) { MCeerror->add(EE_SUBTRACT_CANTSET, line, pos); return ES_ERROR; } return ES_NORMAL; #endif /* MCSubtract */ }
// MW-2007-07-03: [[ Bug 5123 ]] - Strict array checking modification // Here the source can be an array or number so we use 'tona'. Exec_stat MCMultiply::exec(MCExecPoint &ep) { #ifdef /* MCMultiply */ LEGACY_EXEC MCVariable *t_dst_var; MCVariableValue *t_dst_ref; t_dst_ref = NULL; if (source->eval(ep) != ES_NORMAL || ep.tona() != ES_NORMAL) { MCeerror->add(EE_MULTIPLY_BADSOURCE, line, pos); return ES_ERROR; } if (overlap) ep . grab(); if (destvar != NULL && destvar -> evalcontainer(ep, t_dst_var, t_dst_ref) != ES_NORMAL) { MCeerror->add(EE_MULTIPLY_BADDEST, line, pos); return ES_ERROR; } if (t_dst_ref != NULL && t_dst_ref -> is_array()) { if (t_dst_ref->factorarray(ep, O_TIMES) != ES_NORMAL) { MCeerror->add(EE_MULTIPLY_BADARRAY, line, pos); return ES_ERROR; } return ES_NORMAL; } if (ep.getformat() == VF_ARRAY) { MCeerror->add(EE_MULTIPLY_MISMATCH, line, pos); return ES_ERROR; } // Variable case real8 n2 = ep.getnvalue(); if (t_dst_ref != NULL) { real8 n1; if (!t_dst_ref -> get_as_real(ep, n1)) { MCeerror -> add(EE_MULTIPLY_BADDEST, line, pos); return ES_ERROR; } MCS_seterrno(0); n1 *= n2; if (n1 == MCinfinity || MCS_geterrno() != 0) { MCS_seterrno(0); MCeerror->add(EE_MULTIPLY_RANGE, line, pos); return ES_ERROR; } t_dst_ref -> assign_real(n1); if (t_dst_var != NULL) t_dst_var -> synchronize(ep, True); return ES_NORMAL; } // Chunk case if (dest->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add(EE_MULTIPLY_BADDEST, line, pos); return ES_ERROR; } real8 n1 = ep.getnvalue(); MCS_seterrno(0); n1 *= n2; if (n1 == MCinfinity || MCS_geterrno() != 0) { MCS_seterrno(0); MCeerror->add(EE_MULTIPLY_RANGE, line, pos); return ES_ERROR; } ep.setnvalue(n1); if (dest->set(ep, PT_INTO) != ES_NORMAL) { MCeerror->add(EE_MULTIPLY_CANTSET, line, pos); return ES_ERROR; } return ES_NORMAL; #endif /* MCMultiply */ }
Exec_stat MCFunction::evalparams(Functions func, MCParameter *params, MCExecPoint &ep) { uint4 nparams = 0; real8 n, tn, oldn; n = oldn = 0.0; MCSortnode *mditems = NULL; // JS-2013-06-19: [[ StatsFunctions ]] Support for new stats functions based on arithmeticMean if (func == F_AVG_DEV || func == F_POP_STD_DEV || func == F_POP_VARIANCE || func == F_SMP_STD_DEV || func == F_SMP_VARIANCE) { //use recursion to get average first if (evalparams(F_ARI_MEAN, params, ep) != ES_NORMAL) return ES_ERROR; oldn = ep.getnvalue(); } // JS-2013-06-19: [[ StatsFunctions ]] Support for geometricMean if (func == F_GEO_MEAN) { //use recursion to count items first if (evalparams(F_UNDEFINED, params, ep) != ES_NORMAL) return ES_ERROR; oldn = ep.getnvalue(); } if (func == F_MEDIAN) { //use recursion to count items first if (evalparams(F_UNDEFINED, params, ep) != ES_NORMAL) return ES_ERROR; mditems = new MCSortnode[(uint4)ep.getnvalue()]; } if (params != NULL && params->getnext() == NULL) { if (params->eval(ep) != ES_NORMAL) { MCeerror->add(EE_FUNCTION_BADSOURCE, line, pos); return ES_ERROR; } if (ep.getformat() == VF_ARRAY) { if (ep.getarray() -> is_array() && ep.getarray()->get_array()->dofunc(ep, func, nparams, n, oldn, mditems) != ES_NORMAL) { MCeerror->add(EE_FUNCTION_BADSOURCE, line, pos); return ES_ERROR; } } else { MCString s(ep.getsvalue()); uint4 length = s.getlength(); const char *sptr = s.getstring(); MCU_skip_spaces(sptr, length); while (length != 0) { s.setstring(sptr); if (!MCU_strchr(sptr, length, ',')) { s.setlength(length); length = 0; } else { s.setlength(sptr - s.getstring()); MCU_skip_char(sptr, length); MCU_skip_spaces(sptr, length); } if (s.getlength() == 0) tn = 0.0; else if (!MCU_stor8(s, tn)) { MCeerror->add (EE_FUNCTION_NAN, 0, 0, s); return ES_ERROR; } MCU_dofunc(func, nparams, n, tn, oldn, mditems); } } } else { MCParameter *tparam = params; while (tparam != NULL) { if (tparam->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL) { MCeerror->add(EE_FUNCTION_BADSOURCE, line, pos); return ES_ERROR; } MCU_dofunc(func, nparams, n, ep.getnvalue(), oldn, mditems); tparam = tparam->getnext(); } } if (nparams != 0) switch (func) { // JS-2013-06-19: [[ StatsFunctions ]] Support for arithmeticMean (was average) case F_ARI_MEAN: n /= nparams; break; // JS-2013-06-19: [[ StatsFunctions ]] Support for averageDeviation case F_AVG_DEV: n /= nparams; break; // JS-2013-06-19: [[ StatsFunctions ]] Support for harmonicMean case F_HAR_MEAN: n = nparams/n; break; case F_MEDIAN: { uint4 toffset; MCU_sort(mditems, nparams, ST_ASCENDING, ST_NUMERIC); toffset = (nparams + 1)/2 - 1; if ((nparams % 2) != 0) //odd n = mditems[toffset].nvalue; else //even average 2 closest values n = (mditems[toffset].nvalue + mditems[toffset+1].nvalue)/2; break; } // JS-2013-06-19: [[ StatsFunctions ]] Support for populationStandardDeviation case F_POP_STD_DEV: n = sqrt(n/nparams); break; // JS-2013-06-19: [[ StatsFunctions ]] Support for populationVariance case F_POP_VARIANCE: n /= nparams; break; // JS-2013-06-19: [[ StatsFunctions ]] Support for sampleStandardDeviation (was stdDev) case F_SMP_STD_DEV: n = sqrt(n/(nparams - 1)); break; // JS-2013-06-19: [[ StatsFunctions ]] Support for sampleVariance case F_SMP_VARIANCE: n /= nparams - 1; break; case F_UNDEFINED: n = nparams; break; default: break; } ep.setnvalue(n); delete mditems; return ES_NORMAL; }
Exec_stat MCRepeat::exec(MCExecPoint &ep) { real8 endn = 0.0; int4 count = 0; MCExecPoint ep2(ep); MCScriptPoint *sp = NULL; Parse_stat ps; const char *sptr; uint4 l; MCVariableValue *tvar = NULL; MCHashentry *hptr = NULL; uint4 kindex = 0; Boolean donumeric = False; Exec_stat stat; switch (form) { case RF_FOR: if (loopvar != NULL) { while ((stat = endcond->eval(ep2)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep2, getline(), getpos(), EE_REPEAT_BADFORCOND); if (stat != ES_NORMAL) { MCeerror->add(EE_REPEAT_BADFORCOND, line, pos); return ES_ERROR; } if (each == FU_ELEMENT) { tvar = ep2.getarray(); if (tvar != NULL && tvar -> is_array()) { l = 1; kindex = 0; donumeric = tvar -> get_array() -> isnumeric(); hptr = tvar -> get_array() -> getnextelement(kindex, hptr, donumeric, ep); if (hptr == NULL) { kindex = 0; donumeric = False; hptr = tvar -> get_array() -> getnextelement(kindex, hptr, donumeric, ep); } } else l = 0; } else if (each == FU_KEY) { tvar = ep2.getarray(); if (tvar != NULL && tvar -> is_array()) { l = 1; kindex = 0; donumeric = False; hptr = tvar -> get_array() -> getnextkey(kindex, hptr); // [[ Bug 3871 ]] : If hptr is NULL then we are done already (this can happen // with an empty custom property set). if (hptr == NULL) l = 0; } else l = 0; } else { sptr = ep2.getsvalue().getstring(); l = ep2.getsvalue().getlength(); if (each == FU_WORD) MCU_skip_spaces(sptr, l); else if (each == FU_TOKEN) { sp = new MCScriptPoint(ep2); ps = sp->nexttoken(); if (ps == PS_ERROR || ps == PS_EOF) l = 0; } } } else { while (((stat = endcond->eval(ep)) != ES_NORMAL || (stat = ep.ton()) != ES_NORMAL) && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADFORCOND); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADFORCOND, line, pos); return ES_ERROR; } count = MCU_max(ep.getint4(), 0); } break; case RF_WITH: if (step != NULL) { while (((stat = step->eval(ep)) != ES_NORMAL || (stat = ep.ton()) != ES_NORMAL) && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHSTEP); stepval = ep.getnvalue(); if (stat != ES_NORMAL || stepval == 0.0) { MCeerror->add (EE_REPEAT_BADWITHSTEP, line, pos); return ES_ERROR; } } while (((stat = startcond->eval(ep)) != ES_NORMAL || (stat = ep.ton()) != ES_NORMAL) && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHSTART); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWITHSTART, line, pos); return ES_ERROR; } ep.setnvalue(ep.getnvalue() - stepval); while ((stat = loopvar->set (ep)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHVAR); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWITHVAR, line, pos); return ES_ERROR; } while (((stat = endcond->eval(ep)) != ES_NORMAL || (stat = ep.ton()) != ES_NORMAL) && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHEND); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWITHEND, line, pos); return ES_ERROR; } endn = ep.getnvalue(); break; default: break; } MCString s; Boolean done = False; bool t_first; t_first = false; while (True) { switch (form) { case RF_FOREVER: break; case RF_FOR: if (loopvar != NULL) { if (l == 0) { done = True; // OK-2007-12-05 : Bug 5605. If there has been at least one iteration, set the loop variable to // whatever the value was in the last iteration. if (!t_first) { // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } } } else { const char *startptr; // = sptr; switch (each) { case FU_KEY: // MW-2010-12-15: [[ Bug 9218 ]] Make a copy of the key so that it can't be mutated // accidentally. ep . setstaticcstring(hptr -> string); loopvar -> set(ep); hptr = tvar -> get_array() -> getnextkey(kindex, hptr); if (hptr == NULL) l = 0; break; case FU_ELEMENT: hptr -> value . fetch(ep); loopvar -> set(ep); hptr = tvar -> get_array() -> getnextelement(kindex, hptr, donumeric, ep); if (hptr == NULL) l = 0; break; case FU_LINE: startptr = sptr; if (!MCU_strchr(sptr, l, ep.getlinedel())) { sptr += l; l = 0; } s.set(startptr, sptr - startptr); MCU_skip_char(sptr, l); break; case FU_ITEM: startptr = sptr; if (!MCU_strchr(sptr, l, ep.getitemdel())) { sptr += l; l = 0; } s.set(startptr, sptr - startptr); MCU_skip_char(sptr, l); break; case FU_WORD: startptr = sptr; if (*sptr == '\"') { MCU_skip_char(sptr, l); while (l && *sptr != '\"' && *sptr != '\n') MCU_skip_char(sptr, l); MCU_skip_char(sptr, l); } else while (l && !isspace((uint1)*sptr)) MCU_skip_char(sptr, l); s.set(startptr, sptr - startptr); MCU_skip_spaces(sptr, l); break; case FU_TOKEN: s = sp->gettoken(); ps = sp->nexttoken(); if (ps == PS_ERROR || ps == PS_EOF) l = 0; break; case FU_CHARACTER: default: startptr = sptr; s.set(startptr, 1); MCU_skip_char(sptr, l); } // MW-2010-12-15: [[ Bug 9218 ]] Added KEY to the type of repeat that already // copies the value. if (each != FU_ELEMENT && each != FU_KEY) { if (MCtrace) { ep.setsvalue(s); loopvar->set(ep); } else loopvar->sets(s); } } } else done = count-- == 0; break; case RF_UNTIL: while ((stat = endcond->eval(ep)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADUNTILCOND); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADUNTILCOND, line, pos); return ES_ERROR; } done = ep.getsvalue() == MCtruemcstring; break; case RF_WHILE: while ((stat = endcond->eval(ep)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWHILECOND); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWHILECOND, line, pos); return ES_ERROR; } done = ep.getsvalue() != MCtruemcstring; break; case RF_WITH: while (((stat = loopvar->eval(ep)) != ES_NORMAL || (stat = ep.ton()) != ES_NORMAL) && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHVAR); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWITHVAR, line, pos); return ES_ERROR; } if (stepval < 0) { if (ep.getnvalue() <= endn) done = True; } else if (ep.getnvalue() >= endn) done = True; if (!done) { ep.setnvalue(ep.getnvalue() + stepval); while ((stat = loopvar->set (ep)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, getline(), getpos(), EE_REPEAT_BADWITHVAR); if (stat != ES_NORMAL) { MCeerror->add (EE_REPEAT_BADWITHVAR, line, pos); return ES_ERROR; } } break; default: break; } if (done) break; Exec_stat stat; MCStatement *tspr = statements; while (tspr != NULL) { if (MCtrace || MCnbreakpoints) { MCB_trace(ep, tspr->getline(), tspr->getpos()); if (MCexitall) break; } ep.setline(tspr->getline()); stat = tspr->exec(ep); // MW-2011-08-17: [[ Redraw ]] Flush any screen updates. MCRedrawUpdateScreen(); switch(stat) { case ES_NORMAL: if (MCexitall) { // OK-2007-12-05 : Bug 5605 : If exiting loop, set the loop variable to the value it had // in the last iteration. // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (form == RF_FOR && loopvar != NULL && each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } delete sp; return ES_NORMAL; } tspr = tspr->getnext(); break; case ES_NEXT_REPEAT: tspr = NULL; break; case ES_EXIT_REPEAT: // OK-2007-12-05 : Bug 5605 : If exiting loop, set the loop variable to the value it had // in the last iteration. // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (form == RF_FOR && loopvar != NULL && each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } delete sp; return ES_NORMAL; case ES_ERROR: if ((MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) do { MCB_error(ep, tspr->getline(), tspr->getpos(), EE_REPEAT_BADSTATEMENT); } while (MCtrace && (stat = tspr->exec(ep)) != ES_NORMAL); if (stat == ES_ERROR) { // OK-2007-12-05 : Bug 5605 : If exiting loop, set the loop variable to the value it had // in the last iteration. // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (form == RF_FOR && loopvar != NULL && each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } delete sp; if (MCexitall) return ES_NORMAL; else { MCeerror->add(EE_REPEAT_BADSTATEMENT, line, pos); return ES_ERROR; } } else tspr = tspr->getnext(); break; default: // OK-2007-12-05 : Bug 5605 : If exiting loop, set the loop variable to the value it had // in the last iteration. // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (form == RF_FOR && loopvar != NULL && each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } delete sp; return stat; } } if (MCscreen->abortkey()) { // OK-2007-12-05 : Bug 5605 : If exiting loop, set the loop variable to the value it had // in the last iteration. // MW-2011-02-08: [[ Bug ]] Make sure we don't use 's' if the repeat type is 'key' or // 'element'. if (form == RF_FOR && loopvar != NULL && each != FU_ELEMENT && each != FU_KEY) { ep.setsvalue(s); loopvar->set(ep); } delete sp; MCeerror->add(EE_REPEAT_ABORT, line, pos); return ES_ERROR; } if (MCtrace || MCnbreakpoints) { MCB_trace(ep, getline(), getpos()); if (MCexitall) break; } t_first = false; } delete sp; return ES_NORMAL; }