home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- ** **
- ** GBRoute Plus ARexx Script **
- ** **
- ** (c) 1991 Complex Computers **
- ** **
- ** Name : gbrarrive.rexx **
- ** **
- ** Description : Given an arrival time, calculates the departure time **
- ** **
- *****************************************************************************/
-
-
- TEMPFILE = 'ram:$$temp' /* This can be any valid filename */
-
- say 'GBRoute Plus ARexx Demonstration'
-
- options prompt 'Enter Start: ';
- /* get starting place */
- pull start
-
- options prompt 'Enter Destination: ';
- /* get destination place */
- pull dest
-
- /* and the proposed arrival time */
- options prompt 'Arrival Time (format 00:00 - 24hr clock): ';
-
- pull arrive
-
- options results /* neeed this if we are to get */
- /* returned values */
- address 'GBR'
-
- 'from' start /* give GBR start and destination */
- p1 = result
- 'to' dest
- p2 = result
-
- 'go' /* calculate the time for the route */
-
- 'time'
- t = result
-
- start = calc_start(arrive,t) /* calc_start determines the */
- /* departure time, given the arrival */
- /* time and the time for the journey */
-
- /* tell the user the departure time */
- say 'If you want to arrive at 'p2' for 'arrive','
- say 'then you should leave 'p1' at 'start
-
- /* ask to see the route ? */
- options prompt 'Do you want to see the route? (Y/N): '
- pull ans
- /* if N then exit */
- if compare(left(ans,1),'N') == 0 then exit
-
- 'dtime' start /* give GBR our calculated departure */
- /* time */
- 'go' /* and calculate the route... */
-
- say 'Calculating journey from: 'p1' to: 'p2
- 'file' TEMPFILE
- /* open file */
- open(file, TEMPFILE, read)
- /* loop until the end of the file */
- do while eof(file)=0
- /* read a line from file */
- st = readln(file)
- /* and print each line */
- say st
- end
- /* close the file */
- close(file)
-
- address command /* call dos 'delete' to remove the */
- /* temporary file */
- delete TEMPFILE
-
- address 'GBR' /* back to GBR */
-
- 'dist' /* get the distance, time and cost */
- d = result
- 'time'
- t = result
- 'cost'
- c = trunc(result/100,2) /* fix to pounds.pence */
-
- say 'This journey costs £'c' and takes 't' minutes covering 'd' miles'
-
- exit
-
-
- /* calc_start */
- calc_start:
- arg arrv,time /* arrv, is the arrival time */
- /* time, is the journey time */
-
- /* ignore > 24 hours */
- if time > (24*60) then time = time // (24*60)
-
- hrstrt = substr(arrv,1,2) /* get hours and mins from xx:xx */
- minstrt = substr(arrv,4,2)
-
- rt = hrstrt*60 + minstrt /* convert to minutes */
-
- nt = rt - time /* subtract journey time from */
- /* arrival time */
- if nt < 0 then nt = nt + 24*60
-
- hrs = nt % 60 /* convert back to hours and mins */
- /* checking for 0's */
- if hrs < 10 then hrs = '0'hrs
- if hrs == 0 then hrs = '00'
- mins = nt // 60
- if mins < 10 then mins = '0'mins
- if mins == 0 then mins = '00'
-
- return hrs':'mins /* return the departure time */
-
-