Cycling74 / max-sdk

Software Development Kit for Max by Cycling '74
Other
262 stars 57 forks source link

Incorrect documentation for writing text files #61

Open TimMoore opened 1 year ago

TimMoore commented 1 year ago

In the documentation page titled "File Handling", it shows the following example code:

void myobject_writefile(t_myobject *x, char *filename, short path)
{
    char *buf = "write me into a file";
    long err;
    t_filehandle fh;

    err = path_createsysfile(filename, path, 'TEXT', &fh);
    if (err)
        return;
    err = sysfile_writetextfile(fh, &buf, TEXT_LB_NATIVE);
    sysfile_close(fh);
}

This results in an empty file. The sysfile_writetextfile function requires an allocated handle. This has been discussed a few times in the forums: