[comp.binaries.ibm.pc.d] Program Usage Program needed

v056ped5@ubvmsa.cc.buffalo.edu (Brian M McNamara) (10/28/90)

In article <ww7PR1w163w@turbo.atl.ga.us>, greg@turbo.atl.ga.us (Greg Montgomery) writes...
>I'm looking for a program that will monitor the amount of time that I
>spend in a program. Specifically, I need to know how many hours I spend
>in TC++ so I know how much to bill my clients. I would like it to be
>totally automated so I could just check the log file to see how much
>time I've spent in TC++. If you know of a program like this available
>anywhere, please let me know...
> 
>Greg


I am not sure whether you are looking to buy a program or for freeware or what,
but...

Most menu programs I have seen have time log options. One in particular is
LeMenu (regular for sale software, I am not sure where to get it). If I
remember correctly, LeMenu kept a log of every program run during the session
and could at any time be dumped in whole or tallied for number of uses, time
of usage, etc. This would solve your problem of tallying time. As a programmer
I find it aggravating to be running from anything but DOS though. If anyone
knows of any TSR not-a-shell programs to do the same, please post it.

Brian

mitchell@thesis1.hsch.utexas.edu (Philip Mitchel) (10/29/90)

While this isn't exactly what you asked for, it may do.  You could
always try using a timer program (such as is included with Norton
Utilities (tm etc. etc.)), and invoke your program from a batch file
that starts the timer, runs the program, then appends the program name
antime inside it to a log file.  You could eread the command line to
specify which of your clients any particul session lled to.  Hope that
helps.

Phil Mitchell  mitchell@thesis1.hsch.utexas.edu

r3jjs@VAX1.CC.UAKRON.EDU (Jeremy J Starcher) (10/29/90)

>>I'm looking for a program that will monitor the amount of time that I
>>spend in a program.


I have written a program for work that I can upload the .ASM source
code for that keeps a time log.  You need to manually start and stop
it, but it works well for us.

 
; ***** Assemble as a .COM file *****
CR      EQU     13
LF      EQU     10
W       EQU     WORD PTR
B       EQU     BYTE PTR
 
page 66,132
page
;  X:0
;
;
;
cseg    segment para public 'code'
zeno            proc  far
        assume  cs:cseg, ds:cseg, es:cseg, ss:cseg
        org     100h            ; for .COM file
;
;
;-------------------------------
; enter here on initial load
;-------------------------------
;
start:
;
        jmp     near ptr load_pgm
;
old_key		DW 00, 00
;
;-------------------------------
; enter here from int 10h
;-------------------------------
;
;---------------------- The starting code ------------------
StartTime:	DB 'Started ',0
EndTime:	DB 'Ended ',0
PrnID		DW 0			;Which printer gets the goods
Buffer:		DB 10 dup (32)
NewLine:	DB 13,10,0	;CR LF,0
;---------------------- The memory resident code -------------------
;====================== Subroutines ========================
BIN_ASCII PROC NEAR
	;On Entry --->
	;		AX	= Number to be converted
	;		BX	= Address of Buffer
	;
	;On Exit --->
	;		BX	= Address of Buffer
	;			  The buffer contains an ASCIIZ string
	;		CX	= Length of String
 
	PUSH	DX		;SAVE AFFECTED REGISTERS
	PUSH	SI
	PUSH	AX		;SAVE BINARY VALUE
	MOV	CX,6		;FILL BUFFER WITH SPACES
FILL_BUFFER:
	MOV	BYTE PTR CS:[BX],' '	;BLANK
	INC	BX
	LOOP	FILL_BUFFER
	MOV	SI,10		;GET READY TO DIVIDE BY 10
	OR	AX,AX		;IF VALUE IS NEGITIVE
	JNS	CLR_DVD
	NEG	AX		;MAKE IT POSITIVE
CLR_DVD:
	SUB	DX,DX		;CLEAR UPPER HALF OF DIVIDEND
	DIV	SI		;DIVIDE AX BY 10
	ADD	DX,'0'		;CONVERT REMAINDER TO ASCII DIGIT
	DEC	BX		;BACK UP THROUGH BUFFER
	MOV	CS:[BX],DL	;STORE THIS CHAR IN THE STRING
	INC	CX		;COUNT CONVERTED CHARACTER
	OR	AX,AX		;ALL DONE?
	JNZ	CLR_DVD		;NO. GO GET NEXT DIGIT
	POP	AX		;YES. RETRIEVE ORIGINAL VALUE
	OR	AX,AX		;WAS IT NEGITIVE?
	JNS	NO_MORE
	DEC	BX		;YES. STORE SIGN
	MOV B	CS:[BX],'-'
	INC	CX		;AND INCREASE CHARACTER COUNT
NO_MORE:
	POP	SI
	POP	DX
 
	;Turn the number into an ASCIIZ string
	PUSH	BX
	PUSH	CX
 
BA1:	INC	BX
	LOOP	BA1
 
	MOV W	CS:[BX],0
	POP	CX
	POP	BX
	RET			;RETURN TO CALLER
 
BIN_ASCII	ENDP
 
;-----------------------------------------------------------------------------
DumpString	PROC NEAR
	;On Entry ---> CS:BX Holds address of ASCIIZ string
 
	PUSH	AX
 
D1:	MOV	AL, CS:[BX]	;Get Current Character
	CMP	AL, 0		;At the end of the line?
	JE	D2		;Yes - then quit the nonsense
 
	CALL	DumpChar
 
	INC	BX		;Go on to next character
	JMP	D1		;Loop again.
 
D2:	;EnddString:
        POP     AX
        RET
DumpString	ENDP
;-----------------------------------------------------------------------------
DumpChar	PROC NEAR
	;On Entry -->   Char in AL
	;		CS:[PrnID] = Printer number (0..1)
	PUSH	AX
	PUSH	DX
 
	MOV	DX, CS:[PrnID]	;Get the printer ID Number (0 or 1)
	MOV	AH, 0		;Send One Byte To Printer
	INT	17h		;GO..
 
	POP	DX
	POP	AX
	RET
DumpChar	ENDP
;-----------------------------------------------------------------------------
DumpTime	PROC NEAR
	PUSH	AX
	PUSH	BX
	PUSH	CX
	PUSH	DX
 
	MOV	AH,02Ch		;Get Time
	INT	21h		;Get it
 
				;Time Returned in this form
				;CH	= Hour		(0..23)
				;CL	= Minutes	(0..59)
				;DH	= Seconds	(0..59)
				;DL	= Hundreds	(0..99)
				;	  These are not real hundreths of a
				;	  second since the clock cannot	
				;	  do any better than 1/20 of a second.
				;	  However, this does return an even
				;	  spread over the number range and is
				;	  OK for a random seed.
 
	PUSH	CX
 
	;Print the Hour
	PUSH	AX
	MOV	AL,CH
	MOV	AH,0
	MOV	BX, OFFSET(Buffer)
	CALL	BIN_ASCII
	CALL	DumpString
	MOV	AL,':'
	CALL	DumpChar	;Send the colon seperator
	POP	AX
 
	POP	CX	;Restore CX
	PUSH	CX	;However, we still need to hang on to it
 
	;Print the Minute
	PUSH	AX
	MOV	AL, CL
	MOV	AH, 0
	MOV	BX, OFFSET(Buffer)
	CALL	BIN_ASCII
	CMP	CX,1		;Is our output string only one char?
	JNE	T1		;No - then just print the minute
	MOV	AL, '0'		;Else - Show a preceding '0'
	CALL	DumpChar
T1:	CALL	DumpString
	POP	AX
 
	POP	CX
 
	POP	DX
	POP	CX
	POP	BX
	POP	AX
	RET
DumpTime	ENDP
 
;-----------------------------------------------------------------------------
DumpDate	PROC NEAR
	PUSH	AX
	PUSH	BX
	PUSH	CX
	PUSH	DX
 
	MOV	AH,02Ah		;Get Time
	INT	21h		;Get it
 
				;Date Returned in this form
				;DH	= Month Number	(1..12)
				;DL	= Day of Month  (1..28,29,30,31)
				;CX	= Year		(1980..2099)
				;AL	= Day of week	(0..6) Sun = 0
 
	PUSH	CX
 
	;Print the Month
	PUSH	AX
	MOV	AL,DH
	MOV	AH,0
	MOV	BX, OFFSET(Buffer)
	CALL	BIN_ASCII
	CALL	DumpString
	MOV	AL,'-'
	CALL	DumpChar	;Send the hyphen seperator
	POP	AX
 
	POP	CX	;Restore CX
	PUSH	CX	;However, we still need to hang on to it
 
	;Print day of month
	PUSH	AX
	MOV	AL,DL
	MOV	AH,0
	MOV	BX, OFFSET(Buffer)
	CALL	BIN_ASCII
	CALL	DumpString
	MOV	AL,'-'
	CALL	DumpChar	;Send the hyphen seperator
	POP	AX
 
	POP	CX	;Restore CX
	PUSH	CX	;However, we still need to hang on to it
 
	;Print the Year
	PUSH	AX
	MOV	AX, CX
	MOV	BX, OFFSET(Buffer)
	CALL	BIN_ASCII
	CALL	DumpString
	POP	AX
 
	POP	CX
 
	POP	DX
	POP	CX
	POP	BX
	POP	AX
	RET
