home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- ** **
- ** GBRoute Plus ARexx Script **
- ** **
- ** (c) 1991 Complex Computers **
- ** **
- ** Name : gbrconsole.rexx **
- ** **
- ** Description : Calculates a route and displays it in 'English(?)' **
- ** **
- *****************************************************************************/
-
- TEMPFILE = 'ram:$$temp' /* This can be any valid filename */
-
- say 'GBRoute Plus ARexx Verbose Demonstration'
-
- options prompt 'Enter Start: ';
- /* get starting place */
- pull start
-
- options prompt 'Enter Destination: ';
- /* get destination place */
- pull dest
-
- options prompt 'Via: (or Enter)';
- /* get optional via */
- pull via
- options results /* neeed this if we are to get */
- /* returned values */
- address 'GBR' /* address host */
-
- 'from' start /* send GBR from, to and via */
- p1 = result
- 'to' dest
- p2 = result
- 'via1' via
- v1 = result
-
- say 'Calculating journey from: 'p1' to: 'p2 ' via: 'v1
-
- 'go' /* calculate route */
- /* Check for no route */
- if result == 'RESULT' then do
- /* output journey to file */
- 'file' TEMPFILE
- /* open file */
- open(file, TEMPFILE, read)
- say ''
- say 'From 'p1
- /* loop until the end of the file */
- do while eof(file)==0
- /* read a line from file */
- st = readln(file)
- /* and print it */
- /* get direction (strip spaces) and */
- /* convert to string */
-
- st1 = direction(strip(substr(st,24,6),'B'))
- /* get road */
- st2 = strip(substr(st,30,8),'B')
- /* get intermediate destination */
- st3 = strip(substr(st,67,3),'B')
-
- st4 = strip(substr(st,38,23),'B')
- /* and make up our new string */
- say 'Head' st1 'along the' st2 'for' st3 'miles until you arrive at' st4
-
- end
- /* close the file */
- close(file)
-
- address command /* call dos 'delete' */
- delete TEMPFILE /* to remove the temporary file */
-
- address 'GBR' /* back to GBR */
-
- 'dist' /* get time, distance and cost */
- d = result
- 'time'
- t = result
- 'cost'
- c = trunc(result/100,2) /* pounds.pence */
- say ''
- say 'This journey costs £'c' and takes 't' mins covering 'd' miles'
- end
- /* Route not possible */
- else say result
- exit
-
- direction: /* returns direction as a string */
- arg dir
- select
- when dir == 'N' then str = 'north'
- when dir == 'S' then str = 'south'
- when dir == 'E' then str = 'east'
- when dir == 'W' then str = 'west'
- when dir == 'NE' then str = 'north east'
- when dir == 'NW' then str = 'north west'
- when dir == 'SE' then str = 'south east'
- when dir == 'SW' then str = 'south west'
- otherwise str = 'into another dimension'
- end
- return str
-