home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- ** **
- ** GBRoute Plus ARexx Script **
- ** **
- ** (c) 1991 Complex Computers **
- ** **
- ** Name : gbrmetric.rexx **
- ** **
- ** Description : Calculates a route with distances in Kilometres **
- ** and prompts for cost in pence/litre **
- ** **
- *****************************************************************************/
-
- TEMPFILE = 'ram:$$temp' /* This can be any valid filename */
- blank = ''
-
- say 'GBRoute Plus ARexx Metric Demonstration'
-
- options prompt 'Enter Start: ';
- /* get starting place */
- pull start
-
- options prompt 'Enter Destination: ';
- /* get destination place */
- pull dest
-
- /* and cost in pence/litre */
- options prompt 'Cost/Litre (pence): ';
-
- pull cost
- /* send commands to GBRoute */
- options results /* neeed this if we are to get */
- /* returned values */
- address 'GBR' /* address host */
-
- 'from' start /* give GBR start and destination */
- p1 = result
- 'to' dest
- p2 = result
-
- cost = cost * 4.5461 /* convert cost from pence/litre to */
- /* pence/gallon
-
- 'pcost' cost /* send GBR converted cost */
-
- say 'Calculating journey from: 'p1' to: 'p2
-
- 'go' /* calculate route */
- /* Check for no route */
- if result == 'RESULT' then do
- /* output journey to file */
- '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)
-
- /* here we cut each line into 3 parts*/
- /* the middle part contatining the */
- /* distances is converted to */
- /* kilometres */
- part1 = substr(st,1,64)
-
- dist = strip( substr(st, 65, 5)) /* extract distance and strip spaces */
- /* convert and round up to nearest km*/
- dist = ( dist * 1.60934 + 0.5) % 1
-
- part2 = substr(st, 70, 7)
- /* justify right into a 5 char string*/
- dist = insert(dist, blank, 5 - length(dist))
-
- say part1''dist''part2 /* print with all 3 parts joined */
-
- end
- /* close the file */
- close(file)
-
- address command /* call dos 'delete' to remove */
- delete TEMPFILE /* temporary file */
-
- address 'GBR' /* back to GBR */
-
- 'dist'
- d = (result * 1.60934 + 0.5) % 1 /* convert total distance to km */
- 'time'
- t = result
- 'cost'
- c = trunc(result/100,2) /* pounds and pence */
-
- say 'This journey costs £'c' and takes 't'mins covering 'd' Km'
- end
- /* Route not possible */
- else say result
- exit
-