## working 5 kilometer run time to mile split calculator

Expand Messages
• It appears I have it with Hugo s assistance once again. What a duh on the padding numbers problem, and yet I stared at that for thirty minutes. Funny how
Message 1 of 5 , Oct 4, 2004
It appears I have it with Hugo's assistance once again. What a duh on
the padding numbers problem, and yet I stared at that for thirty
minutes. Funny how that can be counter-productive sometimes. Here I am
making sure every variable is the same letter for letter ...

;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
;minutes
^!Set %minutes_per_mile_target%=^\$Calc(FLOOR(^%seconds_per_mile%/60))\$
^!If ^\$StrSize("^%minutes_per_mile_target%")\$=1 ^!Set
%minutes_per_mile_target%=0^%minutes_per_mile_target%
;seconds
^!Set
%seconds_per_mile_target%=^\$Calc(^%seconds_per_mile%-(^%minutes_per_mile_target%*60);1)\$
^!If ^\$StrSize("^%seconds_per_mile_target%")\$=3 ^!Set
%seconds_per_mile_target%=0^%seconds_per_mile_target%

;two miles
;minutes
^!Set %minutes_per_2mile_target%=^\$Calc(FLOOR((^%seconds_per_mile%*2)/60))\$
^!If ^\$StrSize("^%minutes_per_2mile_target%")\$=1 ^!Set
%minutes_per_2mile_target%=0^%minutes_per_2mile_target%
;seconds
^!Set
%seconds_per_2mile_target%=^\$Calc((^%seconds_per_mile%*2)-(^%minutes_per_2mile_target%*60);1)\$
^!If ^\$StrSize("^%seconds_per_2mile_target%")\$=3 ^!Set
%seconds_per_2mile_target%=0^%seconds_per_2mile_target%

;three miles
;minutes
^!Set %minutes_per_3mile_target%=^\$Calc(FLOOR((^%seconds_per_mile%*3)/60))\$
^!If ^\$StrSize("^%minutes_per_3mile_target%")\$=1 ^!Set
%minutes_per_3mile_target%=0^%minutes_per_3mile_target%
;seconds
^!Set
%seconds_per_3mile_target%=^\$Calc((^%seconds_per_mile%*3)-(^%minutes_per_3mile_target%*60);1)\$
^!If ^\$StrSize("^%seconds_per_3mile_target%")\$=3 ^!Set
%seconds_per_3mile_target%=0^%seconds_per_3mile_target%

;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^%nl%

;the end

I have tested it on many numbers and it seems to zero pad all the way
through. The only thing that strikes me (as usual after the fact) is
that this could probably be built more effectively using an array that
stores the seconds per mile, and then process the array of seconds at
the end in a loop. By doing that, I think you could then use it for any
number of kilometers. That would give greater utility. I may play with
that later if I get the time, although I personally don't see a use for
it at other distances currently. I think it would make it a more widely
used clip however ... something like this:
http://www.runningtimes.com/pace/splits/splits.htm

I have been using that and copy/pasting results back to my notetab, so
this will be much better, especially when I get part two built. Part
two will take the actual splits of the runner and place them side by
side with the desired number to help them understand that they were too
fast at the beginning (as they usually are).
• On Mon, 04 Oct 2004 06:58:05 -0400, Don Passenger wrote: [ .  see the original post this thread for the original enclosed clip . ] P.S. Yahoo Groups and my
Message 2 of 5 , Oct 4, 2004
On Mon, 04 Oct 2004 06:58:05 -0400, Don Passenger wrote:
[ . �see the original post this thread for the original enclosed clip . ]

P.S. Yahoo Groups and my ISP lately, even right now, having huge incompatabilities. I may need get another email addr elsewhere to use for Yahoo Groups.

>�[ . . ] �The only thing that strikes me (as usual after the fact) is
>�that this could probably be built more effectively using an array that
>�stores the seconds per mile, and then process the array of seconds at
>�the end in a loop. �By doing that, I think you could then use it for any

I often get better ideas after the fact so to speak.

I tinkered, modified the original clip, got re usable code placed inside the loop and merely does increment whilst re using the same code over again for yet another mile. � �time entry allows xx.xx as well as xx:xx �; � length entry allows differing length to entered �; � allows entered length format where x equals a digit: � �x. �or �x.x � or � x � �or � �xx.xxx � �or i guess even �xxx.xxx �100 mile run, eh �this latter 3 digit run untested.

FWIW if anything,

Tinkering results next:

