[chuck-users] Evaluating an argument as anything but a string

Joel Matthys jwmatthys at yahoo.com
Wed Oct 1 23:42:54 EDT 2008


Hi Andrew. There is a handy command in the Std library for doing exactly that, Std.atof. (That's short for ASCII to float.)

float harm;
string arg1;
me.arg(0) => arg1;
arg1 => Std.atof => harm;

or you can shorten it to:
me.arg(0) => Std.atof => harm;

Hope this helps!
Joel


----- Original Message ----
From: Andrew C. Smith <acsmith at willamette.edu>
To: chuck-users at lists.cs.princeton.edu
Sent: Wednesday, October 1, 2008 7:55:38 PM
Subject: [chuck-users] Evaluating an argument as anything but a string

Hey all,
Long time listener, first time caller.  I'm a little bit new to this,
but I managed to write a program that uses LiSa to play a sample of a
piano harmonic at a specified rate, putting it at a specified partial.
Here's the deal:  I want to just do chuck harmonic.ck:4 for the 4th
partial, or chuck harmonic.ck:5 for the 5th, but it keeps telling me
that my arguments are strings, not floats.  Is there a way to do a
string-float conversion, or just even to read a particular argument as
a float?

float harm;
string arg1;
me.arg(0) => arg1;
...
arg1 => harm;

is all I have relating to the arguments.  Obviously, that doesn't
work, as you can't ChucK a string to a float.  There's probably a
simple answer to this, isn't there?

Andrew Smith
_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20081001/ce268e34/attachment.html>


More information about the chuck-users mailing list