<div dir="ltr">The problem with this approach, though, is that it apparently takes a few seconds before the input is processed and the internal chuck timer starts counting.<div>This results in that the times printed by the suggested code always is a few seconds too early. This makes this approach not quite useful for tracking down latency problems.</div><div><br></div><div>Is there a way around this caveat, or are there other approaches to print full time?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 3, 2016 at 9:54 AM, Chiel ten Brinke <span dir="ltr"><<a href="mailto:ctenbrinke@gmail.com" target="_blank">ctenbrinke@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Here is an improvement over the provided script:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>class FullTimeHack</div></div><div><div>{</div></div><div><div> int minutes;</div></div><div><div> int seconds;</div></div><div><div><br></div></div><div><div> // PRECONSTRUCTOR</div></div><div><div><br></div></div><div><div> string datetime;</div></div><span class=""><div><div> ConsoleInput stdin; // gonna read from here</div></div><div><div> stdin.prompt("") => now; // wait until something comes in</div></div></span><span class=""><div><div> while (stdin.more()) { stdin.getLine() => datetime; } // read input</div></div></span><div><div> //<<< datetime >>>;</div></div><div><div> Std.atoi(datetime.substring(10, 2)) => minutes;</div></div><div><div> Std.atoi(datetime.substring(13, 2)) => seconds;</div></div><div><div> <<< minutes + ":" + seconds >>>;</div></div><div><div><br></div></div><div><div><br></div></div><div><div> fun void print_full_time()</div></div><div><div> {</div></div><div><div> (seconds + now/second) % 60 => float new_seconds;</div></div><div><div> (minutes + now/minute) $ int % 60 => int new_minutes;</div></div><div><div> <<< new_minutes + ":" + new_seconds >>>;</div></div><div><div> }</div></div><div><div><br></div></div><div><div>}</div></div><div><div><br></div></div><div><div>FullTimeHack hack;</div></div><div><div>hack.print_full_time();</div></div></blockquote><div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 2, 2016 at 6:11 PM, Chiel ten Brinke <span dir="ltr"><<a href="mailto:ctenbrinke@gmail.com" target="_blank">ctenbrinke@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for you response. I'm gonna try that out right away,<div><br></div><div>By the way, wouldn't it be nice if this could be done more easily? Especially since ChucK is really into all the timey wimey stuff :)</div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 2, 2016 at 10:56 AM, Gonzalo <span dir="ltr"><<a href="mailto:gonzalo@dense13.com" target="_blank">gonzalo@dense13.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I had a similar problem a while ago, Perry Cook suggested this, it might be of help:<br>
<br>
One way to do it would be to pass it in<br>
as an argument or other when you run ChucK.<br>
This example uses stdin to read the output<br>
of a <date> command in the shell:<br>
<br>
// TestDate.ck Perry R. Cook, Dec. 2014<br>
ConsoleInput stdin; // gonna read from here<br>
stdin.prompt("") => now; // wait until something comes in<br>
string datetime; // date and time<br>
string datetimenow; // plus time since chuck invoked tacked on<br>
while (stdin.more()) { stdin.getLine() => datetime; } // read input<br>
datetime.setCharAt(9,'-'); // replace time string colons<br>
datetime.setCharAt(12,'-'); // with dashes instead<br>
datetime+"-"+Std.ftoa(now/second,4) => datetimenow; // tack on time since chuck invoked<br>
<<< datetimenow >>>;<br>
// If you want to continue making updated unique<br>
// strings, just keep redoing the datetimenow line<br>
1.5*second => now;<br>
datetime+"-"+Std.ftoa(now/second,4) => datetimenow; // tack on time since chuck invoked<br>
<<< datetimenow >>>;<br>
<br>
To use this:<br>
<br>
date +"%m%d%y-%T" | chuck TestDate.ck<br>
<br>
Outputs (date-H-M-S-now):<br>
<br>
"120614-15-00-09-0.0000" : (string)<br>
"120614-15-00-09-1.5000" : (string)<div><div><br>
<br>
<br>
<br>
On 2/05/2016 9:53 AM, Chiel ten Brinke wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
I would like to figure out the source of latency from chuck interacting<br>
with another application via OSC. To do that, I want to print timestamps<br>
of messages sent and received and compare these.<br>
But here's the thing:<br>
<br>
How do I print the absolute current time in chuck? The variable `now`<br>
only seems to hold the time from the start of the process.<br>
<br>
<br></div></div>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br><span><font color="#888888">
</font></span></blockquote><span><font color="#888888">
<br>
-- <br>
<a href="http://dense13.com" rel="noreferrer" target="_blank">http://dense13.com</a><br>
<a href="http://www.whole-play.com" rel="noreferrer" target="_blank">http://www.whole-play.com</a><br>
<a href="https://www.30daygroove.com" rel="noreferrer" target="_blank">https://www.30daygroove.com</a><br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>