I am trying to write an elapsed time sub that will display the
time since a remembered start time. I have got seconds working
but kind of got stuck on minutes, one thought was to convert
all times to elapsed seconds then do the math to extrapolate
Minutes and hours. I am drawing a blank on how to make this work.
Note: I am not asking any one to write code, I will be more then
happy to get a pseudo code strategy or even a hint on a better
direction.
Thanks
Brian
On a side note.. I am learning PB after years of VB experience.
I just wrote an Excel Macro to pull data out of 10000 or so
unique text files, it took about 45 minutes to run. I think I
will rewrite it in PBCC to output to a comma del text file and
see what the speed diff is. From what I have read here it
should be significantly faster. Since this is something I will
reuse in the future it should be worth it. Also I noticed that quite
a few of my favorite functions I have written in VB copy over and
run in PB without modification. Something that makes me very
Happy
BS
'================
'Start PB Dos Code
'================
'this is a test bas to try out the function and and see what
' it does. Once it works I will copy it to the main bas.
DIM Start AS STRING
DIM x AS INTEGER
Start = TIME$
FOR x = 0 TO 65
CLS
LOCATE 2,1
DispTimeLeft Start, "09:00:00"
SLEEP 1
NEXT x
PRINT "done"
SUB DispTimeLeft(StartTime AS STRING)
DIM CurTime AS STRING
DIM CurHr AS INTEGER
DIM CurMn AS INTEGER
DIM CurSc AS INTEGER
DIM StartHr AS INTEGER
DIM StartMn AS INTEGER
DIM StartSc AS INTEGER
DIM DiffHr AS INTEGER
DIM DiffMn AS INTEGER
DIM DiffSc AS INTEGER
'get current time
CurTime = TIME$
'Parse out Hours, Minutes and Seconds into int's
CurHr = VAL(MID$(CurTime,1,2))
CurMn = VAL(MID$(CurTime,4,2))
CurSc = VAL(MID$(CurTime,7,2))
StartHr = VAL(MID$(StartTime,1,2))
StartMn = VAL(MID$(StartTime,4,2))
StartSc = VAL(MID$(StartTime,7,2))
'Calculates diff of start seconds to current Seconds
IF CurSc>=StartSc THEN
DiffSc = CurSc-StartSc
ELSE
DiffSc = (CurSc+60)-StartSc
END IF
'Calculate diff of start minutes to current minutes
IF CurMn>=StartMn THEN
DiffMn = CurMn-StartMn
ELSE
DiffMn = (CurMn+60)-StartMn
END IF
'NOTE: Not sure how to mix minutes and seconds, not to mention hours
'Display results for now
PRINT "Current = "+TRIM$(STR$(CurHR))+":"+TRIM$(STR$(CurMN))+":"+TRIM$(STR$(CurSC))
PRINT "Start = "+TRIM$(STR$(StartHR))+":"+TRIM$(STR$(StartMN))+":"+TRIM$(STR$(StartSC))
PRINT "Diffrence = "+TRIM$(STR$(DiffHR))+":"+TRIM$(STR$(DiffMN))+":"+TRIM$(STR$(DiffSC))
'Other stuff to come later...
END SUB
'================
'End PB Dos Code
'================
------------------
time since a remembered start time. I have got seconds working
but kind of got stuck on minutes, one thought was to convert
all times to elapsed seconds then do the math to extrapolate
Minutes and hours. I am drawing a blank on how to make this work.
Note: I am not asking any one to write code, I will be more then
happy to get a pseudo code strategy or even a hint on a better
direction.
Thanks
Brian
On a side note.. I am learning PB after years of VB experience.
I just wrote an Excel Macro to pull data out of 10000 or so
unique text files, it took about 45 minutes to run. I think I
will rewrite it in PBCC to output to a comma del text file and
see what the speed diff is. From what I have read here it
should be significantly faster. Since this is something I will
reuse in the future it should be worth it. Also I noticed that quite
a few of my favorite functions I have written in VB copy over and
run in PB without modification. Something that makes me very
Happy

BS
'================
'Start PB Dos Code
'================
'this is a test bas to try out the function and and see what
' it does. Once it works I will copy it to the main bas.
DIM Start AS STRING
DIM x AS INTEGER
Start = TIME$
FOR x = 0 TO 65
CLS
LOCATE 2,1
DispTimeLeft Start, "09:00:00"
SLEEP 1
NEXT x
PRINT "done"
SUB DispTimeLeft(StartTime AS STRING)
DIM CurTime AS STRING
DIM CurHr AS INTEGER
DIM CurMn AS INTEGER
DIM CurSc AS INTEGER
DIM StartHr AS INTEGER
DIM StartMn AS INTEGER
DIM StartSc AS INTEGER
DIM DiffHr AS INTEGER
DIM DiffMn AS INTEGER
DIM DiffSc AS INTEGER
'get current time
CurTime = TIME$
'Parse out Hours, Minutes and Seconds into int's
CurHr = VAL(MID$(CurTime,1,2))
CurMn = VAL(MID$(CurTime,4,2))
CurSc = VAL(MID$(CurTime,7,2))
StartHr = VAL(MID$(StartTime,1,2))
StartMn = VAL(MID$(StartTime,4,2))
StartSc = VAL(MID$(StartTime,7,2))
'Calculates diff of start seconds to current Seconds
IF CurSc>=StartSc THEN
DiffSc = CurSc-StartSc
ELSE
DiffSc = (CurSc+60)-StartSc
END IF
'Calculate diff of start minutes to current minutes
IF CurMn>=StartMn THEN
DiffMn = CurMn-StartMn
ELSE
DiffMn = (CurMn+60)-StartMn
END IF
'NOTE: Not sure how to mix minutes and seconds, not to mention hours
'Display results for now
PRINT "Current = "+TRIM$(STR$(CurHR))+":"+TRIM$(STR$(CurMN))+":"+TRIM$(STR$(CurSC))
PRINT "Start = "+TRIM$(STR$(StartHR))+":"+TRIM$(STR$(StartMN))+":"+TRIM$(STR$(StartSC))
PRINT "Diffrence = "+TRIM$(STR$(DiffHR))+":"+TRIM$(STR$(DiffMN))+":"+TRIM$(STR$(DiffSC))
'Other stuff to come later...
END SUB
'================
'End PB Dos Code
'================
------------------
Comment