home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / srcmac.zip / PUT.REX < prev    next >
OS/2 REXX Batch file  |  1993-01-14  |  3KB  |  111 lines

  1. /* PUT.REX - PVCS PUT the currently viewed work file.
  2.  
  3.   This macro PUTs the current file that you are viewing to a logfile.
  4.   If the log file does not exist, one is created and a file comment
  5.   can be entered.
  6.  
  7.   A revision comment is prompted for. 
  8.  
  9.   CANCELing the comment is transparent to functionality of this macro.
  10.   Your work file will still be PUT into the log file.
  11.  
  12.   Customizations necessary:
  13.   1. PVCSPUT specs where the PUT executable is.
  14.   2. sLogFile is the directory where your log file in question is.
  15.      Remember the final '\'.
  16. */
  17.  
  18. /* -------------------------- Alias list ----------------------------*/
  19.  
  20.       /* Setup full path to PUT */
  21. pvcsput = 'e:\pvcs\put'
  22.  
  23.       /* Set the Log File directory */
  24. sLogFile = 'e:\pvcs\macros\test\src\'
  25.       
  26. /* ---------------------------- Begin ------------------------------ */
  27.  
  28. 's_get_curr_filename sCurrFile'
  29.  if \(RC = 0) then
  30.    do
  31.    's_msg "Could not obtain the current file name","Error Code is:",' rc ',resp'
  32.    exit
  33.    end
  34.  
  35. /* Build the string for the files */    
  36. sDrv = filespec("drive",sCurrFile)
  37. sFileName = filespec("name",sCurrFile)
  38. sPath = filespec("path",sCurrFile)
  39.   
  40. iLp = lastpos('.',sFileName)
  41. sNameOnly = substr(sFileName,1,iLp-1)
  42.   
  43. iLp = lastpos('.',sCurrFile)
  44. sExtension = substr(sCurrFile,iLp+1)
  45.   
  46. /* Make the extension into PVCS standard form, adding a 'V' in the 3rd position */
  47. if (length(sExtension) = 1) then
  48.   sLFExt = insert(sExtension,'_V')
  49. else if (length(sExtension) = 2) then
  50.    sLFExt = insert(sExtension,'V')
  51. else if (length(sExtension) = 3) then
  52.   sLFExt = overlay('V',sExtension,3)
  53. else
  54.   sLFExt = '__V'
  55.   
  56. /* Build the logfile name */
  57. sLogFile = insert(sLogFile,sNameOnly)
  58. sLogFile = insert(sLogFile,'.')
  59. sLogFile = insert(sLogFile,sLFExt)
  60.   
  61. /* Get Revision Comment */
  62. 's_prompt "Revision Comment?",' sComment
  63. if \(sComment='CANCEL') then
  64. do
  65.   sComment = insert('-m"',sComment)
  66.   sComment = insert(sComment,'"')
  67. end
  68. else
  69.   sComment = ''
  70.  
  71. /* Build path parameter. Create: logfile(workfile */   
  72. sPathParam = insert(sLogFile,'(')
  73. sPathParam = insert(sPathParam,sCurrFile)
  74.  
  75. /* If the LogFile exists, PUT the file.
  76.    If the LofFile DOES NOT EXIST, ask for a LogFile comment too! Then PUT the file.
  77. */       
  78. resp = stream(sLogFile,'c','query exists')
  79. if (length(resp) > 0) then
  80.   cmd = pvcsput sComment '-q -xeerr' sPathParam
  81. else
  82.   do
  83.   's_prompt "Comment for NEW LogFile",'  sFileComment
  84.   if \(sFileComment='CANCEL') then
  85.     do
  86.     sFileComment = insert('-t"',sFileComment)
  87.     sFileComment = insert(sFileComment,'"')
  88.     end
  89.   else
  90.     sComment = ''
  91.   cmd = pvcsput  sComment sFileComment '-q -xeerr' sPathParam
  92.   end
  93. cmd  /* PUT here */    
  94.  
  95. /* If the PUT went ok, close the current file ( the workfile ).
  96.    If the PUT went bad, tell us and SLSTART the error file.
  97. */       
  98. if (rc=0) then
  99.   do
  100.   's_msg "File has been PUT",,,resp'
  101.   's_close_curr_file'
  102.   end
  103. else
  104.   do
  105.   's_msg "There was an error:",' rc ',"Report it please",resp'
  106.   'slstart err'
  107.   end
  108.  
  109. exit
  110.  
  111. /* fini */