Loading ...
Sorry, an error occurred while loading the content.

padding numbers

Expand Messages
  • Don Passenger
    I am getting very close now! I have two halves to this thing, and both halves are getting very close. Part two in a bit, but part one will allow you to
    Message 1 of 4 , Oct 3, 2004
    • 0 Attachment
      I am getting very close now! I have two halves to this thing, and both
      halves are getting very close.

      Part two in a bit, but part one will allow you to calculate mile splits
      to achieve a particular 5 Kilometer Road Run time.
      I have one problem, if the answer to my math problem is say 6.9 as in
      5:06.9, I need the zero padding to make it come out right.

      Try 30:00 first and then try 19:00 minutes second. Compare the first
      mile split both times and you will see the shortcoming in my clip. Any
      help greatly appreciated!

      Here is my clip:

      ;get goal time
      ^!Set %goal_time%=^?[Goal Time (xx:xx)]

      ;split goal time to minutes/seconds
      ^!SetListDelimiter :
      ^!SetArray %time%=^%goal_time%

      ;convert minutes to seconds
      ^!Set %time_seconds%=^$Calc((^%time1%*(60))+^%time2%)$

      ;calculate seconds per mile
      ^!Set %seconds_per_mile%=^$Calc(^%time_seconds%/3.107)$

      ;do math on seconds per mile
      ;to get minutes and seconds
      ;one mile
      ^!Set %minutes_per_mile_target%=^$Calc(FLOOR(^%seconds_per_mile%/60))$
      ^!Set
      %seconds_per_mile_target%=^$Calc(^%seconds_per_mile%-(^%minutes_per_mile_target%*60);1)$

      ;two miles
      ^!Set %minutes_per_2mile_target%=^$Calc(FLOOR((^%seconds_per_mile%*2)/60))$
      ^!Set
      %seconds_per_2mile_target%=^$Calc((^%seconds_per_mile%*2)-(^%minutes_per_2mile_target%*60);1)$

      ;three miles
      ^!Set %minutes_per_3mile_target%=^$Calc(FLOOR((^%seconds_per_mile%*3)/60))$
      ^!Set
      %seconds_per_3mile_target%=^$Calc((^%seconds_per_mile%*3)-(^%minutes_per_3mile_target%*60);1)$


      ;output
      ^%nl%Mile Splits to Run ^%goal_time% for 5K
      ^%nl%^%minutes_per_mile_target%:^%seconds_per_mile_target% - 1 Mile
      ^%minutes_per_2mile_target%:^%seconds_per_2mile_target% - 2 Mile
      ^%minutes_per_3mile_target%:^%seconds_per_3mile_target% - 3 Mile
      ^%goal_time%.0 - finish
    • Don Passenger
      looks like I may have repeated myself ... see http://groups.yahoo.com/group/ntb-clips/message/11161 where apparently Hugo answered about the same question once
      Message 2 of 4 , Oct 3, 2004
      • 0 Attachment
        looks like I may have repeated myself ...
        see http://groups.yahoo.com/group/ntb-clips/message/11161
        where apparently Hugo answered about the same question once before
        ^!If ^$StrSize("^%Field%")$=2 ^!Set %Field%=0^%Field%
        I can adapt that I think.

        Don Passenger wrote:
        snip
        > I have one problem, if the answer to my math problem is say 6.9 as in
        > 5:06.9, I need the zero padding to make it come out right.
        snip
      • Don Passenger
        Missing something simple here: ^!Set ^%seconds_per_mile_target%=6.9 ^!Info ^%seconds_per_mile_target% ^!Info ^$StrSize( ^%seconds_per_mile_target% )$ ^!If
        Message 3 of 4 , Oct 3, 2004
        • 0 Attachment
          Missing something simple here:

          ^!Set ^%seconds_per_mile_target%=6.9
          ^!Info ^%seconds_per_mile_target%
          ^!Info ^$StrSize("^%seconds_per_mile_target%")$
          ^!If ^$StrSize("^%seconds_per_mile_target%")$=3 ^!Set
          ^%seconds_per_mile_target%=0^%seconds_per_mile_target%
          ^!Info ^%seconds_per_mile_target%


          Is not working as I expect. I would think it would make 6.9 become 06.9
        • Hugo Paulissen
          ... [snip] ... 06.9 Don, Remove the ^ before the name of the variable when you set it. ^!Set ^%var% does not work, it should be ^!Set %var% Hugo
          Message 4 of 4 , Oct 4, 2004
          • 0 Attachment
            > Missing something simple here:
            >
            [snip]
            >
            > Is not working as I expect. I would think it would make 6.9 become
            06.9

            Don,

            Remove the ^ before the name of the variable when you set it.

            ^!Set ^%var% does not work, it should be
            ^!Set %var%

            Hugo
          Your message has been successfully submitted and would be delivered to recipients shortly.