[chuck-users] String concatenation
Graham Coleman
gc at gehennom.net
Mon Oct 9 13:26:36 EDT 2006
Norman,
There's currently no support for building strings - strings are
immutable once they are initialized from literals. String ops
have been in development, but are waiting garbage collection to
be added.
A workaround for your task is to generate a large literal array
of filenames in text and index them:
["a.wav","b.wav","c.wav","d.wav","e.wav","f.wav","g.wav","h.wav",
"i.wav","j.wav","k.wav","l.wav","m.wav","n.wav","o.wav","p.wav",
"q.wav","r.wav","s.wav","t.wav","u.wav","v.wav","w.wav","x.wav",
"y.wav","z.wav","aa.wav","bb.wav","cc.wav","dd.wav","ee.wav"]
@=> string names[];
> By the way, I'm doing the split by elaborating on
>
> SndBuf ibuf;
> "test.aif" => ibuf.read;
> 0 => ibuf.pos;
>
> WvOut ofile;
> "out0.aif" => ofile.aifFilename;
>
> ibuf => ofile => blackhole;
> 2::second => now;
>
> ofile.closeFile;
>
> Does that look reasonable, or am I misunderstanding something (on a
> few hours' acquaintance with ChucK)?
You might need parens on the function call:
ofile.closeFile();
best,
Graham
On Mon, 9 Oct 2006, Norman wrote:
> Greetings.
>
> Is there any support for building up strings within ChucK?
>
> I'd like to do something like
>
> WvOut ofile;
> 0 => int idx;
> "out" + idx + ".aif" => ofile.aifFilename;
>
> I'm trying to produce a script which will split an input file into
> short sections. I think I can see how to do most of it, but can't
> work out how to generate file names.
>
> The "string" type is mentioned in passing in the 'type' section of
> the manual, but with no indication of what methods it might have (I
> tried "idx => ofile.append", but...). Googling for 'string' at
> chuck.csc.princeton.edu doesn't indicate that I've missed anything
> major. And I can't spot anything in the FAQ at <http://
> wiki.cs.princeton.edu/index.php/ChucK>, other than a `medium
> priority' note `string operations' in <http://wiki.cs.princeton.edu/
> index.php/ChucK/Dev/DoThisNow>. Does this latter note mean that this
> isn't possible, but might be soon?
>
>
> Thanks for any pointers.
>
> Norman
>
More information about the chuck-users
mailing list