home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 30 fixes_v / 30-fixes_v.zip / fixfor.zip / PRJFIXCP.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-16  |  4KB  |  149 lines

  1. /* */
  2. /* if this file is named PRJFIXCP.CMD then we are repairing a C++ project */
  3. /* if this file is named PRJFIXC.CMD then we are repairing a C project */
  4. /* if this file is named PRJFIXR.CMD then we are repairing a REXX project */
  5.  
  6. parse source sys type progname
  7. if pos('PRJFIXCP', progname)<>0 then
  8.   do
  9.     say 'C++ Project Repair'
  10.     classname='VPCPForm'
  11.   end
  12. else if pos('PRJFIXR', progname)<>0 then
  13.   do
  14.     say 'REXX Project Repair'
  15.     classname='VPForm'
  16.   end
  17. else
  18.   do
  19.     say 'C Project Repair'
  20.     classname='VPCForm'
  21.   end
  22.  
  23. temparea='Temp!!.1!!'
  24.  
  25. say''
  26. say 'This utility will convert all Workplace Shell folders '
  27. say 'in the current directory to VisPro Form objects.'
  28. say ''
  29. say 'This macro MUST be run from the project directory.'
  30. say ''
  31. say 'The damaged Project folder MUST be CLOSED before running'
  32. say 'this program.'
  33. say ''
  34. say 'It is recommended that you back-up your project'
  35. say 'before running this macro.'
  36. say ''
  37. say 'Repair now? (Y/N)'
  38. pull response
  39. if response <> 'Y' & response <> 'y' then
  40.    return
  41.  
  42. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  43. call SysLoadFuncs
  44.  
  45. call SysQueryClassList 'CLASSES.'
  46. found=0
  47. do i=1 to classes.0
  48.    parse var classes.i name module
  49.    if name==classname then
  50.       found=1
  51. end
  52.  
  53. if found==1 then
  54.    say classname' is already registered as a Workplace Shell object'
  55. else do
  56.    rc=SysRegisterObjectClass(classname, classname)
  57.    Call SysSleep 1
  58.    if rc==0 then do
  59.      say '*****Error registering 'classname' object class'
  60.      return
  61.    end
  62. end
  63.  
  64. projectdir='.\'
  65. /* find the form directors by searching for FORM binary file */
  66. rc=SysFileTree(projectdir'FORM', 'forms', 'sf')
  67.  
  68.  
  69. do index=1 to forms.0
  70.    /* strip off FORM to get the FORM dir name */
  71.    lastslash=lastpos('\',forms.index)
  72.    if lastslash<>0 then
  73.      do
  74.         forms.index=left(forms.index, lastslash-1)
  75.      end
  76.  
  77.    /* strip off project path to get the FORM name */
  78.    lastslash=lastpos('\',forms.index)
  79.    if index==1 then do
  80.       if lastslash<>0 then
  81.         do
  82.            projectdir=left(forms.index, lastslash-1)
  83.            lastspace=lastpos(' ',projectdir)
  84.            if lastspace<>0 then
  85.               projectdir=right(projectdir, length(projectdir)-lastspace)
  86.            rc=SysCreateObject(classname, temparea, projectdir)
  87.            Call SysSleep 1
  88.            if rc==0 then do
  89.               say '*****Error creating 'classname' object 'temparea
  90.               return
  91.            end
  92.            '@rd 'temparea' 1>NUL 2>NUL'
  93.            '@rd form 1>NUL 2>NUL'
  94.            rc=SysCreateObject(CLASSNAME, 'Form', projectdir, "TEMPLATE=YES")
  95.            Call SysSleep 1
  96.         end
  97.    end
  98.    if lastslash<>0 then
  99.      do
  100.         forms.index=right(forms.index, length(forms.index)-lastslash)
  101.      end
  102.  
  103.    parse upper var forms.index upcase
  104.  
  105.    if upcase<>'SUBPROCS' then
  106.      do
  107.        if (classname=='VPForm' & upcase<>'THREADS') | (classname<>'VPForm' & upcase<>'SOURCE') then
  108.          do
  109.            say 'Found VisPro form 'forms.index
  110.            say '   Repairing VisPro form 'forms.index
  111.            '@md 'temparea
  112.            Call SysSleep 1
  113.            say 'Moving Form Objects...'
  114.            '@move 'forms.index'\*.* 'temparea
  115.            Call SysSleep 1
  116.            '@rd 'forms.index
  117.  
  118.            if forms.index=='MAIN' then
  119.               forms.index='Main'
  120.            say 'Creating new Form'
  121.            rc=SysCreateObject(classname, forms.index, projectdir)
  122.            Call SysSleep 1
  123.            if rc==0 then do
  124.               say '*****Error creating 'classname' object 'forms.index
  125.               '@rename 'temparea' 'forms.index
  126.               return
  127.            end
  128.            say 'Moving form object files'
  129.            '@move 'temparea'\*.* 'forms.index
  130.            Call SysSleep 1
  131.            '@rd 'temparea' 1>NUL 2>NUL'
  132.          end
  133.  
  134.      end
  135.  
  136.  
  137. end
  138. 'cls'
  139. if forms.0==0 then
  140.    say '****No VisPro forms found'
  141. else
  142.    say 'Project repaired successfully'
  143.  
  144.  
  145. return
  146.  
  147.  
  148.  
  149.