home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Internet / Mail / Yam2URL.lha / yam2url / YAM2URL.rexx < prev   
OS/2 REXX Batch file  |  1998-03-31  |  9KB  |  174 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                                  YAM2URL                                   */
  4. /*                                                                            */
  5. /*                    for use with YAM 2.0 by Marcel Beck                     */
  6. /*                                                                            */
  7. /*                      Copyright ⌐1997 by Dick Whiting                       */
  8. /*                                                                            */
  9. /*----------------------------------------------------------------------------*/
  10. /*  This will display a URL using your browser, start the browser if needed,  */
  11. /*  uniconify it if already running. It can also be used to view HTML mime    */
  12. /*  attachments.                                                              */
  13. /*                                                                            */
  14. /*  To use this for double-clicking and going to a URL:                       */
  15. /*     edit the three variables in this script for your configuration         */
  16. /*     YAM Config->ARexx->When double-clicking an URL (last entry in list)    */
  17. /*     set the type to ARexx (cycle gadget)                                   */
  18. /*     set the script string to 'Yam:Rexx/YAM2URL.rexx' (assuming it's here)  */
  19. /*     set open console OFF                                                   */
  20. /*     set wait for termination OFF                                           */
  21. /*     SAVE settings                                                          */
  22. /*     you can now double-click on a URL and go to it.                        */
  23. /*                                                                            */
  24. /*  To use this for displaying included HTML attachments:                     */
  25. /*     YAM Config->Read->MimeViewers                                          */
  26. /*     if there is NOT a type for 'text/html' create a NEW one                */
  27. /*     set viewer to: 'sys:rexxc/rx Yam:Rexx/YAM2URL.rexx %s'                 */
  28. /*     SAVE settings                                                          */
  29. /*     you can now display HTML attachments by selecting 'Display' from the   */
  30. /*        YAM read window and choosing the HTML attachment from the list.     */
  31. /*                                                                            */
  32. /*----------------------------------------------------------------------------*/
  33. /* !!! You need to edit the four values hideyam,browser,runbr, and newwindow. */
  34. /*----------------------------------------------------------------------------*/
  35. /* NOTES:                                                                     */
  36. /*                                                                            */
  37. /* IF YOU HAVE REASSIGNED THE YAM TEMPORARY DIRECTORY USE THIS FORM:          */
  38. /* (This value is specified on the Config->Mixed page.)                       */
  39. /*                                                                            */
  40. /* set viewer to: 'sys:rexxc/rx Yam:Rexx/YAM2URL.rexx file:///%s'             */
  41. /*                                                                            */
  42. /* Also, the '%s' you specify for *MUST* be lowercase. This applies to ALL    */
  43. /* mime prefs, not just the one for Yam2URL. Uppercase '%S' will NOT pass     */
  44. /* the correct information to your mime viewers.                              */
  45. /*                                                                            */
  46. /*----------------------------------------------------------------------------*/
  47. /* If you have the rexxtricks.library installed then the browser screen will  */
  48. /* pop to the front correctly.                                                */
  49. /* You can find this on Aminet/util/rexx/RexxTricks_386.lha                   */
  50. /*                                                                            */
  51. /*----------------------------------------------------------------------------*/
  52. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  53. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  54. /*                                                                            */
  55. /*                                                                            */
  56. /*HOWEVER, if you do find a use for it: I homeschool my kids and they would   */
  57. /*love a postcard from where EVER you live. Instant Geography Lesson;)        */
  58. /*                                                                            */
  59. /*POSTCARDS:    Dick Whiting                                                  */
  60. /*              28590 S. Beavercreek Rd.                                      */
  61. /*              Mulino, Oregon 97042                                          */
  62. /*              USA                                                           */
  63. /*                                                                            */
  64. /*                                                                            */
  65. /*----------------------------------------------------------------------------*/
  66. /*                                                                            */
  67. /*                     Dick Whiting <dwhiting@europa.com>                     */
  68. /*                             31 March 1998                                  */
  69. /*                                                                            */
  70. /******************************************************************************/
  71. /*
  72. $VER: 1.4 Copyright ⌐1998 by Dick Whiting
  73. $AUTHOR: Dick Whiting
  74. $DESCRIPTION: Goto URL for Yam2.x
  75. */
  76.  
  77. parse arg url
  78. options results
  79.  
  80. /******************************************************************************/
  81. /*         !!! EDIT THESE !!! EDIT THESE !!! EDIT THESE !!!                   */
  82. /******************************************************************************/
  83. browser='IBROWSE'                      /* IBROWSE, VOYAGER, or AWEB only.     */
  84. runbr='C:RUN >NIL: TEMP:IBROWSE/IBROWSE' /* this is your browser-- keep quotes*/
  85. newwindow=0                            /* set this to 1 for a NEW window.     */
  86. hideyam=0         /* set this to 1 to iconify YAM prior to opening the browser*/
  87.  
  88.  
  89. /******************************************************************************/
  90. /*  See if it's an html mime attachment.                                      */
  91. /******************************************************************************/
  92. htmltext=0
  93. if upper(left(url,9))='T:YAMMSG-' then do
  94.    htmltext=1
  95.    Address Command 'Copy 'url 'T:yam2url.html QUIET'
  96.    url='file:///T:yam2url.html'
  97. end
  98.  
  99. /******************************************************************************/
  100. /* These should work, but you can change them if not.                         */
  101. /******************************************************************************/
  102. browser=strip(upper(browser))
  103. select
  104.    when browser='IBROWSE' then do
  105.       brscreen='IBROWSE'               /* CASE SENSITIVE browser screen name  */
  106.       portname='IBROWSE'               /* ARexx portname of your browser      */
  107.       portcmd1='GOTOURL "'url'"'       /* for IB, open URL in current window  */  
  108.       portcmd2='NEWWINDOW "'url'"'     /* open URL in a NEW window            */
  109.       showcmd='SHOW'                   /* MUI uniconify command               */
  110.    end
  111.    when browser='VOYAGER' then do
  112.       brscreen='VOYAGER'               /* CASE SENSITIVE browser screen name  */
  113.       portname='VOYAGER'               /* ARexx portname of your browser      */
  114.       portcmd1='OPENURL "'url'"'       /* for IB, open URL in current window  */  
  115.       portcmd2='OPENURL "'url'" NEWWIN'  /* open URL in a NEW window        */
  116.       showcmd='SHOW'                   /* MUI uniconify command               */
  117.    end
  118.    when browser='AWEB' then do   
  119.       brscreen='AWEB.1'                /* CASE SENSITIVE browser screen name  */
  120.       portname='AWEB.1'                /* ARexx portname of your browser      */
  121.       portcmd1='OPEN "'url'"'          /* for IB, open URL in current window  */  
  122.       portcmd2='NEW "'url'"'           /* is there a one for NEW WINDOW ???   */
  123.       showcmd='SHOW'                   /* no idea if this works:)             */
  124.    end
  125.    otherwise do
  126.      Address YAM 'REQUEST "Invalid browser name in script" "OK"'
  127.      exit
  128.    end
  129. end
  130.  
  131. tricks=0
  132.  
  133. if ~show('L','rexxsupport.library') then do
  134.    addlib('rexxsupport.library',0,-30)
  135. end
  136.  
  137. if ~show('L','rexxtricks.library') then do
  138.    if exists('LIBS:rexxtricks.library') then do
  139.       tricks=addlib('rexxtricks.library',0,-30)
  140.    end
  141. end
  142. else tricks=1
  143.  
  144. if ~show(p,portname) then do
  145.   Address Command runbr '"'url'"'
  146.   do 5 while ~show(p,portname)
  147.      Address Command 'SYS:REXXC/WAITFORPORT 'portname
  148.   end
  149.   if rc=5 then do 
  150.      Address YAM 'SHOW'
  151.      Address YAM 'REQUEST "Could not find "' portname '" port" "OK"'
  152.      exit
  153.   end
  154. end
  155. else do
  156.   interpret 'Address' portname showcmd
  157.   if newwindow then do
  158.      interpret 'Address' portname "'"portcmd2"'"
  159.   end
  160.   else do
  161.      interpret 'Address' portname "'"portcmd1"'"
  162.   end
  163.   if tricks then do
  164.      foo=PUBSCREENTOFRONT(brscreen)
  165.   end
  166. end
  167.  
  168. if hideyam then do
  169.   Address Command 'C:run >nil: sys:rexxc/rx "Address YAM HIDE"'
  170. end
  171.  
  172. exit
  173.  
  174.