10 !list usage summary for UAS
15 ! This program can be used as a starting point for a more
16 !sophisticated billing system
20 map1 usrnam,s,8
30 map1 etime,s,6
40 map1 ctime,s,6
50 map1 hhmmss,s,6
60
70 map1 hdr,s,80,"User name Elapsed CPU Cost"
80 map1 fmt,s,80,"\234567\ \234567\ \234567\ $$####.##"
90
100 print "Printing ... Please wait"
110 open #99,"dsk0:usage.tim[1,2]",input
120 input #99,ecost,ccost
130 close #99
140 open #1,"dsk0:usage[1,2]",input
150 open #2,"usage.prt",output
160 input #1,dat$: dat$=dat$[1,2]+"/"+dat$[3,4]+"/"+dat$[5,6]
170 print #2,"System time usage summary for "dat$
180 print #2
190 print #2,hdr
195
200 read'next:
210 input #1,usrnam,etime,ctime
220 if eof(1)=0 then call process: goto read'next
230 print #2,using fmt,"","","",grandtot/100
240 close #1
250 close #2
260 xcall spool,"usage.prt"
270 end
280
290 !process this user
300 process:
310 et$ = etime[1,2]+":"+etime[3,4]+":"+etime[5,6]
320 ct$ = ctime[1,2]+":"+ctime[3,4]+":"+ctime[5,6]
330 call cost
340 if total=0 then print #2,usrnam: return
350 print #2 using fmt,usrnam,et$,ct$,total/100
360 grandtot = grandtot + total
370 return
380
390 !Compute the cost of the time used
400 !values used:
410 ! ecost - elapsed time cost in cents/second
420 ! ccost - CPU time cost in cents/second
430 ! total - final result in cents
440 cost:
450 hhmmss = etime: call getsec
460 total = seconds * ecost
470 hhmmss = ctime: call getsec
480 total = total + seconds * ccost
490 return
500
510 !get value of time - convert HHMMSS to SECONDS
520 getsec:
530 seconds = hhmmss[1,2]*3600 + hhmmss[3,4]*60 + hhmmss[5,6]
540 return