News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

calculate time

Started by n, July 10, 2007, 03:24:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

n

Hello

Many freeware makes it possible to calculate time sums and differences; add and subtract hours:minutes:seconds. But I do not like them.
I would like to have a macro who make just only one thing : add hours, minutes and seconds.

For example: 2 Hours 32 Minutes 15 Seconds + 1 Hours 45 Minutes 10 Seconds + 0 Hours 18 Minutes 37 Seconds + 3 Hours 00 Minutes 15 Seconds = 7 Hours 36 Minutes 17 Seconds

INPUT "Hours : ", H
INPUT "Minutes : ", M
INPUT "Seconds : ", S
...
...
MESSAGE, " 7 Hours 36 Minutes 17 Seconds"


Sorry for my bad English and thank you with all those which helps me

prl

#1
Maybe something along this line.

'Program: hms.d3m (hours minutes seconds adder)


Input "Hours : ", hours
Input "Minutes : ", mins
Input "Seconds : ", secs

again:

Input "Hours : ", H2
Input "Minutes : ", M2
Input "Seconds : ", S2

secs = secs + S2
mins = mins + M2
hours = hours + H2

do while secs >= 60
  secs = secs - 60
  mins = mins + 1
loop 

do while mins >= 60
  mins = mins - 60
  hours = hours + 1
loop 


precision 0
hr$ = hours
mn$ = mins
sc$ = secs
s$ = hr$ + " hours " + mn$ + " minutes  " + sc$ + " seconds"
Sys(1027) = 0
Message s$

Sys(1027) = 4 'Yes/No MessageBox style
Message "Do you want to add another time value?"
If sys(1028) = 6 then
   goto again
else
   end
endif


End



n

Exactly like that
Thank you  ::)

n

Hello prl
Still a small question.
The macro functions very well but it is necessary to introduce 0 if hours or minutes or seconds = 0.
It would be faster to type directly Enter without anything.

Test this :
0 hours 0 minutes 35 seconds + 1 hours 0 minutes 25 seconds + 0 hours 59 minutes 58 seconds

= 2 hours 00 minutes 58 seconds  ;D
with : 0 Enter 0 Enter 35 Enter 1 Enter 0 Enter 25 Enter 0 Enter 59 Enter 58 Enter

and is = 3 hours 00 minutes 58 seconds  >:(
with : Enter Enter 35 Enter 1 Enter Enter 25 Enter Enter 59 Enter 58 Enter


To calculate my working time I use a stopwatch freeware. Then with your macro I additione various sessions. What would be brilliant, it would be macro which would calculate automatically the working time (beginning, pause and end) and save it in a text file.
Is this possible to do that With d3M macro ? 

Thank You

prl


Bob P

It seems to me that a time-in and a time-out macro would be a very cool way to do this.

The time-in macro would record the date and time to a file, perhaps with the same name and location of the drawing but a different extension.

The time-out macro would look for the same date in the file and do the elapsed-time calculations.  There's should be some way to do calculations for multiple logins and logouts on the same day by putting a marker in the file.

Since I'm going on vacation, I'll let someone else write the macros (he said, laughing evilly).  8)

n

prl that seems so easy for you ... ;)
thank you 

n

some ideas :

'macro 1:

OPEN "O", 1, "C:\Workingtime.txt"
PRINT #1,sys$(7),":","Working time","ON"
CLOSE

'macro 2:
OPEN "A", 1, "C:\Workingtime.txt"
PRINT #1,sys$(7),":","Working time","OFF"
CLOSE

the date would have to be added but I do not know how to make

and especially it would be necessary that the calculation of the working time is done automatically

much too difficult to program for me ...

n

other ideas

automatically run macro 1 when DesignCAD starts, I know that that is possible

and automatically run macro 2 when DesignCAD stop (???)

n

still me  ;D

For the current date : sys$(8)

herbertjackson

I made a program that will keep track TIME.
You enter a customers name, then click a button to start Designcad.
The timer will start. When you quit Designcad, click STOP on the timer program and the timer will stop and record the time. The next time you start the program click on the customers name (you can have a list of several different customers) and the timer will start again and add the new time with the old.
You can print out the list to a printer or to the screen.

This is a typical print out.