H="track"
^!clearvariables
;get goal time
^!Set %goal_time%=^?[Goal Time (xx:xx)]
^!Set %length%=^?[Overall distance in miles=3.107]

;allows Goal Time (xx.xx) (period instead of :)
^!Set %goal_time%=^\$StrReplace(".";":";"^%goal_time%";0;0)\$

;insures x.x length, enables subsequent split on .
^!IfMatch "\d+\.\d+" "^%length%" Skip
^!Set %length%=^%length%.0
^!Set %length%=^\$StrReplace("..";".";"^%length%";0;0)\$

;^!Info ^%length%
;^!Goto end

;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%/^%length%)\$

;^!Info ^%seconds_per_mile%

;split length into 2 item list x.x miles
^!SetListDelimiter .
^!SetArray %length_list%=^%length%
^!Info LL1 ^%length_list1%~~~LL2 ^%length_list2%
;^!Goto end

;here to end:
;loops, each mile minute result appends into %breakdown%
;each mile second result to be appended as well. but this
;short section is not working right so it's not appended now
;then checks for fractional of a mile or not in %length_list2%
;then show the output or printed ^%breakdown%
^!Set %Count%=^%length_list1%
^!Set %Index%=0
:ea_chunk
^!Inc %Index%
;total seconds mile 1, mile 2, mile 3, etc.
;^!Set %tm_ea_mile%=^\$Calc(^%seconds_per_mile%*^%Index%)\$

;%tm_ea_mile% equals target_minutes_per_mile
^!Set %tm_ea_mile%=^\$Calc(FLOOR((^%seconds_per_mile%*^%Index%)/60))\$
^!If ^\$StrSize("^%tm_ea_mile%")\$=1 ^!Set %tm_ea_mile%=0^%tm_ea_mile%

;next section not working right
;s_p_m_t equals seconds_per_mile_target
^!Set %s_p_m_t%=^\$Calc(^%seconds_per_mile%-(^%tm_ea_mile%*60);1)\$
^!If ^\$StrSize("^%s_p_m_t%")\$=3 ^!Set %s_p_m_t%=0^%s_p_m_t%
^!Info ^%s_p_m_t%

^!Append %breakdown%=Mile ^%Index%: �^%tm_ea_mile%~s_p_m_t^%NL%
^!IfSame "^%Index%" "^%Count%" finale
^!Goto ea_chunk
:finale
^!IfSame "^%length_list2%" "0" Skip
^!Append %breakdown%=Mile ^%length%: �^%goal_time%
^!Info ^%breakdown%
^!clearvariables
;----end---

--
Alan.
• Alan, you da bomb man! I think I have it working: ^!clearvariables ;get goal time ^!Set %goal_time%=^?[Goal Time (xx:xx)] ^!Set %length%=^?[Overall distance
Message 3 of 5 , Oct 4, 2004
Alan, you da bomb man! I think I have it working:

^!clearvariables
;get goal time
^!Set %goal_time%=^?[Goal Time (xx:xx)]
^!Set %length%=^?[Overall distance in miles=3.107]

;allows Goal Time (xx.xx) (period instead of :)
^!Set %goal_time%=^\$StrReplace(".";":";"^%goal_time%";0;0)\$

;insures x.x length, enables subsequent split on .
^!IfMatch "\d+\.\d+" "^%length%" Skip
^!Set %length%=^%length%.0
^!Set %length%=^\$StrReplace("..";".";"^%length%";0;0)\$

;^!Info ^%length%
;^!Goto end

;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%/^%length%)\$

;^!Info Seconds per Mile: ^%seconds_per_mile%

;split length into 2 item list x.x miles
^!SetListDelimiter .
^!SetArray %length_list%=^%length%
^!Info LL1 ^%length_list1%~~~LL2 ^%length_list2%
;^!Goto end

;here to end:
;loops, each mile minute result appends into %breakdown%
;each mile second result to be appended as well. but this
;short section is not working right so it's not appended now
;then checks for fractional of a mile or not in %length_list2%
;then show the output or printed ^%breakdown%
^!Set %Count%=^%length_list1%
^!Set %Index%=0
:ea_chunk
^!Inc %Index%
;total seconds mile 1, mile 2, mile 3, etc.
;^!Set %tm_ea_mile%=^\$Calc(^%seconds_per_mile%*^%Index%)\$

;%tm_ea_mile% equals target_minutes_per_mile
^!Set %tm_ea_mile%=^\$Calc(FLOOR((^%seconds_per_mile%*^%Index%)/60))\$
^!If ^\$StrSize("^%tm_ea_mile%")\$=1 ^!Set %tm_ea_mile%=0^%tm_ea_mile%

