how to use intload()


    Mar 22 2013 | 11:54 pm
    Hey,
    I'd like to know how I can use intload to create a toplevel-patcher with arguments.
    The problem is that I don't really understand the method signature.
    void *intload(C74_CONST char *name, short volume, t_symbol *s, short ac, t_atom *av, short couldedit);
    I tried:
    short couldedit = 0;
        t_atom *av[9];
        atom_setlong(av[0], 0);
        atom_setlong(av[1], 0);
        atom_setlong(av[2], 0);
        atom_setlong(av[3], 0);
        atom_setlong(av[4], 0);
        atom_setlong(av[5], 0);
        atom_setlong(av[6], 0);
        atom_setlong(av[7], 0);
        atom_setlong(av[8], 0);
    
        t_object* opened_patch = intload("my_patcher", 1, gensym(""), 9, av, couldedit);
    I don't understand what the volume is (or how to get it) and what symbol is expected.
    ?

    • Mar 23 2013 | 1:14 pm
      Hi,
      thanks Nicolas, that code example was quite helpful!
      Now I'm able to create the patcher with arguments
      but somehow if I use intload, fileload or jpatcher_load
      there's no patcherview created(and no max window opened) for the patcher I specified with the string.
      But subpatches contained in the opened top-level-patcher appear
      (when the top-level patcher was saved with open subpatchers) with a window and are having correct arguments.
      Here's the code:
      /*–––––––––––works correctly––––––––––––––––*/
          char filename[MAX_FILENAME_CHARS];
          strncpy_zero(filename,"new.maxpat", MAX_FILENAME_CHARS);
      
          t_uint32  type_searched_for = 'JSON';
          t_uint32  type_found;
      
          short path_id = 0;
          int res = locatefile_extended(filename,&path_id, &type_found ,&type_searched_for, 1);
      
          if(res == 0 && path_id != 0)    {post("filename found");}
          else if(res != 0)               {post("filename not found"); return;}
      /*––––––––––––––––––––––––––––––––––––––––––*/
      
          short couldedit = 0;
          t_atom av[9];
          atom_setlong(&av[0], 99); //#1
          atom_setsym(&av[1], gensym("aaa")); //#2
          atom_setlong(&av[2], 0); //#3
          atom_setlong(&av[3], 0);
          atom_setlong(&av[4], 0);
          atom_setlong(&av[5], 0);
          atom_setlong(&av[6], 0);
          atom_setlong(&av[7], 0);
          atom_setlong(&av[8], 0);
      
          t_object* opened_patch = NULL;
          opened_patch = intload("new.maxpat", path_id, NULL, 9, av, couldedit);
      //    opened_patch = jpatcher_load("new.maxpat", path_id, 9, av);
      
          if(opened_patch != NULL)
              {post("opened_patch found adress is %i", opened_patch);}
          else if(opened_patch == NULL)
              {post("opened_patch not found : %i", opened_patch);return;}
      
          t_object* open_p_topview = NULL;
          open_p_topview = jpatcher_get_firstview(opened_patch);
      
          if(open_p_topview != NULL)
              {post("open_p_topview found adress is %i", open_p_topview);}
          else if(open_p_topview == NULL)
              {post("open_p_topview not found : %i", open_p_topview);}
      While everything else is found, the last branch states "open_p_topview not found".
      jpatcher_get_firstview(opened_patch) returns NULL. (If intload, fileload or jpatcher_load was used)
      From what is documented in the headers at least fileload should open a window what it doesn't.
      ...maybe someone from cycling can give me a hand on this...?
    • Mar 23 2013 | 2:47 pm
      ...hopefully not
      Best case would be if someone could explain it with: jpatcher_load_fromdictionary
      I'd like to do s.th like this:
      //...code like above
      
      t_dictionary *rd;
      rd = dictionary_sprintf("@hidden 1"); // to hide the patcher when opened
      opened_patch = jpatcher_load_fromdictionary("empty_track.maxpat", path_id, rd, 9, av);
    • Mar 23 2013 | 3:01 pm
      Hi,
      Without having the slightest experience with patcher window management, I am convinced that anything that has jpatcher in its name is definitely not Max 4-related. As far as I remember, JUCE was introduced in Max 5.
      Hope that helps,
      Ádám
    • Mar 23 2013 | 3:28 pm
      Hi,
      good to know, this gives some hope, thanks!
    • Mar 26 2013 | 7:59 pm