[chuck-users] print absolute time in chuck

Gonzalo gonzalo at dense13.com
Mon May 2 04:56:05 EDT 2016


I had a similar problem a while ago, Perry Cook suggested this, it might 
be of help:

One way to do it would be to pass it in
as an argument or other when you run ChucK.
This example uses stdin to read the output
of a <date> command in the shell:

// TestDate.ck  Perry R. Cook, Dec. 2014
ConsoleInput stdin;     // gonna read from here
stdin.prompt("") => now; // wait until something comes in
string datetime; // date and time
string datetimenow; // plus time since chuck invoked tacked on
while (stdin.more())  {  stdin.getLine() => datetime;  } // read input
datetime.setCharAt(9,'-'); // replace time string colons
datetime.setCharAt(12,'-'); // with dashes instead
datetime+"-"+Std.ftoa(now/second,4) => datetimenow; // tack on time 
since chuck invoked
<<< datetimenow >>>;
// If you want to continue making updated unique
// strings, just keep redoing the datetimenow line
1.5*second => now;
datetime+"-"+Std.ftoa(now/second,4) => datetimenow; // tack on time 
since chuck invoked
<<< datetimenow >>>;

To use this:

date +"%m%d%y-%T" | chuck TestDate.ck

Outputs (date-H-M-S-now):

"120614-15-00-09-0.0000" : (string)
"120614-15-00-09-1.5000" : (string)



On 2/05/2016 9:53 AM, Chiel ten Brinke wrote:
> I would like to figure out the source of latency from chuck interacting
> with another application via OSC. To do that, I want to print timestamps
> of messages sent and received and compare these.
> But here's the thing:
>
> How do I print the absolute current time in chuck? The variable `now`
> only seems to hold the time from the start of the process.
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>

-- 
http://dense13.com
http://www.whole-play.com
https://www.30daygroove.com


More information about the chuck-users mailing list