Dictionary with key-value entries specified by sprintf-style syntax (scripting)

    May 04 2019 | 8:28 pm
    with the function dictionary_sprintf() I can create a dictionary by specifying a sprintf-style format string with attribute nomenclature (i.e. "@myattrname 100")
    For example, given the following values of type A_SYM, A_LONG and A_FLOAT : t_symbol *sym = gensym("foo"); t_atom_long n = 100; double f = 3.141592;
    I could create a dictionary with the following code: t_dictionary *dict = dictionary_sprintf("@name %s @intval %ld @floatval %f", sym->s_name, n, f); if (dict) { dictionary_dump(dict, 0, 0); object_free(dict); } My question is: using the same sprintf syntax, is it possible to create a key-value entry of type A_OBJ ?
    I really want to do this but it is not working for me:
    t_object *obj = someMaxObject; t_dictionary *dict = dictionary_sprintf("@object %p", obj); if (dict) { dictionary_dump(dict, 0, 0); object_free(dict); }
    Thanks for any assistance.

    • May 07 2019 | 9:54 pm
      Hi Luigi,
      dictionary_sprintf() does not support this. If you want to add objects to your dictionary then you will need to use a different method, such as dictionary_appendobject().