Cycling74/max-sdk

Incorrect documentation for writing text files

TimMoore opened this issue · 0 comments

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: