home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / bobsapps.zip / makeurl.cmd < prev   
OS/2 REXX Batch file  |  2000-02-26  |  3KB  |  102 lines

  1. /* MAKEURL.CMD Makes a WpURL object. Reads the URL from a file, a messy intermediate step to get
  2. *  around my inability to parse '//' correctly when passed to a REXX command as a parameter.
  3. *  We get the URL object title, and the folder to put it in, from the user. 
  4. *  I am assuming that the Web Sites folder is under the desktop directory. I am also assuming that
  5. *  the environment variable OS2_SHELL is set and that it refers to a program on the boot drive.
  6. *  Note: If you want another URL folder COPY an existing one and rename it.
  7. *  Parameters passed ..
  8. *  URLfile - the name of the file containing the URL
  9. *  Version 1.0 29-09-1999 Bob McLellan Created
  10. */
  11. /* Set up the program */
  12. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  13. Call SysLoadFuncs
  14. parse arg URLfile
  15. URL=linein(URLfile)
  16.  
  17. /* Do the work */
  18. Say "Bob's URL creator"
  19. Title=titledialog()
  20. Folder=folderdialog()
  21. Call CreateObject
  22. Exit
  23.  
  24. CreateObject:
  25. rc = SysCreateObject('WPUrl', Title, Folder, 'DEFAULTVIEW=CONTENTS;URL='||URL||';;OBJECTID=<'||Title||'>', 'Fail' )
  26. If rc <> 1 Then
  27.  Say ' > failed to create ['Title'] at location ['Folder']'
  28. return
  29.  
  30. titledialog: procedure
  31. /* Get title for URL object. */
  32. Say 'Please supply the title for the URL' 
  33. Parse Pull Title
  34.  
  35. return Title
  36.  
  37. folderdialog: procedure
  38. /* Get folder to hold object. */
  39. boot=left(value('OS2_SHELL',,'OS2ENVIRONMENT'),3)                  /* Get the boot drive  & \ */  
  40. /* If your Web URL folders are not in the desktop, change the next line. Watch out for duplicates, as in the ARCHIVES */
  41. rc=SysFileTree(boot||'desktop\web sites','wsfolder','sdo')         /* Look for Web Sites folder */
  42. if rc<>0 then
  43. do
  44.  say 'System problem while looking for Web Sites folder'
  45.  exit
  46. end
  47.  
  48. if wsfolder.0<>1 then
  49. do
  50.  say 'Either none or many Web Sites folders. Cannot proceed.'
  51.  exit
  52. end
  53.  
  54. rc=SysFileTree(wsfolder.1||'\*','folders','sdo')        /* Look for url folders in Web Sites folder */
  55. if rc<>0 then
  56. do
  57.  say 'System problem while looking in Web Sites folder'
  58.  exit
  59. end
  60. if folders.0=0 then
  61. do
  62.  say 'No folders found in Web Sites folder. Cannot proceed.'
  63.  exit
  64. end
  65.  
  66. do forever
  67.  folderno=SelectFolder()              /* Show the folder names to the user and ask for a selection */
  68.  if verify(folderno,'0123456789')<>0 | folderno>folder.0 then
  69.  do
  70.   say 'The response contained something other than digits. Please only enter digits, or'
  71.   say 'The response was a number higher than listed. Please only use a listed number.'
  72.   say 'Do you want to try again Y/N'
  73.   pull reply
  74.   if translate(reply)<>'Y' then exit
  75.  end
  76.  else leave
  77. end
  78.  
  79. thefolder=folders.folderno
  80.  
  81. return thefolder
  82.  
  83. SelectFolder:
  84. Say 'Please enter the NUMBER of the folder to hold the URL'
  85. x=0
  86. outline=''
  87. blank='               '                             /* Create a 15 character field */
  88.  
  89. do i=1 to folders.0+1
  90.  x=x+1
  91.  field=overlay(filespec('Name',folders.i),blank,,15) /* Get just the name from the full filespec */
  92.  outline=outline i field
  93.  if x=3 | i=folders.0 then
  94.  do
  95.   say outline
  96.   outline=''
  97.   x=0
  98.  end
  99. end
  100. Say 'Please enter the NUMBER of the folder to hold the URL' 
  101. Parse Pull folderno
  102. return folderno