home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / opus / v4 / versioncopy / vcopy.dopus.source < prev    next >
Text File  |  1977-12-31  |  3KB  |  108 lines

  1. /**********************************************
  2.    VersionCopy v2.0
  3.    Checking version numbers before copying.
  4.    For use with directoryopus.
  5.  
  6.    $VER: VersionCopy 2.0 (9.8.94)
  7.  **********************************************/
  8.  
  9. options results
  10. lf='0a'x;chk=1
  11. status 3;nr=result
  12. status 9 nr;turns=result
  13.  
  14. do turns
  15.    call routine
  16. end
  17. return
  18.  
  19. Routine:
  20.  
  21. /****************
  22.   Get sourcename
  23.  ****************/
  24.   getnextselected;filename=result
  25.   status 3;winnr=result
  26.   status 13 winnr;source=result
  27.  
  28. /**********************
  29.   Get destination path
  30.  **********************/
  31.   if winnr=1 then winnr2=0
  32.   if winnr=0 then winnr2=1
  33.   status 13 winnr2;dest=result
  34.  
  35. /***************************
  36.   Check for duplicate files 
  37.  ***************************/
  38.    if exists(dest||filename)=0 then do;call copyfile;return;end
  39.  
  40. /**************************************
  41.   Get version for source & destination
  42.  **************************************/
  43.   address command 'c:version "'source||filename'" full >t:dopustemp.tmp0'
  44.   address command 'c:version "'dest||filename'" full >t:dopustemp.tmp1'
  45.   
  46.   open('file0',"t:dopustemp.tmp0")
  47.   line0=readln('file0')
  48.   ver0=word(line0,2)
  49.  
  50.   open('file1',"t:dopustemp.tmp1")
  51.   line1=readln('file1')
  52.   ver1=word(line1,2)
  53.  
  54.   if ver0="not" & ver1="not" then;do;call copyfile;return;end
  55.   if ver0="not" then ver0=" - "
  56.   if ver1="not" then ver1=" - "
  57.   
  58. /*******************
  59.   Get creation date
  60.  *******************/
  61. p2=index(line0,')');p1=index(line0,'(');len=p2-p1+1
  62.  if p1*p2=0 then do;date0="";p1=1;p2=0;end
  63.  if p2>p1 then date0=right(line0,len)
  64.  
  65. p2=index(line1,')');p1=index(line1,'(');len=p2-p1+1
  66.  if p1*p2=0 then do;date1="";p1=1;p2=0;end
  67.  if p2>p1 then date1=right(line1,len)
  68.  
  69.  if length(date0)<12 then do
  70.     line0=readln('file0')
  71.     p2=index(line0,')');p1=index(line0,'(');len=p2-p1+1
  72.     if p1*p2=0 then do;date0="(Unknown Date)";p1=1;p2=0;end
  73.     if p2>p1 then date0=left(line0,len);end
  74.  
  75.  if length(date1)<12 then do
  76.     line1=readln('file1')
  77.     p2=index(line1,')');p1=index(line1,'(');len=p2-p1+1
  78.     if p1*p2=0 then do;date1="(Unknown Date)";p1=1;p2=0;end
  79.     if p2>p1 then date1=left(line1,len,0);end
  80.  
  81.     if length(date0)<5^length(date0)>18 then date0="(Unknown Date)"
  82.     if length(date1)<5^length(date1)>18 then date1="(Unknown Date)"
  83.  
  84. /***********
  85.   Requester
  86.  ***********/
  87.  toptext 'VersionCopy found duplicate file - "'filename'"'
  88.  
  89.  status 27;old_cancel=result
  90.  status 27 set "Skip"
  91.  request ' New version: 'ver0' 'date0' '||lf' Old version: 'ver1' 'date1' '||lf||lf'Do you want to continue?'
  92.  if ~result=1 then do;close('file0');close('file1');end
  93.  if ~result=0 then call copyfile
  94.  status 27 set old_cancel
  95.  selectfile filename 0 1
  96. Return
  97.  
  98. /**************
  99.   Copy routine
  100.  **************/
  101. copyfile:
  102.  copy filename
  103.    close('file0')
  104.    close('file1')
  105.  selectfile filename 0 1
  106. return
  107. /**/
  108.