[noob] sysfile_write() empty file

    Jun 20 2013 | 10:52 pm
    I am trying to understand the reading and writing portions of the SDK and am having trouble with the sysfile_write(). I got sysfile_writetextfile() to work but am stuck with this.
    I followed the documentation but the resulting textfile, while 100 bytes large, is empty. Here is the code:
    void buffTest_writefile(t_buffTest *x, char *filename, short path) { char *buf[100]; t_fourcc filetype = 'TEXT'; t_ptr_size count; long err; t_filehandle fh; for (int i = 0; i < 100; i++) { buf[i] = i + 1; } count = 100; err = path_createsysfile(filename, path, filetype, &fh); if (err) return; err = sysfile_write(fh, &count, buf); sysfile_close(fh); }
    Any pointers would be appreciated ;)
    Max 6.1.3 SDK. 6.1.1 OSX 10.8.4

    • Jun 20 2013 | 10:56 pm
      ... and while I am here. Why is there a short numtype = 1; in the example? It is never used as far as I can tell...
    • Jun 20 2013 | 11:17 pm
      the code is questionable. I am unsure what you are trying to do, but I see several concerns.
      char *buf[100] that creates an array of 100 slots where each slot is a pointer to a char I suspect, you intend to declare it instead to be: char buf[100];
      later in the code, you pass buf to sysfile_write. buf means the pointer to the first element of buf. So its a pointer to a pointer. And that's weird. Not what you probably want to give to sysfile_write.
      Also, the 2nd param to sysfile_write should be a pointer to a long. Therefore, I would declare it to be: long count; and then call it like this: err = sysfile_write(fh, &count, buf);
    • Jun 20 2013 | 11:24 pm
      Ah, I could be wrong. The SDK doc is wrong on this topic area so you might have to experiment. Also read this post https://cycling74.com/forums/problem-with-sysfile_writetextfile/
    • Jun 20 2013 | 11:24 pm
      according to the .h file it's not a long but like this t_max_err sysfile_write(t_filehandle f, t_ptr_size *count, const void *bufptr);
      not sure about the buf thing... it's straight out of the SDK help... not sure what to do about that.
    • Jun 20 2013 | 11:25 pm
      already tried that, thanks.
    • Jun 20 2013 | 11:32 pm
      not sure this will help, but here is the resulting .txt file.