home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / opus / v5 / datestamp / datestamp1.dopus5 < prev   
Text File  |  1977-12-31  |  4KB  |  140 lines

  1. /*
  2. Short:    A DateStamp that won't stop for DOpus5.5+ (In theory)
  3. Uploader: Dave Clarke <4wd@connexus.apana.org.au>
  4. Author:   Dave Clarke <4wd@connexus.apana.org.au>
  5. Type:     biz/dopus/
  6.  
  7. $VER: DateStamp.dopus5 1.2 (14.8.96)
  8.  
  9. This ARexx module will, in theory, DateStamp files, avoiding those that are
  10. 'locked' without stopping and bringing up a requester.
  11.  
  12. I stress 'In Theory', because I didn't have any way to 'lock' a file and
  13. couldn't test it :)  But it did work on my system _without_ any locked files!
  14. (And someone has just told me it works on their system _with_ locked files :)
  15.  
  16.  
  17. Installation:
  18.  
  19. Copy it into your DOpus5:Modules directory, this will add the command
  20. 'DateStamp1' to the internal command set.
  21.  
  22. Then create a button, menuitem, etc, as follows:
  23.  
  24. Function    Command    DateStamp1 [VIEW/K]
  25.  
  26. The VIEW keyword specifies that the result file will be shown at the end.
  27.  
  28. There _must_ be a source lister present, and you can just select files and
  29. directories.
  30.  
  31.  
  32. History:
  33.  
  34. V1.0 - It exists, therefore it is.   Only works for files at the moment.
  35. V1.1 - Now handles files in directories, but doesn't actually datestamp the
  36.        directory :)
  37. V1.2 - Now datestamps the directories. Put the VIEW keyword back.
  38.        NOTE: Doesn't check to see if the directory is locked.
  39.  
  40. */
  41.  
  42. parse arg portname function source dest arguments
  43. address value portname
  44. options results
  45.  
  46. if function = 'init' then do
  47.     dopus command "DateStamp1" program "DateStamp1" desc "'Set the date for files/dirs'" template "VIEW/K" 'source'
  48.     exit
  49.     end
  50.  
  51. parse upper var arguments view
  52. if view = 'VIEW' then view_flag = 1
  53. lister query source path
  54. path = strip(result,B,'"')
  55. if left(path,8) = 'Ram Disk' then do
  56.   parse upper var path ':' subdirs
  57.   path = 'RAM:'subdirs
  58.   end
  59. FixPath(path)
  60.  
  61. oldpath = pragma('d',path)
  62. lister query source selfiles stem files.
  63. lister query source seldirs stem dirs.
  64. if files.count = 0 | files.count = '' | files.count = 'FILES.COUNT' then nofile = 1
  65. if dirs.count = 0 | dirs.count = '' | dirs.count = 'DIRS.COUNT' then nodirs = 1
  66. if nofile = 1 & nodirs = 1 then call ERROR 'Nothing selected!'
  67.  
  68. tdate = date('E')
  69. ntime = time('N')
  70. newtime = translate(tdate,'-','/')||" "||ntime
  71.  
  72. dopus getstring '"Input date to stamp files with:" 20 "'newtime'" Okay|Cancel'
  73. newtime = result
  74. if newtime = '' | newtime = 'RESULT' then exit
  75.  
  76. call open('outfile','T:Date.results','W')
  77. i = 0
  78. do while i < files.count
  79.   lister select source files.i off
  80.   lister refresh source full
  81.   if ~open('FILE',files.i,'R') then
  82.     call writeln('outfile',files.i)
  83.   else
  84.     call close('FILE')
  85.     address command 'SetDate 'files.i newtime
  86.   i = i + 1
  87. end
  88.  
  89. path = pragma('d',oldpath)
  90. FixPath(path)
  91. i = 0
  92. do while i < dirs.count
  93.   lister select source dirs.i off
  94.   lister refresh source full
  95.   address command 'SetDate 'path||dirs.i'/ 'newtime
  96.   address command 'list 'path||dirs.i' all files lformat "%p%n" >T:DS.temp'
  97.   address command 'list 'path||dirs.i' all dirs lformat "%p%n %l" >>T:DS.temp'
  98.   if open('infile','T:DS.temp','r') then
  99.     do
  100.       do while ~eof('infile')
  101.         thefile = readln('infile')
  102.         if word(thefile,2) ~= 'Dir' then
  103.           if ~open('FILE',thefile,'R') then
  104.             call writeln('outfile',thefile)
  105.           else do
  106.             call close('FILE')
  107.             address command 'SetDate 'thefile newtime
  108.             end
  109.         else do
  110.           thedir = word(thefile,1)
  111.           FixPath(thedir)
  112.           address command 'SetDate 'thedir newtime
  113.           end
  114.       end
  115.       call close('infile')
  116.       call delete('T:DS.temp')
  117.     end
  118.   i = i + 1
  119. end
  120.  
  121. call close('outfile')
  122.  
  123. if view_flag = 1 then
  124.   'dopus read delete T:Date.results'
  125. else
  126.   call delete('T:Date.results')
  127.  
  128. exit
  129.  
  130. FixPath:
  131. tpath = arg(1)
  132. if index(tpath,':') = 0 then tpath = tpath':'
  133. else if (right(tpath,1) ~= '/') & (right(tpath,1) ~= ':') then tpath = tpath'/'
  134. return tpath
  135.  
  136. ERROR:
  137. parse arg error
  138. dopus request "'"error"'" "OK"
  139. exit
  140.