;next section not working right
;s_p_m_t equals seconds_per_mile_target
^!Set
%s_p_m_t%=^\$Calc((^%seconds_per_mile%*^%Index%)-(^%tm_ea_mile%*60);1)\$
^!If ^\$StrSize("^%s_p_m_t%")\$=3 ^!Set %s_p_m_t%=0^%s_p_m_t%
^!Info ^%s_p_m_t%

^!Append %breakdown%=Mile ^%Index%: ^%tm_ea_mile%:^%s_p_m_t%^%NL%
^!IfSame "^%Index%" "^%Count%" finale
^!Goto ea_chunk
:finale
^!IfSame "^%length_list2%" "0" Skip
^!Append %breakdown%=Mile ^%length%: ^%goal_time%
^%breakdown%
^!clearvariables
;----end---

Next question for this more flexible clip ... what happens when we
exceed 60 minutes as we might for a marathon for example ... not that
I need it, but it may make a more generically useable clip.

I have part two working as well, and I can post that in a bit when I
fire up my other computer.
• ... [ see former post for the previous, smaller version clip ] ... that ... For up to 3 hrs 59 minutes and 59 seconds, here s a rough blueprint that works. It
Message 4 of 5 , Oct 5, 2004
--- In ntb-clips@yahoogroups.com, "dpasseng" <dpasseng@i...> wrote:
[ see former post for the previous, smaller version clip ]
> Next question for this more flexible clip ... what happens when we
> exceed 60 minutes as we might for a marathon for example ... not
that
> I need it, but it may make a more generically useable clip.

For up to 3 hrs 59 minutes and 59 seconds, here's a rough blueprint
that works. It works! It also includes hints on howto add on to a
sub clip therein to make it so can also to use for 4 hours and
upwards thereof.

It has now swelled to three clips all total. But I don't think it's
totally 100% dialed in yet though. Though it's fun, I likely only
have but little if any more time to spend on it. As usual, rather
likely other, different ways than this also do exist.

As a test, I entered something like 13 miles and 2 hours and 14:36

It worked great. but I think, when hours field is used, the
outputted minutes yet need a bit more revision. Cheers! (3) Clips
enclosed next.

H="track2"
^!clearvariables
;get goal time
^!Set %goal_time%=^?[Goal Time (xx:xx)]
^!Set %hours%=^?[Optional hour field (x or xx)=]
^!Set %length%=^?[Overall distance in miles=3.107]

;allows Goal Time (xx.xx) (period instead of :)
^!Set %goal_time%=^\$StrReplace(".";":";"^%goal_time%";0;0)\$

;insures x.x length, enables subsequent split on .
^!IfMatch "\d+\.\d+" "^%length%" Skip
^!Set %length%=^%length%.0
^!Set %length%=^\$StrReplace("..";".";"^%length%";0;0)\$

;^!Info ^%length%
;^!Goto end

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

^!IfTrue ^\$IsEmpty(^%hours%)\$ no_hrs
^!If ^%hours% <= 3 lo_hrs
^!Clip big_hour_handlr
^!Goto is_big_hours

:lo_hrs
^!Set %lo_hr_2min%=^\$Calc(^%hours%*60)\$
^!Set %time1%=^\$Calc(^%time1%+^%lo_hr_2min%)\$

:no_hrs

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

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

;^!Info ^%seconds_per_mile%

;split length into 2 item list x.x miles
^!SetListDelimiter .
^!SetArray %length_list%=^%length%
;^!Info LL1 ^%length_list1%~~~LL2 ^%length_list2%
;^!Goto end

;here to end:
;loops, each mile minute result appends into %breakdown%
;each mile second result appends as well.
;then checks for fractional of a mile or not in %length_list2%
;then show the output or printed ^%breakdown%
^!Set %Count%=^%length_list1%
^!Set %Index%=0
:ea_chunk
^!Inc %Index%
;total seconds mile 1, mile 2, mile 3, etc.
;^!Set %tm_ea_mile%=^\$Calc(^%seconds_per_mile%*^%Index%)\$

;%tm_ea_mile% equals target_minutes_per_mile
^!Set %tm_ea_mile%=^\$Calc(FLOOR((^%seconds_per_mile%*^%Index%)/60))\$
^!If ^\$StrSize("^%tm_ea_mile%")\$=1 ^!Set %tm_ea_mile%=0^%tm_ea_mile%