Time report for customer name.tme

Start Date        Start Date        Start Time      End Time      Total Time
11-30-2007      20:13:56       11-30-2007        21:34:58       1: 21: 2
11-30-2007      21:41:39       11-30-2007        23:04:49       1: 23: 10
12-01-2007      14:16:41       12-01-2007        15:59:31       1: 42: 50
12-01-2007      17:42:18       12-01-2007        18:04:48       00: 22: 30
12-01-2007      19:39:32       12-01-2007        20:55:46       1: 16: 14

                              Total hours       6
                              Total minutes     5
                              Total seconds     46

This is not a BASIC CAD program, but an .exe file
If  you think you can use it then E-MAIL me at
[email protected]
I get a lot of junk mail and I delete any one that I do not know. So I

Mark Laing

Here are two macros I made for creating and maintaining a time sheet. They record start time, finish time, total drawing time, and total daily time, along with the drawing names.
Try them.
Mark

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Time In.d3m

Sys(800)=0
'from a designcad forum request
'to create a time sheet
'to enter time in a time sheet
time$ = Sys$(7)
date$ = Sys$(8)
>Save
{
}
DrawingName$ = Sys$(2)
'message "It's ", time$, ",", date$,  chr$(13), "Working on ", DrawingName$
'OPEN "A", filenumber, filename
'slash in date is not acceptable for a file name
'this changes the slashes to dashes
a$ = MID$(date$, 1, 1)    'Returns 1 characters of a$ beginning at i.

for i = 2 to len(date$)
b$ = MID$(date$, i, 1)    'Returns 1 characters of a$ beginning at i.
'message b$
if b$ = "/" then b$ = "-"
a$ = a$ + b$
'message a$
next i
newdate$ = a$
filename$ = "TimeSheet " + newdate$
'message "File Name may be ", filename$ ,
Open "a", 1, filename$
Print #1, time$, date$, "Start ", DrawingName$
Close 1

run$ = "c:\windows\notepad.exe ", filename$
run run$, 1

end




''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Time Out.d3m
Sys(800)=0
'from a designcad forum request
'to maintain a time sheet
'to enter time in a time sheet
time$ = Sys$(7)
date$ = Sys$(8)
>Save
{
}
DrawingName$ = Sys$(2)
'message "It's ", time$, ",", date$,  chr$(13), "Working on ", DrawingName$
'this changes the slashes in the date to dashes that'll save as a file name.
a$ = MID$(date$, 1, 1)    'Returns 1 characters of a$ beginning at i.
for i = 2 to len(date$)
b$ = MID$(date$, i, 1)    'Returns 1 characters of a$ beginning at i.
'message b$
if b$ = "/" then b$ = "-"
a$ = a$ + b$
'message a$
next i
newdate$ = a$
filename$ = "TimeSheet " + newdate$
'message "File Name may be ", filename$ ,

Open "i", 1, filename$
total = 0
Do While Eof(1) = 0
input #1, starttime$
'message starttime$
check$ = mid$(starttime$, 1, 4)
if check$ = "Time" then
total$ = mid$(starttime$, 19, 6)
message total$
message starttime$
t = val(total$)
total = t + total
endif
Loop


close 1
oldhours$= mid$(starttime$, 1, 2)
oldmins$ = mid$(starttime$, 4, 2)
oldsecs$ = mid$(starttime$, 7, 2)
oldtime$ = oldhours$ + "D" + oldmins$ + "M" + oldsecs$ + "S"

hours$= mid$(time$, 1, 2)
mins$ = mid$(time$, 4, 2)
secs$ = mid$(time$, 7, 2)
time2$ = hours$ + "D" + mins$ + "M" + secs$ + "S"

oldtime = val(oldtime$)
time = val(time2$)
totald = time - oldtime
total$ = totald
total = total + totald
dtotal$ = total

'message "Start Time = ", oldtime, oldtime$
'message "Finish Time = ", time, time$
'message " Time Spent = ", total$

Open "a", 1, filename$
Print #1, time$, date$, "Finish ", DrawingName$
Print #1, "Time on Drawing = ", total$
Print #1, "Total Time Today = ", dtotal$
Close 1

run$ = "c:\windows\notepad.exe ", filename$
run run$, 1
end