home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / goat006.zip / SRC.ZIP / goatsrc / PRJFIXR.CMD < prev    next >
OS/2 REXX Batch file  |  1995-11-28  |  5KB  |  173 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 upper 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. sleeptime = 2
  25.  
  26. say''
  27. say 'This utility will convert all Workplace Shell folders '
  28. say 'in the current directory to VisPro Form objects.'
  29. say ''
  30. say 'This macro MUST be run from the project directory.'
  31. say ''
  32. say 'The damaged Project folder MUST be CLOSED before running'
  33. say 'this program.'
  34. say ''
  35. say 'It is recommended that you back-up your project'
  36. say 'before running this macro.'
  37. say ''
  38. say 'Repair now? (Y/N)'
  39. pull response
  40. if response <> 'Y' & response <> 'y' then
  41.    return
  42.  
  43. classes.0 = 0
  44. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  45. call SysLoadFuncs
  46.  
  47. call SysQueryClassList 'CLASSES.'
  48. found=0
  49. if classes.0 = 0 then do
  50.    say ''
  51.    say ''
  52.    say ''
  53.    say 'There has been an error running REXX system '
  54.    say 'functions.  Please open a NEW OS/2 window,  '
  55.    say 'change to the effected project directory and'
  56.    say 'run this application again.'
  57.    say ''
  58.    say ''
  59.    say ''
  60.    say 'Press <enter> to exit.'
  61.    say ''
  62.    say ''
  63.    return
  64. end  /* Do */
  65. do i=1 to classes.0
  66.    parse var classes.i name module
  67.    if name==classname then
  68.       found=1
  69. end
  70.  
  71. if found==1 then
  72.    say classname' is already registered as a Workplace Shell object'
  73. else do
  74.    rc=SysRegisterObjectClass(classname, classname)
  75.    Call SysSleep sleeptime
  76.    if rc==0 then do
  77.      say '*****Error registering 'classname' object class'
  78.      return
  79.    end
  80. end
  81.  
  82. projectdir='.\'
  83. /* find the form directors by searching for FORM binary file */
  84. rc=SysFileTree(projectdir'FORM', 'forms', 'sf')
  85.  
  86.  
  87. do index=1 to forms.0
  88.    /* strip off FORM to get the FORM dir name */
  89.    lastslash=lastpos('\',forms.index)
  90.    if lastslash<>0 then
  91.      do
  92.         forms.index=left(forms.index, lastslash-1)
  93.      end
  94.  
  95.    /* strip off project path to get the FORM name */
  96.    lastslash=lastpos('\',forms.index)
  97.    if index==1 then do
  98.       if lastslash<>0 then
  99.         do
  100.            projectdir=left(forms.index, lastslash-1)
  101.            lastspace=lastpos(' ',projectdir)
  102.            if lastspace<>0 then
  103.               projectdir=right(projectdir, length(projectdir)-lastspace)
  104.            rc=SysCreateObject(classname, temparea, projectdir)
  105.            Call SysSleep sleeptime
  106.            if rc==0 then do
  107.               say '*****Error creating 'classname' object 'temparea
  108.               return
  109.            end
  110.            '@rd 'temparea' 1>NUL 2>NUL'
  111.            '@rd form 1>NUL 2>NUL'
  112.            rc=SysCreateObject(CLASSNAME, 'Form', projectdir, "TEMPLATE=YES")
  113.            Call SysSleep sleeptime
  114.         end
  115.    end
  116.    if lastslash<>0 then
  117.      do
  118.         forms.index=right(forms.index, length(forms.index)-lastslash)
  119.      end
  120.  
  121.    parse upper var forms.index upcase
  122.  
  123.    if upcase<>'SUBPROCS' then
  124.      do
  125.        if (classname=='VPForm' & upcase<>'THREADS') | (classname<>'VPForm' & upcase<>'SOURCE') then
  126.          do
  127.            say 'Found VisPro form 'forms.index
  128.            say '   Repairing VisPro form 'forms.index
  129.            '@md 'temparea
  130.            Call SysSleep sleeptime
  131.            say 'Moving Form Objects...'
  132.            '@move 'forms.index'\*.* 'temparea
  133.            Call SysSleep sleeptime
  134.            rc=SysDestroyObject(projectdir'\'forms.index)
  135.            Call SysSleep sleeptime
  136.  
  137.            if forms.index=='MAIN' then
  138.               forms.index='Main'
  139.            say 'Creating new Form'
  140.            rc=SysCreateObject(classname, forms.index, projectdir)
  141.            Call SysSleep sleeptime
  142.            if rc==0 then do
  143.               say '*****Error creating 'classname' object 'forms.index
  144.               '@rename 'temparea' 'forms.index
  145.               return
  146.            end
  147.            say 'Moving form object files'
  148.            '@move 'temparea'\*.* 'forms.index
  149.            Call SysSleep sleeptime
  150.            '@rd 'temparea' 1>NUL 2>NUL'
  151.          end
  152.  
  153.      end
  154.  
  155.  
  156. end
  157. 'cls'
  158. if forms.0==0 then do
  159.    say ' '
  160.    say ' '
  161.    say ' '
  162.    say ' '
  163.    say '****No VisPro forms found'
  164.    end
  165. else do
  166.    say ' '
  167.    say ' '
  168.    say ' '
  169.    say ' '
  170.    say 'Project repaired successfully'
  171.    end
  172. return
  173.