THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2011 at 06:41, xxxxxxxx wrote:
Cinema 4D Version: 11.5-12
Platform: Windows ;
Language(s) : C++ ;
Hi all !
I didn't found how to add a line jump in a remote text file.
When I use Basefile* WriteString() I result with a strange caracter in front of the string and I don't know how to add a line jump... Is it a special character to insert with WriteChar() ?
Any hint ?
On 07/03/2011 at 09:35, xxxxxxxx wrote:
AIUI WriteString() doesn't write a simple C character array as you might expect. It writes a C4D String object which obviously contains the text but also the other data which make it a String object. That's the odd stuff you see before the text.
If you want to write a plain text file, you need to write your own routine to do this. This has been discussed a few times here and if you search the forum you'll find a routine by Matthias (IIRC) that does the trick very well. Others have posted similar routines.
On 07/03/2011 at 12:00, xxxxxxxx wrote:
Now I know what I should look for. I'll dig in the forum.
Thank you !
On 08/03/2011 at 00:59, xxxxxxxx wrote:
Something like this should do the trick:
Bool WriteString(const String &line, BaseFile* file)
if(!file) return FALSE;
CHAR *charline = NULL;
LONG strlength = line.GetCStringLen(STRINGENCODING_7BITHEX);
charline = GeAllocType(CHAR, strlength+1);
if(!charline) return FALSE;
strlength = line.GetCString(charline, strlength+1, STRINGENCODING_7BITHEX);
for(i=0; i<strlength; i++)
if(!file->WriteChar(charline[i])) return FALSE;