home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Database / GBROUTE1,03PLUS.DMS / in.adf / ARexx / GBRVERBOSE.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1991-09-12  |  4.3 KB  |  104 lines

  1. /*****************************************************************************
  2. **                                                                          **
  3. **                       GBRoute Plus ARexx Script                          **
  4. **                                                                          **
  5. **                       (c) 1991 Complex Computers                         **
  6. **                                                                          **
  7. **  Name : gbrconsole.rexx                                                  **
  8. **                                                                          **
  9. **  Description : Calculates a route and displays it in 'English(?)'        **
  10. **                                                                          **
  11. *****************************************************************************/
  12.  
  13. TEMPFILE = 'ram:$$temp'                /* This can be any valid filename    */
  14.  
  15. say 'GBRoute Plus ARexx Verbose Demonstration'
  16.  
  17. options prompt 'Enter Start: '; 
  18.                                        /* get starting place                */
  19. pull start
  20.  
  21. options prompt 'Enter Destination: '; 
  22.                                        /* get destination place             */
  23. pull dest
  24.  
  25. options prompt 'Via: (or Enter)'; 
  26.                                        /* get optional via                  */
  27. pull via
  28. options results                        /* neeed this if we are to get       */
  29.                                        /* returned values                   */
  30. address 'GBR'                          /* address host                      */
  31.  
  32. 'from' start                           /* send GBR from, to and via         */
  33. p1 = result
  34. 'to' dest
  35. p2 = result
  36. 'via1' via
  37. v1 = result
  38.  
  39. say 'Calculating journey from: 'p1' to: 'p2 ' via: 'v1
  40.  
  41. 'go'                                   /* calculate route                   */
  42.                                        /* Check for no route                */
  43. if result == 'RESULT' then do
  44.                                        /* output journey to file            */
  45.    'file' TEMPFILE
  46.                                        /* open file                         */
  47.    open(file, TEMPFILE, read)
  48.    say ''
  49.    say 'From 'p1
  50.                                        /* loop until the end of the file    */
  51.    do while eof(file)==0
  52.                                        /* read a line from file             */
  53.       st = readln(file)
  54.                                        /* and print it                      */
  55.                                        /* get direction (strip spaces) and  */
  56.                                        /* convert to string                 */
  57.               
  58.       st1 = direction(strip(substr(st,24,6),'B'))
  59.                                        /* get road                          */
  60.       st2 = strip(substr(st,30,8),'B')
  61.                                        /* get intermediate destination      */
  62.         st3 = strip(substr(st,67,3),'B')
  63.  
  64.       st4 = strip(substr(st,38,23),'B')
  65.                                        /* and make up our new string        */
  66.         say 'Head' st1 'along the' st2 'for' st3 'miles until you arrive at' st4
  67.  
  68.    end
  69.                                        /* close the file                    */
  70.    close(file)
  71.  
  72.    address command                     /* call dos 'delete'                 */
  73.    delete TEMPFILE                     /* to remove the temporary file      */
  74.  
  75.    address 'GBR'                       /* back to GBR                       */
  76.  
  77.    'dist'                              /* get time, distance and cost       */
  78.    d = result
  79.    'time'
  80.    t = result
  81.    'cost'
  82.    c = trunc(result/100,2)             /* pounds.pence                      */
  83.    say ''
  84.    say 'This journey costs £'c' and takes 't' mins covering 'd' miles'
  85.    end
  86.                                        /* Route not possible                */
  87. else say result
  88. exit
  89.  
  90. direction:                             /* returns direction as a string     */
  91. arg dir
  92. select 
  93.    when dir == 'N' then str = 'north'
  94.    when dir == 'S' then str = 'south'
  95.    when dir == 'E' then str = 'east'
  96.    when dir == 'W' then str = 'west'
  97.    when dir == 'NE' then str = 'north east'
  98.    when dir == 'NW' then str = 'north west'
  99.    when dir == 'SE' then str = 'south east'
  100.    when dir == 'SW' then str = 'south west'
  101.     otherwise str = 'into another dimension'
  102.    end
  103. return str
  104.