Ok, here is a solution, It doesnt take into account of changing from the last day of one month, and the start of another.
Also, the same for Year Changes, it only takes into account Consecutive days in the same month.
Also The "CostEstimate.txt" File, will create itself in the Mach3 main directory.
If you want it to create some where else, you will need to change the path to where you want it to drop.
NOTE: The intermediate file "Time File" will create and destroy itself with the complete running of the G-Code part file.
What this does is create a file, called: "CostEstimate.txt" This text shows Start Time and Date, End Time and Date, and total elapsed time on that part for: Days, Hours, Minutes, Seconds
This is TRUE elapsed time while on that part, so if you pause your G-Code for 1 hour then come back and hit cycle start, then it will add that hour to the program.
Things you will have to do for Setup:
1). You will have to change your computers System time to 24 hour clock for the time calculation to work.
2). You will need to put the Macro "M1002" at least one line down from the start of your code, and before your part starts. (the line above it can be a comment), or Init G codes.
3). You will need to put the Macro "M1003" right before your last line, which should be a M30.
Other Things:
1). You will need to run the file completly from start to finish, since these to Macros are linked to create and destroy it intermediates.
2). Once you run a part, you will have to Copy and MOVE that file, out of that area, and Print it off, If you run that same part, or some other part, the next run will delete that file, and recreate it at the end, with the new times from start to finish.
Here is the Start Timer, Date, Macro: M1002.m1s
'****************************
'M1002.m1s Store Start time point
Open "CostEstimate.txt" For Output As #2
Close #2
Kill "CostEstimate.txt"
Dim StartTime As String
Dim StartDate As String
StartTime = Time(Now)
StartDate = Date()
Open "TimeFile" For Output As #1 ' Open to write file.
Write #1, StartTime
Write #1, StartDate
Close #1
Code "G4 P0.5"
While IsMoving
Wend
Sec = Second(StartTime)
Min = Minute(StartTime)
Hr = Hour(StartTime)
Dy = Day(StartDate)
SetVar(100,Sec)
SetVar(101,Min)
SetVar(102,Hr)
SetVar(103,Dy)
'*****************************
Here is the End Timer, Date, Macro: M1003.m1s
'*****************************
'M1003.m1s Get End Time point and calc, and post file
Dim StartTime As String
Dim StartDate As String
Dim EndTime As String
Dim EndDate As String
Dim File As String
Dim Days
EndTime = Time(Now)
EndDate = Date()
SecEnd = Second(EndTime)
MinEnd = Minute(EndTime)
HrEnd = Hour(EndTime)
DyEnd = Day(EndDate)
SecStart = GetVar(100)
MinStart = GetVar(101)
HrStart = GetVar(102)
DyStart = GetVar(103)
File = FileName()
Open "TimeFile" For Input As #1 ' Open file.
Line Input #1, TextLine ' Read line into variable.
StartTime = TextLine ' get start time.
Line Input #1, TextLine ' Read line into variable.
StartDate = TextLine ' get start date.
Close #1 ' Close file.
Code "G4 P0.5"
While IsMoving
Wend
If HrEnd<HrStart Then
Hr=((24-HrStart)+(24-(24-HrEnd)))
Else
Hr=(HrEnd-HrStart)
End If
If MinEnd<MinStart Then
Min=((60-MinStart)+(60-(60-MinEnd)))
Else
Min=(MinEnd-MinStart)
End If
If SecEnd<SecStart Then
Sec=((60-SecStart)+(60-(60-SecEnd)))
Else
Sec=(SecEnd-SecStart)
End If
If (DyEnd-DyStart)= 0 Then
Days = 0
End If
If ((DyEnd-DyStart)=1) And (HrEnd<HrStart) Then
Days = 0
End If
If ((DyEnd-DyStart)=1) And (HrEnd>HrStart) Then
Days = 1
End If
If ((DyEnd-DyStart)>1) Then
Days = (DyEnd-DyStart)
End If
Kill "TimeFile"
Open "CostEstimate.txt" For Output As #2 ' Open to write file.
Write #2, "File Name: " & File
Write #2, "Start Time: " & StartTime, "Start Date: " & StartDate
Write #2, "End Time: " & EndTime, "End Date: " & EndDate
Write #2, "Total Time: " & " Days: " & Days & " Hours: " & Hr & " Mins: " & Min & " Secs: " & Sec
Close #2
Code "G4 P0.5"
While IsMoving
Wend
'*******************************************
'Hope this helps you
'Scott