[PD] [gem] Looking for an abstraction for converting textfiles in text3d string

IOhannes m zmoelnig zmoelnig at iem.at
Wed Feb 20 15:04:30 CET 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-02-19 15:21, Charles Goyard wrote:
> Hi,
> 
> almost there. But I don't know why, any2bytes converts my newlines
> (10) into spaces (32).
> 
> My input is like :
> 
> line1 line2 line3
> 
> So textfile returns the whole file at once, which is what I want.

[textfile] usually expects lines to be terminated by semicolons, e.g.
 line1;
 line2;
 line3;

if your file does not use semicolons as line delimiters, [textfile]
will ignore CR/LF/CRLF and append all those lines into a single
message [line1 line2 line3(,
and [any2bytes] will properly insert a space (32) as the atom delimiter.

you can tell [textfile] to use CR/LF/CRLF as line delimiters by
opening the file in "cr" mode, like
 [open file.txt cr(

then you will need to stop through the lines by [bang(ing [textfile]
till the end is reached. if you want to read the entire file at once,
use [until] (with the 2nd outlet of [textfile] fed back to the 2nd
inlet of [until], so it stops banging once the textfile is done.
convert each line with [any2bytes], use [list append] to append '10'
(the newline), and append those lists using another [list append].


> Maybe mrpeach's binfile is more appropriate ?

maybe.
if your file is saved as a W32 or MacOS(<X) file, then your line
delimiters will be CRLF resp. CR, which will show up as an unprintable
character (a small rectangle).
in this case you might want to replace the line delimiters with proper
LF to get what you want (which is easy enough if you don't care for
supporting _both_ CRLF and CR)


ghmnsdf
IOhannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlEk1+sACgkQkX2Xpv6ydvSyYACdG04xEZY+OZ6mVrT2iGLIMgEN
ZIsAoMM9IFrprjznZemvKa1KQH/5KlLi
=jo8q
-----END PGP SIGNATURE-----



More information about the Pd-list mailing list