Commodore PET User Manual page 296

Table of Contents

Advertisement

5 PRINT"::FEAL TIME":PRINT:PRINT;
10
~T=TI
15 T$=TIME$
20 H=INT(J/21600)
30 IF H<>0 THEN
3=3-H~21600
40 M=INT(3/3600)
50 IF M<>0 THEN
3=3-M~3600
61:::1 S=INT<3/60)
70 H$=RIGHT$(STR$(H),2)
80 M$=RIGHT$(STR$(M),2)
g~
S$=RIGHT$(STR$(S),2)
100 PRIt-lT"H; t'1: S; ".; H$.; " :".; t'1$.; ": "; S$., "TIt'1E$; ".; T$
110 PRINT"i:8:mtll".; : GOT010
Statements 70 through 90 convert the numeric answers into proper string form
for tidy printing. Statement 100 prints both the real time calculated from the pro-
gram, and TIME$, the real time calculated automatically by the PET. Notice that
the result is the same in both cases.
To get an idea of jiffy speed and the conversion from the jiffy to the standard
clock. type the following program into your PET. This program prints our the run-
ning time of both TIME$ and TIME (TI):
5 REM **RUNNING CLOCKS**
10 PRINT u::FEAL TIME: u;PRINT:PRINT u3IFFY TIME:
U
20 FOR 1=1 TO 235959
30 PRINT u
l:8";
TAB( 13); TIME$
40 FOR 3=1 TO 60 STEP 2
50 PR 1NTul:iIlIOO" ; TAB( 12); TI
60 NEXT J
70 NEXT 1
The FOR... NEXT loop to print TIME (TI) is nested inside the FOR... NEXT loop
in TIME$ because multiple jiffies are incremented and printed for each increment
and print of a second shown in TIME$.
20 FOR 1=1 TO 235959
30 PRINT u
l:8";
TAB( 13); TIME$
40 FOR 3=1 TO 60 STEP 2
50 PR 1NT
"l:i1l1OO
U
;
TAB ( 12) .; TI
60 NEXT 3
70 NEXT 1
The FOR. .. NEXT loop for TIME increments by STEP 2 (every two jiffies) for
two reasons: 1) the printing of 60 jiffies a second is too fast to read. and 2) the
printing of each jiffy takes longer than its incrementations; this would delay the
loop. so the printing of TIME$ is slower than it should be. By incrementing and
printing every other jiffy we can minimize this delay problem. Run this program
and vou will see that jiffies increment to 60 within each second. Run this program
without STEP 2 in line 40 and see the time delay when printing TIME$.
REAL TIME:
006704
3IFFY TIME; 25500
283

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents