home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / opus / v5 / icon_update / iconupdate.lha / IconUpdate / Modules / IconUpdate.dopus5 next >
Text File  |  1997-06-23  |  7KB  |  259 lines

  1. /*
  2. $VER: IconUpdate.dopus5 1.0 (23.6.97) © by Maik "BLiZZeR" Schreiber [FREEWARE]
  3.  
  4. Contact: BLiZZeR@dame.de
  5.          http://home.pages.de/~bZ
  6. */
  7.  
  8.  
  9.  
  10. /* This is the path to the "IconUpdate" program that comes along with
  11. ** the MagicWB package. You can specify options after the path.
  12. */
  13. IconUpdateProgram = "IconUpdate TCSDW"
  14.  
  15.  
  16. /* Replace the word "TRUE" with anything else but "TRUE"
  17. ** (maybe "FALSE" ;) if you don't want to check for ImageDrawers
  18. ** (although you should think twice before deactivating this).
  19. */
  20. CheckForImageDrawers = TRUE
  21.  
  22.  
  23. /* This is the path to the "Icon" program which is used for checking
  24. ** for ImageDrawers.
  25. */
  26. IconProgram = "Icon"
  27.  
  28.  
  29.  
  30. /* ========== PLEASE DO NOT CHANGE ANYTHING BELOW THIS LINE ========== */
  31.  
  32. Signal ON SYNTAX
  33. Signal ON BREAK_C
  34.  
  35. Options RESULTS
  36. Options FAILAT 21
  37.  
  38. LF                  = "0a"x
  39. ImageDrawer         = "ImageDrawer, don't remove this entry"
  40. hutti_ist_eine_nase = "»»»» Icon by Martin Huttenloher ««««"
  41.  
  42. Parse ARG DOpusPort function source dummy dest .
  43.  
  44. Address VALUE DOpusPort
  45.  
  46. If (function = "init") Then
  47.   Call init
  48. Else If (function = "IconUpdate") Then
  49.   Call IconUpdate(source, dest)
  50. Else If (function = "AddImageDrawer") Then
  51.   Call AddImageDrawer(source)
  52. Else If (function = "RemImageDrawer") Then
  53.   Call RemImageDrawer(source)
  54. Else If (function = "XENCopyright") Then
  55.   Call XENCopyright(source)
  56. Call Quit
  57.  
  58.  
  59. init: Procedure
  60. DOpus Command '"IconUpdate" Program "IconUpdate" Desc "Updates icons'' information"'
  61. DOpus Command '"AddImageDrawer" Program "IconUpdate" Desc "Converts drawers to ImageDrawers"'
  62. DOpus Command '"RemImageDrawer" Program "IconUpdate" Desc "Converts ImageDrawers to drawers"'
  63. DOpus Command '"XENCopyright" Program "IconUpdate" Desc "Adds XEN''s copyright to icons"'
  64. Return
  65.  
  66.  
  67. IconUpdate: Procedure EXPOSE LF ImageDrawer IconProgram IconUpdateProgram
  68. Parse ARG source , dest
  69. Lister Query source NumSelEntries
  70. If (RESULT < 1) Then
  71.   Return
  72. Lister Query dest NumSelEntries
  73. entries = RESULT
  74. If (entries < 1) Then
  75.   Return
  76. Lister Set source Busy 1
  77. Lister Set dest Busy 1
  78. Lister Query source Path
  79. sourcepath = Strip(RESULT, "B", '"')
  80. Lister Query dest Path
  81. destpath = Strip(RESULT, "B", '"')
  82. Lister Query source FirstSel
  83. icon = sourcepath || Strip(RESULT, "B", '"')
  84. selcount = 0
  85. Do dummy = 1 To entries
  86.   Lister Query dest FirstSel
  87.   file = Strip(RESULT, "B", '"')
  88.   Lister Query dest Entry '"' || file || '"'
  89.   If (SubStr(RESULT, Length(file) + 2, 1) ~= "-") Then
  90.   Do
  91.     doit = TRUE
  92.     If (CheckForImageDrawers = TRUE) Then
  93.     Do
  94.       Address COMMAND IconProgram || ' "' || destpath || file || '" "' || ImageDrawer || '" FIND'
  95.       If (RC = 0) Then
  96.       Do
  97.         DOpus Request '"The file' || LF || destpath || file || LF || 'seems to be an ImageDrawer.' || LF || 'Replace the image anyway?" Yes|No'
  98.         If (RC = 0) Then
  99.           doit = FALSE
  100.       End
  101.     End
  102.     If (doit = TRUE) Then
  103.     Do
  104.       Address COMMAND IconUpdateProgram || ' "' || icon || '" "' || destpath || file || '"'
  105.       reread = TRUE
  106.     End
  107.   End
  108.   Else
  109.   Do
  110.     selentries.selcount = file
  111.     selcount = selcount + 1
  112.   End
  113.   Lister Select dest '"' || file || '"' 0
  114.   Lister Refresh dest
  115. End
  116. Do dummy = 0 To (selcount - 1)
  117.   Lister Select dest '"' || selentries.dummy || '"' 1
  118. End
  119. Lister Set source Busy 0
  120. Lister Set dest Busy 0
  121. Lister Query source FirstSel
  122. Lister Select source RESULT 0
  123. Lister Refresh source
  124. If (reread = TRUE) Then
  125.   Lister Read dest '"' || destpath || '"'
  126. Return
  127.  
  128.  
  129. AddImageDrawer: Procedure EXPOSE LF ImageDrawer IconProgram
  130. Parse ARG dest
  131. Lister Query dest NumSelEntries
  132. entries = RESULT
  133. if (entries < 1) Then
  134.   Return
  135. Lister Set dest Busy 1
  136. Lister Query dest Path
  137. destpath = Strip(RESULT, "B", '"')
  138. selcount = 0
  139. Do dummy = 1 To entries
  140.   Lister Query dest FirstSel
  141.   file = Strip(RESULT, "B", '"')
  142.   Lister Query dest Entry '"' || file '"'
  143.   If (SubStr(RESULT, Length(file) + 2, 1) ~= "-") Then
  144.   Do
  145.     Address COMMAND IconProgram || ' "' || destpath || file || '" "' || ImageDrawer || '" FIND'
  146.     If (RC ~= 0) Then
  147.     Do
  148.       Address COMMAND IconProgram || ' "' || destpath || file || '" "' || ImageDrawer || '" ADD'
  149.       reread = TRUE
  150.     End
  151.   End
  152.   Else
  153.   Do
  154.     selentries.selcount = file
  155.     selcount = selcount + 1
  156.   End
  157.   Lister Select dest '"' || file || '"' 0
  158.   Lister Refresh dest
  159. End
  160. Do dummy = 0 To (selcount - 1)
  161.   Lister Select dest '"' || selentries.dummy || '"' 1
  162. End
  163. Lister Set dest Busy 0
  164. If (reread = TRUE) Then
  165.   Lister Read dest '"' || destpath || '"'
  166. Return
  167.  
  168.  
  169. RemImageDrawer: Procedure EXPOSE ImageDrawer IconProgram
  170. Parse ARG dest
  171. Lister Query dest NumSelEntries
  172. entries = RESULT
  173. if (entries < 1) Then
  174.   Return
  175. Lister Set dest Busy 1
  176. Lister Query dest Path
  177. destpath = Strip(RESULT, "B", '"')
  178. selcount = 0
  179. Do dummy = 1 To entries
  180.   Lister Query dest FirstSel
  181.   file = Strip(RESULT, "B", '"')
  182.   Lister Query dest Entry '"' || file '"'
  183.   If (SubStr(RESULT, Length(file) + 2, 1) ~= "-") Then
  184.   Do
  185.     Address COMMAND IconProgram || ' "' || destpath || file || '" "' || ImageDrawer || '" FIND'
  186.     If (RC = 0) Then
  187.     Do
  188.       Address COMMAND IconProgram || ' "' || destpath || file || '" "' || ImageDrawer || '" REMOVE'
  189.       reread = TRUE
  190.     End
  191.   End
  192.   Else
  193.   Do
  194.     selentries.selcount = file
  195.     selcount = selcount + 1
  196.   End
  197.   Lister Select dest '"' || file || '"' 0
  198.   Lister Refresh dest
  199. End
  200. Do dummy = 0 To (selcount - 1)
  201.   Lister Select dest '"' || selentries.dummy || '"' 1
  202. End
  203. Lister Set dest Busy 0
  204. If (reread = TRUE) Then
  205.   Lister Read dest '"' || destpath || '"'
  206. Return
  207.  
  208.  
  209. XENCopyright: Procedure EXPOSE IconProgram hutti_ist_eine_nase
  210. Parse ARG dest
  211. Lister Query dest NumSelEntries
  212. entries = RESULT
  213. if (entries < 1) Then
  214.   Return
  215. Lister Set dest Busy 1
  216. Lister Query dest Path
  217. destpath = Strip(RESULT, "B", '"')
  218. selcount = 0
  219. Do dummy = 1 To entries
  220.   Lister Query dest FirstSel
  221.   file = Strip(RESULT, "B", '"')
  222.   Lister Query dest Entry '"' || file '"'
  223.   If (SubStr(RESULT, Length(file) + 2, 1) ~= "-") Then
  224.   Do
  225.     Address COMMAND IconProgram || ' "' || destpath || file || '" "' || hutti_ist_eine_nase || '" FIND'
  226.     If (RC ~= 0) Then
  227.     Do
  228.       Address COMMAND IconProgram || ' "' || destpath || file || '" "' || hutti_ist_eine_nase || '" ADD'
  229.       reread = TRUE
  230.     End
  231.   End
  232.   Else
  233.   Do
  234.     selentries.selcount = file
  235.     selcount = selcount + 1
  236.   End
  237.   Lister Select dest '"' || file || '"' 0
  238.   Lister Refresh dest
  239. End
  240. Do dummy = 0 To (selcount - 1)
  241.   Lister Select dest '"' || selentries.dummy || '"' 1
  242. End
  243. Lister Set dest Busy 0
  244. If (reread = TRUE) Then
  245.   Lister Read dest '"' || destpath || '"'
  246. Return
  247.  
  248.  
  249. SYNTAX:
  250. BREAK_C:
  251. Address VALUE DOpusPort
  252. DOpus Request '"Error in ARexx script' || LF || 'IconUpdate.dopus5,' || LF || 'Line ' || SIGL || ':' || LF || LF || ErrorText(RC) || '"'
  253. Call Quit
  254.  
  255.  
  256. Quit:
  257. Exit
  258.  
  259.