;s_p_m_t equals seconds_per_mile_target
^!Set %s_p_m_t%=^\$Calc((^%seconds_per_mile%*^%Index%)-(^%tm_ea_mile%
*60);1)\$
^!If ^\$StrSize("^%s_p_m_t%")\$=3 ^!Set %s_p_m_t%=0^%s_p_m_t%
;^!Info ^%s_p_m_t%

^!If ^%tm_ea_mile% <= 59 stay_here1
^!Clip undr_4_hrs
^!Goto undr_4_hrs_return

:stay_here1
^!Append %breakdown%=Mile ^%Index%: ^%tm_ea_mile%:^%s_p_m_t%^%NL%
^!Goto stay_here2

:undr_4_hrs_return
^!Append %breakdown%=Mile ^%Index%: ^%hrs%:^%m_ea_mil%:^%s_p_m_t%^%NL%

:stay_here2
^!IfSame "^%Index%" "^%Count%" finale
^!Goto ea_chunk
:finale
^!IfSame "^%length_list2%" "0" Skip
^!Append %breakdown%=Mile ^%length%: ^%goal_time%
^!Info ^%breakdown%
^!clearvariables
^!Goto end
:is_big_hours
^!Info ^%big_hr_breakdown%

H="_undr_4_hrs"
;^!Append %howto%=Please notice this win title!^%NL%
;^!Append %howto%= --- --- --- --- --^%NL%
;^!Append %howto%=1 1/2 cent idea!^%NL%
;^!Append %howto%=Here in this sub clip^%NL%
;^!Append %howto%=see comment Routine herein^%NL%
;^!Info ^%howto%
;comment Routine (exists above)

^!If ^%tm_ea_mile% => 120 onehundrtwenty
^!Set %hrs%=^\$Calc(^%tm_ea_mile%/60)\$
^!Set %m_ea_mil%=^\$Calc(^%tm_ea_mile%/60)\$
^!Goto end

:onehundrtwenty
^!If ^%tm_ea_mile% => 180 onehundreighty
^!Set %hrs%=^\$Calc(^%tm_ea_mile%/120)\$
^!Set %m_ea_mil%=^\$Calc(^%tm_ea_mile%/120)\$
^!Goto end

:onehundreighty
^!Set %hrs%=^\$Calc(^%tm_ea_mile%/180)\$
^!Set %m_ea_mil%=^\$Calc(^%tm_ea_mile%/180)\$

H="_big_hour_handlr"
^!Append %helps%=Please notice this win title!^%NL%
^!Append %helps%= --- --- --- --- --^%NL%
^!Append %helps%=Current max 3 hrs 59 mins 59 secs^%NL%
^!Append %helps%=For 4 hrs and up, read on!^%NL%
^!Append %helps%= ---- ---- ---- ----^%NL%
^!Append %helps%=1 1/2 cent idea!^%NL%
^!Append %helps%=Right here in _big_handlr sub clip^%NL%
^!Append %helps%=write a routine use only hrs and^%NL%
^!Append %helps%=minutes. Eliminate seconds.^%NL%
^!Append %helps%=Identical to main clip. Except uses^%NL%
^!Append %helps%=hrs and mins instead of mins and^%NL%
^!Append %helps%=seconds. See, this bypasses the mins^%NL%
^!Append %helps%=and secs routine of main clip.
^!Info ^%helps%

^!Append %big_hr_breakdown%=Please notice this win title!
^!Append %big_hr_breakdown%=^%NL% --- --- --- --^%NL%
^!Append %big_hr_breakdown%=Hi! Your big! Lots hours!
^!Set %big_hr_breakdown%=^%big_hr_breakdown%
;-----end_of_clips----

--
Alan.
• ... [ . . ] ... Already can do that. I forgot to mention a just for fun thing in the clip ie go ahead and enter 7 for the hours, say, 31 for the miles, 12
Message 5 of 5 , Oct 5, 2004
--- In ntb-clips@yahoogroups.com, "acummingsus" <acumming@c...> wrote:
>
> --- In ntb-clips@yahoogroups.com, "dpasseng" <dpasseng@i...> wrote:
> [ see former post for the previous, smaller version clip ]
[ . . ]
> includes hints on howto add on to a
> sub clip therein to make it so can also to use for 4 hours and
> upwards thereof.

Already can do that. I forgot to mention a just for fun thing in the
clip ie go ahead and enter 7 for the hours, say, 31 for the miles, 12
minutes, 14 seconds.

Really the 4 or greater for the hours field is the key thing that
triggers it for it to go into its big_hour_handlr sub routine clip.
But if you want that child clip to calculate then I left some hints.

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