Abort Object creation in external.

    Mar 10 2014 | 9:33 am
    I'm used to program pd externals with flext. Now I have to use the MAX C-API to program Max externals.
    In flext, there was the function InitProblem();, which I used to abort object creation in the constructor for instance if the user set the wrong creation arguments. Pd printed a message like "Object, couldn't create." automatically.
    Is there something similar in Max?

    • Mar 11 2014 | 1:32 pm
      Here is my solution: I abort object creation by returning a NULL pointer and printing an error message to Max console.
      void *fooModule_new(t_symbol *s, long argc, t_atom *argv)
          t_fooModule *x = (t_fooModule *) object_alloc(fooModule_class);
          t_pfftpub *pfft = (t_pfftpub*) gensym("__pfft~__")->s_thing;
          if (pfft->x_fullspect == 0)
              object_error((t_object *) x, "Full spectrum flag in pfft~ must be 1!");
              return NULL;
          /* some other code here .... */
          return x;
    • Mar 11 2014 | 2:30 pm
      Yes, that's the way to go - but don't forget to free your object before leaving the constructor! aa