Thanks JRL. That is very neatly and elegantly done compared to my original rather ugly solution.
Don't forget this wasn't a pleas for help but more a topic of interest and as usual, I have learned a lot from you guys thank you.
Code: Select all
Let>RP_ADMIN=1
Let>APP_TITLE=Frame Calculator
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
Let>MSG_WIDTH=360
Let>MSG_HEIGHT=200
Let>WF_TYPE=1
Let>VAREXPLICIT=0
Let>CF_OVERWRITE=1
Let>reg_pattern=[1 or more digits]:[1 or more digits]:[1 or more digits].[1 or more digits]
Let>reg_pattern_text=[letter]
VBSTART
''
VBEND
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//Determine the decimal placeholder
Let>num=0.1
LibFunc>kernel32,GetNumberFormatA,r,0,0,str:num,0,buf,255
MidStr>r_5,2,1,DecimalPlaceHolder
///////////////////////////////////////////////////////////////////////
Dialog>Dialog1
Caption=FR Calc
Width=240
Height=178
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
Edit=msEdit2,72,40,73,25
Edit=msEdit1,8,70,137,0
Edit=msEdit3,8,100,137,0:0:0.0
Label=Frame Rate Calc by Phil Pendlebury,10,8,true
Label=Frame Rate:,10,42,true
Button=Calc Frames,152,69,74,23,4,,Calculate Frames from a Time entry and add Frames to clipboard
Button=Calc Time,152,99,74,23,3,,Calculate Time from number of frames and add Time to clipboard
Button=Quit,152,39,74,23,6,,Bye Bye!
MainMenu=Menu,About(30),Help(40),Developers(50),MEAP(60),Quit(6)
EndDialog>Dialog1
///////////////////////////////////////////////////////////////////////
Label>ShowD
Show>Dialog1
Label>DialogLoop
GetDialogAction>Dialog1,res
IF>res=3,calctime
IF>res=4,calcframes
IF>res=6,exit
IF>res=30
MDL>Frame Rate Calculator by Phil Pendlebury%CRLF%%CRLF%Version 2.01 - 16 February 2010
RDA>Dialog1
ENDIF
IF>res=40
MDL>ALWAYS Enter a Frame Rate%CRLF%%CRLF%Enter TOT FRAMES and hit Calc Time to get the time from the number of frames.%CRLF%%CRLF%Enter H:M:S.F and hit Calc Frames to get total frames from that time.
RDA>Dialog1
ENDIF
IF>res=50
MDL>Phil Pendlebury%CRLF%%CRLF%http://www.pendlebury.biz/%CRLF%%CRLF%Thanks to: Fredo, Panos, Bo, Neil
RDA>Dialog1
ENDIF
IF>res=60
ExecuteFile>http://www.meap.biz/
RDA>Dialog1
ENDIF
//
Let>dtotal=%Dialog1.msEdit1%
Let>drate=%Dialog1.msEdit2%
Let>dtime=%Dialog1.msEdit3%
Let>doingtime=3
//
Wait>0.001
GOTO>DialogLoop
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>calctime
Let>doingtime=1
GOSUB>isnumber
// from frames
StringReplace>drate,DecimalPlaceHolder,.,drate
Let>allframes=%dtotal%
GOSUB>gettimefromsecs
Let>all_time=%chours%:%cminutes%:%cseconds%.%cframes%
Let>Dialog1.msEdit3=%all_time%
PutClipBoard>%all_time%
RDA>Dialog1
END>calctime
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>calcframes
Let>doingtime=2
GOSUB>sep_time
GOSUB>isnumber
// from time
StringReplace>drate,DecimalPlaceHolder,.,drate
GOSUB>getsecsfromtime
Let>Dialog1.msEdit1=%dtotal%
PutClipBoard>%dtotal%
RDA>Dialog1
END>calcframes
///////////////////////////////////////////////////////////////////////
Label>exit
///////////////////////////////////////////////////////////////////////
SRT>gettimefromsecs
Let>allseconds=allframes/drate
StringReplace>%allseconds%,DecimalPlaceHolder,.,allseconds
////////////////////////////////
let>chours=0
Label>get_hours
IF>allseconds>3599
let>chours=chours+1
let>allseconds=allseconds-3600
StringReplace>%allseconds%,DecimalPlaceHolder,.,allseconds
ENDIF
IF>%allseconds%<3600
GOTO>skip_hours
ENDIF
GOTO>get_hours
Label>skip_hours
////////////////////////////////
let>cminutes=0
Label>get_minutes
IF>allseconds>59
let>cminutes=cminutes+1
let>allseconds=allseconds-60
StringReplace>%allseconds%,DecimalPlaceHolder,.,allseconds
ENDIF
IF>%allseconds%<60
GOTO>skipminutes
ENDIF
GOTO>get_minutes
Label>skipminutes
////////////////////////////////
Let>cseconds={Trunc(%allseconds%)}
Let>fracseconds={Frac(%allseconds%)}
StringReplace>%fracseconds%,DecimalPlaceHolder,.,fracseconds
Let>fracframes=fracseconds*drate
StringReplace>%fracframes%,DecimalPlaceHolder,.,fracframes
Let>cframes=%fracframes%
// Round to 6 DP
VBEval>Round(%cframes%,10),cframes
// MidStr>%cframes%,1,10,cframes
////////////////////////////////
// MDL> HOUR: %chours% MIN: %cminutes% SEC: %cseconds% FR: %cframes%
END>gettimefromsecs
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>getsecsfromtime
//
Let>fhours=%dhours%*60
Let>fhours=%fhours%*60
Let>fhours=%fhours%*%drate%
//
Let>fminutes=%dminutes%*60
Let>fminutes=%fminutes%*%drate%
//
Let>fseconds=%dseconds%*%drate%
//
Let>dtotal=%fhours%+%fminutes%
Let>dtotal=%dtotal%+%fseconds%
Let>dtotal=%dtotal%+%dframes%
//
// MDL>Total Frames: %dtotal%
END>getsecsfromtime
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>sep_time
//
Separate>dtime,:,sep_hms
Separate>sep_hms_3,.,sep_frm
Let>dhours=%sep_hms_1%
Let>dminutes=%sep_hms_2%
Let>dseconds=%sep_frm_1%
Let>dframes=%sep_frm_2%
END>sep_time
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>isnumber
IF>%drate%>0
Let>check_drate=%drate%/%drate%
IF>check_drate<>1
Let>error=FRAME RATE
GOSUB>reset
ENDIF
ELSE
IF>%drate%=0
MDL>Frame Rate must be something other than Zero!
RDA>Dialog1
GOTO>DialogLoop
ENDIF
ENDIF
IF>%drate%=
MDL>Frame Rate must contain a value!
RDA>Dialog1
GOTO>DialogLoop
ENDIF
IF>doingtime=1
IF>%dtotal%=
MDL>Frames must contain a value!
RDA>Dialog1
GOTO>DialogLoop
ENDIF
IF>%dtotal%>0
Let>check_dtotal=%dtotal%/%dtotal%
IF>check_dtotal<>1
Let>error=FRAMES
GOSUB>reset
ENDIF
ELSE
MDL>Frames must contain a value greater than Zero!
ENDIF
ENDIF
IF>doingtime=2
IF>%dtime%=
MDL>Time must contain a value!
RDA>Dialog1
GOTO>DialogLoop
ENDIF
IF>%dtime%=0:0:0.0
MDL>Time must contain a value greater than Zero!
ENDIF
IF>%dtime%>0
RegEx>reg_pattern_text,dtime,1,tmatches,tnum,0
IF>tnum>0
MDL>Time Must not contain letters!
RDA>Dialog1
GOTO>DialogLoop
ENDIF
RegEx>reg_pattern,dtime,1,matches,num,0
IF>num<1
MDL>Time Must be in format H:M:S.F (0:0:0.0)
RDA>Dialog1
GOTO>DialogLoop
ENDIF
ENDIF
ENDIF
END>isnumber
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
SRT>reset
MDL>%error% contains a value that isn't a number!
RDA>Dialog1
GOTO>DialogLoop
END>reset
///////////////////////////////////////////////////////////////////////