DumpDate	ENDP
;-----------------------------------------------------------------------------
 
keyboard_int:
 
        STI
 
		CMP	AH,0
		JE	ki0
		JMP	dword ptr cs:old_key
 
ki0:		PUSHF			;Simulate Org INT call
		call	dword ptr cs:old_key
		PUSH	BX		;We modify BX
		MOV	BX, 0		;Clear it out for out check later
 
		CMP	AL, 0		;Check if we have a extended Key
		JNE	kidone		;No- don't bother with the rest
 
		CMP	AH,078h		;ALT 1?
		JNE	TryAlt2		;No, try an ALT 2
		LEA	BX, StartTime
		JMP	SendOut
 
TryAlt2:	CMP	AH, 079h	;ALT 2?
		JNE	kidone		;No - give up
		LEA	BX, EndTime
		JMP	SendOut
 
SendOut:	CALL	DumpString	;Print "Start" or "End"
		CALL	DumpTime	;Print the time
		MOV	AL,' '		;Print a space seperator
		CALL	DumpChar	;	  "
		CALL	DumpDate	;Print the Date
		
		LEA	BX, NewLine	;Print a CR/LF
		CALL	DumpString	;     "
		MOV	AX, 0000h	;Return NO KEY to the calling prg
		
kidone:		POP	BX
		CLI
		IRET
 
 
;
end_core:
;
;------ Text needed be 'load_prg'
;
install_msg	DB 'IMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;',CR,LF
		DB ':            TIME KEEPER            :',CR,LF
		DB 'GDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD6',CR,LF
		DB ':  ALT 1                 Start      :',CR,LF
		DB ':  ALT 2                 End        :',CR,LF
		DB 'GDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD6',CR,LF
		DB ':       By: Jeremy J Starcher       :',CR,LF
		DB 'HMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM<',CR,LF
		DB '$'
;
finish_msg      DB '          .. Installed //',CR,LF,'$'
 
Usage:		DB CR,LF,CR,LF,CR,LF
		DB 'Use the following format:',CR,LF
		DB CR,LF
		DB 'timekeep /x',CR,LF
		DB CR,LF
		DB 'where x = printer number (1 or 2)',CR,LF,'$'
 
;
retry_msg       db   13,10,'No Action:  Invalid Command Line',13,10,7,'$'
 
 
;-------------------------------
; enter here to load program
;-------------------------------
;
load_pgm:
;
;
 
;--- Print the welcome message
	lea	dx,install_msg		; get message
	mov	ah,9h			; for print fn
	int	21h			; print message
 
	;Search for command line parameter
	MOV	CL, CS:[80h]	;Parameter length
	CMP	CL, 0
	JE	NoGood		;Can't use no parameters
 
	MOV	BX, 81h		;Start of parameters
I1:	MOV	AL, CS:[BX]	;Get a character
	CMP	AL, '/'		;Is it our flag char?
	JE	GetPrnNum	;Yes - get the printer number
	INC	BX		;Advance to the next character
	LOOP	I1
	JMP	NoGood		;Can't find it, too bad.
 
GetPrnNum:
	INC	BX		;Move onto the the next character
	MOV	AL, CS:[BX]	;Get the ASCII value ..
	SUB	AL, '0'		;..By subtraction
	MOV	AH,0		;Clear the high order byte
	CMP	AX, 1
	JB	NoGood		;Reject if below One
	CMP	AX, 2
 
	DEC	AX		;Correct AX (Printers start at 0)
	MOV	CS:[PrnID],AX	;Save the printer ID
	JMP	Good
 
NoGood:
	MOV	AH,9		;Print a string
	LEA	DX, Usage	;Show them the usage
	INT	21h		;DO IT!
	MOV	AH,0		;End Normally
	INT	21h		;NOW!
 
Good:
 
; set keyboard interrupt
;
	push	es		; save
	mov	ax,3516h	; to get vector
	int	21h		; get vector
	mov	old_key[0],bx	; store offset
	mov	old_key[2],es	; store segment
	pop	es		; restore
	mov	ax,2516h	; to set keyboard vector
	lea	dx,keyboard_int	; get offset; ds OK
	int	21h		; set vector
;
; print messages; terminate and stay resident
;
	lea	dx,finish_msg	; get termination
	mov	ah,9h		; for print fn
	int	21h		; print ternination
	lea	ax,end_core	; last address in core
	add	ax,2Fh		; make bumper
	mov	cl,4		; for shift
	shr	ax,cl		; convert to paras
	mov	bx,ax		; no. paras to keep
	mov	dx,ax		; same
	mov	ah,4Ah		; for setblock
	int	21h		; do setblock
	mov	ax,3100h	; for keep; no exit code
	int	21h		; exit and stay resident
