Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Massive Packet
#6
Moneo:  Right!, my fault for not reading the whole, long explanation!  Here us my code for this problem.  Any questions, TIA?

Code:
'TimePast looks at the first data statemet and takes that number of
'subsequent pairs of data as military time in hours and minutes, then obtains
'and prints to screen the time elapsed from the first time to the second.
'If the first time is larger than the second one, assume the second time
'occurs the next day, by adding 24 hours to it.

CLS
'Read first data
READ PairNums

'Read data pairs and report time elapsed; if less pairs available than
'PairNums, report the error
ON ERROR GOTO PairErr:

FOR pair = 1 TO PairNums
  READ h1, m1: t1 = h1 * 60 + m1
  READ h2, m2: t2 = h2 * 60 + m2
  IF t1 < t2 THEN
    totMins = t2 - t1
  ELSE
    totMins = t2 + 24 * 60 - t1
  END IF
  hrs = INT(totMins / 60)
  min = totMins - hrs * 60
  PRINT hrs; "hours"; min; "minutes"
NEXT pair

END

PairErr:
  PRINT " Not enough time pairs!"
  END

'data statements:
DATA 2
DATA 09,00,17,30
DATA 18,25,09,00
DATA 18 25 09 00

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply


Messages In This Thread
My Massive Packet - by Tia - 02-27-2008, 06:29 AM
Re: My Massive Packet - by Tia - 02-29-2008, 04:36 AM
Re: My Massive Packet - by Tia - 03-01-2008, 02:19 AM
Re: My Massive Packet - by Ralph - 03-28-2008, 07:59 PM
Re: My Massive Packet - by Moneo - 03-29-2008, 12:05 AM
Re: My Massive Packet - by Ralph - 03-29-2008, 02:42 AM
Re: My Massive Packet - by Moneo - 03-29-2008, 05:54 AM
Re: My Massive Packet - by Ralph - 03-31-2008, 02:32 AM
Re: My Massive Packet - by Moneo - 03-31-2008, 06:59 AM
Re: My Massive Packet - by Ralph - 03-31-2008, 07:47 AM
Re: My Massive Packet - by Tia - 04-02-2008, 06:12 AM
Re: My Massive Packet - by Ralph - 04-02-2008, 06:23 AM
Re: My Massive Packet - by Tia - 04-03-2008, 04:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)