Csound Csound-dev Csound-tekno Search About

[Csnd-dev] nstrnum returns NOTOK

Date2022-09-20 16:47
FromEduardo Moguillansky
Subject[Csnd-dev] nstrnum returns NOTOK

Hi,

when nstrnum is called with a non-existent instrument name it returns NOTOK which exits the event. It would be much more useful if it just returned -1 without failing. Would anyone be against this? This is the code in Engine/insert.c

int nstrnumset_S(CSOUND *csound, NSTRNUM *p)
{
  /* IV - Oct 31 2002 */
    int res = strarg2insno(csound, ((STRINGDAT *)p->iname)->data, 1);
    if (UNLIKELY(res == NOT_AN_INSTRUMENT)) {
      *p->i_insno = -FL(1.0); return NOTOK;  // <----------- I propose to just  return OK;
    }
    else {
      *p->i_insno = (MYFLT)res; return OK;
    }
}