Works for me if I omit the '_.' in front of the starttime/stoptime variables
(and use "${sw.diff}").

Janis

> Date: Sat, 1 Aug 2009 06:02:16 +0200
> From: roland.ma...@nrubsig.org
> To: ast-users@research.att.com
> Subject: [ast-users] Discipline functions for float vs. $ printf "%f" 
> s_t.varname # ...
> 
> 
> Hi!
> 
> ----
> 
> The following testcase contains a simple "stopwatch" type which tracks
> the time between the functions "start" and "stop" and maintains a
> variable "diff" which contains the difference:
> -- snip --
> typeset -T stopwatch_t=(
>       float starttime=nan
>       float stoptime=nan
>       float diff=nan
>       
>       function start
>       {
>               (( _.starttime=SECONDS ))
>               return 0
>       }
>       function stop
>       {
>               (( _.stoptime=SECONDS ))
>               return 0
>       }
>       function reset
>       {
>               (( _.starttime=nan , _.stoptime=nan ))
>       }
>       function diff.get
>       {
>               (( .sh.value=_.stoptime-_.starttime ))
>               print -u2 "#mark"
>               return 0
>       }
> )
> 
> stopwatch_t sw
> 
> sw.start
> sleep 2.1
> sw.stop
> 
> printf "time=%f\n" sw.diff
> -- snip --
> 
> However when I run this testcase with ast-ksh.2009-06-22 it only prints:
> -- snip --
> time=nan
> -- snip --
> ... while the expected output should AFAIK be:
> -- snip --
> #mark
> time=2.1000
> -- snip --
> 
> AFAIK two things go wrong there:
> 1. Using $ printf "time=%f\n" sw.diff # to call the discipline method
> stopwatch_t.diff.get does not work, however it works when I replace
> "sw.diff" with "${sw.diff}"
> 2. The somehow the value assigned to ".sh.value" does not make it to the
> "printf" builtin... but I am not sure why this happens...
> 
> ----
> 
> Bye,
> Roland
> 
> -- 
>   __ .  . __
>  (o.\ \/ /.o) roland.ma...@nrubsig.org
>   \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
>   /O /==\ O\  TEL +49 641 3992797
>  (;O/ \/ \O;)
> _______________________________________________
> ast-users mailing list
> ast-users@research.att.com
> https://mailman.research.att.com/mailman/listinfo/ast-users

_________________________________________________________________
http://redirect.gimas.net/?n=M0907xIE8_MSN3
Gratis Download – die neue Version des Internet Explorers ist da!
_______________________________________________
ast-users mailing list
ast-users@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to