new(BaseFile) returns NIL
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/01/2008 at 20:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.5
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hi. I'm a new() COFFEE user but I can't get new() to work!:)I'm trying to access a file from within a COFFEE script and whenever I try to instantiate a BaseFile object using new(BaseFile) I get a NIL instead of an object. I have tried copying and pasting the code from the 9.5 COFFEE SDK into my script and it does not run because the new() function returns a NIL. (See below)
Does someone have a clue to steer me in the right direction?
// Creates the file and writes a string to it
var file = new(BaseFile);
file->Open(filename, GE_WRITE);
file->WriteString("Hello World!"); -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/01/2008 at 23:38, xxxxxxxx wrote:
It works fine here, maybe your filename is wrong? Here a working sample:
> _
> var fn = new(Filename);
> if(!fn) return;
>
> if(!fn- >FileSelect("Create file", TRUE)) return;
>
> var file = new(BaseFile);
> if(!file) return;
>
> if(!file->Open(fn, GE_WRITE, FILE_IGNOREOPEN, GE_INTEL)) return;
>
> if(!file->WriteString("hallo", GE_7BIT)) return;
> _cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/01/2008 at 12:29, xxxxxxxx wrote:
Thanks for your response Matthias. It got me half way there.
I have been developing scripts by creating a Null Object and attaching a COFFEE tag to it. If I paste your code into one of those tags, it fails just like mine did.
If I use the Script Manager and paste your code into it, your code works fine, so the code itself is not the problem but my way of implementing it within C4D. I'll have to read up on it and figure out why the tag method doesn't work.
You got me over the hump though - thanks!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/01/2008 at 12:48, xxxxxxxx wrote:
You can't do file access in COFFEE when the script is in a tag or Xpresso node as expressions (this is to disallow scripts from being used maliciously - see the "Basic Functions and Classes" section of the COFFEE docs). You'll need to do the COFFEE script as a full-blown plugin to have file access.