;
zeno		endp
cseg		ends
	end	start
 


-----------------------------------------------------------------------------

Please, no major flames about the code.  It was written in a hurry (I had
only an hour and a half or so).

It should assemble under MASM, although I use the A86 assembler myself.

-- 
--------------------------+---------------------------------------------------
Jeremy J Starcher         !  No programmer programs in LOGO after reaching
r3jjs@vax1.cc.uakron.edu  !  age 14...
r3jjs@akronvm.bitnet      !

ee5391aa@hydra.unm.edu (Duke McMullan n5gax) (10/29/90)

In article <ww7PR1w163w@turbo.atl.ga.us> greg@turbo.atl.ga.us writes:
>I'm looking for a program that will monitor the amount of time that I
>spend in a program. Specifically, I need to know how many hours I spend
>in TC++ so I know how much to bill my clients. ....

One thought occurs to me...if you get 4dos (a _much_improved_ and _almost_
100%_compatible_ replacement for command.com, you could set up an alias like:

	alias tc `timer >> logfile ^ tc++ ^ timer >> logfile`

Assuming that Turbo C++ is invoked by the call "tc++", this would create
a logfile giving the time entered, time exited and elapsed time. You'd
likely want to write a small c, basic or awk program to manipulate the log-
file data.

4dos is shareware...if you can't get it by ftp (try a local BBS, by all 
means), ewrite me and I'll email you a uuencoded version.

					Best o' luck,
						d


--
    Most self-described "pacifists" are not pacific; they simply assume
      false colors. When the wind changes, they hoist the Jolly Roger.
					-- Robert A. Heinlein
   Duke McMullan n5gax nss13429r phon505-255-4642 ee5391aa@hydra.unm.edu

mju@mudos.ann-arbor.mi.us (Marc Unangst) (10/29/90)

ee5391aa@hydra.unm.edu (Duke McMullan n5gax) writes:
> 	alias tc `timer >> logfile ^ tc++ ^ timer >> logfile`
> 
> Assuming that Turbo C++ is invoked by the call "tc++", this would create
> a logfile giving the time entered, time exited and elapsed time. You'd

Why bother with all this?  If you're going to muck around with
aliases, you might as well do it right...

alias tc `log /w c:\tc\tc.log "Turbo C++ started"^*tc^log /w
	c:\tc\tc.log "Turbo C++ stopped"`

(all on one line, natch).  If you didn't care about the special
messages, you could just do "log /w c:\tc\tc.log on" and figure out
when TC++ was started or stopped by grepping for "tc".

I doubt TC++ is started with the command "tc++", since "+" is illegal
in MS-DOS filenames.  More likely than not, it's just "tc" (which
raises incompatibility issues with regular Turbo C, but...).  The "*"
in front of the "tc" in the alias prevents 4DOS from expanding it
further, creating an infinite alias loop.

--
Marc Unangst               |
mju@mudos.ann-arbor.mi.us  | "Bus error: passengers dumped"
...!umich!leebai!mudos!mju | 

nx00699@dsac.dla.mil (Gene McManus) (10/29/90)

>> In article <ww7PR1w163w@turbo.atl.ga.us>, greg@turbo.atl.ga.us (Greg Montgomery) writes...
>>I'm looking for a program that will monitor the amount of time that I
>>spend in a program. Specifically, I need to know how many hours I spend
>>in TC++ so I know how much to bill my clients. I would like it to be
>>totally automated so I could just check the log file to see how much
>>time I've spent in TC++. If you know of a program like this available
>>anywhere, please let me know...
>> 
>>Greg
> 
> 
> I am not sure whether you are looking to buy a program or for freeware or what,
> but...
> 
> Most menu programs I have seen have time log options. 
	[ ... ]
> Brian

The KYSS! menu system/system organizer likewise has a logging
facility. It's available from c.b.i.p, simet20 and chyde. KYSS! is
supplied as shareware.

Gene



=======================================================================
Gene McManus @ DLA Systems Automation Center, DSAC-X
               Columbus, OH 43215 (614) 238-9403,    Autovon 850-
Internet:      gmcmanus@dsac.dla.mil  (131.78.1.1)
UUCP:          {uunet!gould,cbosgd!osu-cis}!dsacg1!gmcmanus

  #define PI  3.141592653589793 /* makes changes easy should
				   							the value of PI change */

The views expressed are my own, not those of the Agency, or the DoD
=======================================================================