home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / wequickl.zip / wequickl.cmd next >
OS/2 REXX Batch file  |  1995-06-05  |  6KB  |  129 lines

  1. /* 
  2. program: wequickl.cmd
  3. type:    REXXSAA-OS/2
  4. purpose: read WebExplorer's quicklist entries and generate WPS-URL-objects
  5. version: 1.0
  6. date:    1995-06-05
  7.  
  8. usage:   wequickl
  9.          ... generates WPS-URL-objects from WE-quicklist in explore.ini
  10. author:  Rony G. Flatscher, Wirtschaftsuniversitaet/Vienna
  11.  
  12. standard disclaimer:
  13.  
  14. All rights reserved, copyrighted 1995, no guarantee that it works without
  15. errors, etc. etc.
  16.  
  17. donated to the public domain granted that you are not charging anything
  18. (money etc.) for it and derivates based upon it, as you did not write it,
  19. etc. if that holds you may bundle it with commercial programs too
  20. */
  21.  
  22. /* check whether OS/2's RexxUtil functions are loaded, if not, load them      */
  23. IF RxFuncQuery('SysLoadFuncs') THEN
  24. DO
  25.     /* load the RexxUtil-load-function                                        */
  26.     CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  27.     /* load all the Sys* utilities via "SysLoadFuncs"                         */
  28.     CALL SysLoadFuncs
  29. END
  30.                                              /* get full path for explore.ini */
  31. explore_ini = VALUE("ETC", , "OS2ENVIRONMENT") || "\explore.ini"
  32.  
  33. IF STREAM(explore_ini, "C", "QUERY EXISTS") = "" THEN
  34.    CALL error explore_ini": WebExplorer INI-file does not exist !"
  35.  
  36. /* get quicklist entries (titles and URLs)                                    */
  37.  
  38. i = 0                                           /* counter for array index    */
  39. quicklist_found = 0                             /* boolean, false             */
  40. quicklist.0 = 0                                 /* indicate no items in array */
  41. url_next    = 0                                 /* indicate if URL expected   */
  42.  
  43. CALL STREAM explore_ini, "C", "OPEN READ"       /* open file for reading only */
  44. DO WHILE CHARS(explore_ini) > 0                 /* as long as lines left      */
  45.    line = LINEIN(explore_ini)                   /* read line                  */
  46.  
  47.    IF LEFT(line, 1) = "[" THEN                  /* new section found          */
  48.    DO
  49.       IF \quicklist_found THEN                  /* quicklist section ?        */
  50.       DO
  51.          IF TRANSLATE(line) = "[QUICKLIST]" THEN  /* is it the quicklist part?*/
  52.             quicklist_found = 1
  53.          ITERATE                                /* jump to top, read next line*/
  54.       END
  55.       ELSE                                      /* quicklist section is over  */
  56.          LEAVE
  57.    END
  58.  
  59.    IF \quicklist_found THEN ITERATE             /* skip line                  */
  60.  
  61.    IF \url_next THEN                            /* title in hand              */
  62.    DO
  63.       i = i + 1                                 /* new entry, increase index  */
  64.       PARSE VAR line "quicklist= " title        /* parse URL itself           */
  65.       quicklist.i.eTitle = title                /* save title of URL          */
  66.    END
  67.    ELSE
  68.       quicklist.i.eURL   = line                 /* save URL                   */
  69.  
  70.    url_next = \url_next                         /* switch boolean value       */
  71. END
  72.  
  73. quicklist.0 = MAX(0, i - 1)                     /* save # of items in array   */
  74. CALL STREAM explore_ini, "C", "CLOSE"           /* close input file           */
  75.  
  76. IF quicklist.0 = 0 THEN
  77.    CALL error explore_ini || ": no quicklist items found!"
  78.  
  79. /* create folder to contain the URLs ******************************************/
  80. web_folder_id = "<RGF WEB QUICKLIST>"           /* Object ID for WEB folder   */
  81.  
  82. ok = SysCreateObject(,
  83.       "WPFolder",,                              /* Object type                */
  84.       "WEB Quicklist Folder",,                  /* Title                      */
  85.       "<WP_DESKTOP>",,                          /* Location                   */
  86.       "OBJECTID=" || web_folder_id || ";",,     /* object ID                  */
  87.       "F")                                      /* fail, if exists            */
  88.  
  89. SAY right("", 3) "WEB Quicklist folder - creation status:" feedback_message(ok)
  90.  
  91.                                              /* set flowed and mini icon view */
  92. ok = SysSetObjectData(web_folder_id, "ICONVIEW=FLOWED,MINI;")
  93. SAY right("", 3) "SysSetObjectData() status:" feedback_message(ok)
  94. SAY
  95.  
  96. /* create WE-objects, if they don't exist yet in top folder *******************/
  97. DO i = quicklist.0 TO 1 BY -1                   /* loop over array            */
  98.    SAY right(i,3) quicklist.i.eTitle            /* show index, URL-title      */
  99.    SAY right("", 3) quicklist.i.eURL            /* show URL                   */
  100.  
  101.    ok = SysCreateObject(,
  102.               "WebExplorer_Url",,               /* Object type                */
  103.               quicklist.i.eTitle,,              /* Title                      */
  104.               web_folder_id,,                   /* Location                   */
  105.               "LOCATOR=" || quicklist.i.eURL,,  /* URL                        */
  106.               "F")                              /* fail, if exists            */
  107.  
  108.    SAY right("", 3) "creation status:" feedback_message(ok) /* show status    */
  109. END 
  110.  
  111. SAY
  112. SAY "total of" quicklist.0 "quicklist entries processed."
  113.  
  114. EXIT
  115.  
  116. /*
  117.    little procedure, to tell whether creation was successfully, 
  118.    expects boolean (0 = false, 1 = true)
  119. */
  120. FEEDBACK_MESSAGE: PROCEDURE
  121.    IF ARG(1) THEN RETURN "successful."
  122.              ELSE RETURN "*** NOT succesful *** (one reason: maybe it exists ?)"
  123. /*
  124.    procedure to tell error and exit with a negative return code
  125. */
  126. ERROR:
  127.    SAY "ERROR:" ARG(1) "aborting ..."
  128.    EXIT -1
  129.