Other web Sites
Harmonica Blues  Harmonica Amps
Harmonica Links Harmonica Pages
Archives Home
Years
 · 1992
 · 1993
 · 1994
 · 1995
 · 1996
 · 1997
 · 1998
 · 1999
 · 2000
 · 2001
 · 2002
 · 2003
 
Web HarpL
Ebay Searches:
Amps:
Microphones:
Effects:
Harmonicas and Gear:
Harmonica Music and Instruction:

 

 

Harp-L Archives

[Previous Message] [Next Message]

[Start of Thread] [End of Thread]

From: Jack Ely
Date: Mon, 22 Jul 1996 16:30:04 -0400 (EDT)
Subject: Add hours and minutes

Do you find adding up hours and minutes to be a pain in the ASCII?...

Have you ever tried to add up the total play time on a TAPE, LP RECORD
or CD? Or - tried to figure out how many songs you can get on side 1 of
a 60 minute cassette without cutting off in the middle of a song. Or -
figured out if all the songs will fit on tape if you add 5 seconds
between each so you can use your AMS feature on your tape deck. Or -
how about adding up a gig list to fill out an hour show? -- I'm sure we
all have - but how many of you find it time consuming (pun intended).
Some of you may know the trick - but for those who don't, here is an
explanation of the logic; Followed by a little BASIC program which will
help you do the chore.

The logic is:
o You have to continuously check the accumulated minutes and seconds
as you are adding your times.

o Whenever SECONDS are 60 or greater you add 40

o Whenever MINUTES are 60 or greater you add 40

Example: You have acumulated 00:00:58 (58 seconds) so far. You add 20
seconds (now you have 78 seconds). Add 40 to seconds and your total
is now 118. Or 1:18 (1 min. 18 seconds). adding 40 rolls seconds to
minutes and keeps accumulated seconds correct.
You have to do the same thing with minutes. (Minutes > 59 add 40)

This logic will work in your mind (not mine), pencil and paper, a hand
calculator (yuk), or on your computer in the language of your choice. I
chose BASIC because it was handy and I knew enough about it to be
dangerous. Plus a lot of you have access to a BASIC interpreter.

If you can look at the seconds, minutes and hours portion of your
counter, then you could get by with one 6 position counter by
redefining it into 3 logical sections (hh:mm:ss). -- in some languages
this would be simple. Not true in BASIC (Well who knows about today, I
learned BASIC about 30 years ago - so don't flame my code).

So, in my BASIC language example I had to approach the problem a little
differently since I did not know how to look at seconds only and
minutes only - I simply used three separate counters. It didn't matter
that I could not set the length of each counter to two positions - my
code eliminates the need for that - as I used a little different logic.
If SECONDS >59 add 1 to MINUTES and subtract 60 from SECONDS. ~and~
If MINUTES >59 add 1 to HOURS and subtract 60 from MINUTES.

So this is getting too long already? Believe me - the code is shorter
than the explanation.

Feel free to copy and use this program. If you don't have access to
BASIC, the above information should give you the logic for you to write
it in the language of your choice.

Jack Ely

OH, harmonica content??? This only works with harmonica music. :-)
=======================================================================
100 REM **************************************************
105 REM ***HHMM - Program to add Hours & Minutes *
110 rem * *
115 REM * by Jack Ely - Freely distributable; "FREEWARE" *
120 REM *** Compute total play time for an album, etc. *
140 REM * *
150 REM * VARIABLES USED IN THIS PROGRAM *
160 REM * *
170 REM * CUTS = Number of tracks/repetitions *
180 REM * REMAIN = Tracks remaining *
182 REM * HOURS = Hours in album or play list *
184 REM * MINUTES = Minutes in song *
186 REM * SECONDS = Seconds in song *
250 REM **************************************************
260 REM * ENTER number of CUTS, MINUTES, & SECONDS when *
265 REM * prompted. There is no prompt for HOURS. HOURS *
270 REM * will be computed, if necessary, into the total *
275 REM * ** ENTER 99 AT MINUTES PROMPT TO EXIT EARLY ** *
280 REM * *
285 REM * To compute an unknown number of cuts, simply *
290 REM * enter a large number in "CUTS" and then enter *
292 REM * 99 at the MINUTES prompt when you are done. *
296 REM **************************************************
300 PRINT "ENTER NUMBER OF CUTS/TRACKS"
310 INPUT CUTS
315 REMAIN = CUTS
320 PRINT "NUMBER OF CUTS/TRACKS"; CUTS
400 FOR LOOP_COUNT = 1 TO CUTS
405 PRINT "ENTER MINUTES";
407 INPUT MINUTES
412 REM *** LET USER BAIL OUT EARLY ***
415 IF (MINUTES = 99) GO TO 600
417 REM *** CAN'T ENTER MORE THAN 60 ***
419 IF (MINUTES > 60) THEN
PRINT "OUT OF RANGE!!!"
GO TO 405
END IF
420 PRINT "ENTER SECONDS";
425 INPUT SECONDS
435 REM *** ADD HRS, MIN, SEC TO TOTALS ***
445 TOTAL_HRS=TOTAL_HRS + HOURS
450 TOTAL_MIN=TOTAL_MIN + MINUTES
455 TOTAL_SEC=TOTAL_SEC + SECONDS
465 REM *** ROLL SECONDS TO MINUTES ***
475 IF (TOTAL_SEC > 59) THEN TOTAL_MIN=TOTAL_MIN +1
480 IF (TOTAL_SEC > 59) THEN TOTAL_SEC=TOTAL_SEC - 60
490 REM *** ROLL MINUTES TO HOURS ***
500 IF (TOTAL_MIN > 59) THEN TOTAL_HRS = TOTAL_HRS + 1
510 IF (TOTAL_MIN > 59) THEN TOTAL_MIN=TOTAL_MIN - 60
535 REM *** HOW MANY ENTRIES REMAIN ***
545 REMAIN = REMAIN - 1
550 PRINT "THERE ARE"; REMAIN; "CUTS REMAINING"
551 REM
552 REM *** DISPLAY ACCUMULATED TIME ***
555 PRINT "ACCUMULATED TIME = ";TOTAL_HRS;":";TOTAL_MIN;":";TOTAL_SEC
560 NEXT LOOP_COUNT
600 PRINT
610 PRINT "*** TOTAL TIME *** = ";TOTAL_HRS;":";TOTAL_MIN;":";TOTAL_SEC
640 END
=======================================================================