Document-ID:        40644.1
Subject:            Recovering Corrupted Forms
Author:             DRMILLS
Last Modified:      10 Dec 96 


Introduction:
-------------
This note discusses some of the techniques that can be used to recover a 
"Corrupted" Form or Library.  What is ment by a by a corrupted form in this 
context is an FMB (or .PLL) file, which you can sucessfully open in 
Developer/2000 Forms Designer, but for some reason you are unable to Save or 
Generate, without an internal error or General Protection Fault.

Classes of Corruption:
----------------------
Broadly speaking we tend to encounter several distinct causes and types of 
Forms corruption, some of which are rooted in specific bugs, some of which 
'Just Happen' and of course corruptions due to physical factors, such as media 
failure or an interrupted save.

Fixing Corruptions:
-------------------

 a) CHKCONS=YES
    As of Developer/2000 release 1.2 (Forms 4.5.6.5.5) a new option was added 
to the f45gen.exe program to fix internal inconsistancies within a FMB file.  
This method effectivly does a sanity check on the internal structure of the FBM 
file and removes any references that no longer make sense.  For instance an 
Item has a Visual Attribute assigned and the internal address for that Visual 
Attribute within the FBM file is empty.
CHKCONS is commonly used to fix GPFs in F45DESM.
To use CHKCONS on MS/Windows you'll need to duplicate the Forms Generate Icon 
and change its properties to add the CHKCONS option in.  CHKCONS is not 
available from the Generate dialog.  So to "fix" a form called FOO in 16 bit 
forms we would set the command line up for the copied generate icon as follows:
    c:\orawin\bin\f45gen.exe module=foo userid=scott/tiger chkcons=yes
You then double click on the icon to run the generate with these options.  A 
dialog should then appear stating that no file has been generated, which is 
correct no FMX file will have been produced, but the date/timestamp on the FMB 
will have been changed
CHKCONS should not be used with any other options, and is only applicable to 
FMB files.
CHKCONS does not require the form to be openable in the Forms Designer, so will 
be worth trying when you have an un-openable FMB file.

b) PURGEPUS=YES
   As of Developer/2000 Release 1.2 (Forms 4.5.6.5.5) the PURGEPUS option
   was added as an argument to the Forms Designer.  This option
   specifically addresses the error "A program unit PU_<number> already
   exists.  Continue compilation?", when opening a Form in the Designer. 
   Choosing to continue at this point could result in the loss of program
   units from the Form. 
   The PURGEPUS option fixes this problem.
   To use this option create a new icon for f45des.exe (or f45des32.exe)
   with the command line "c:\orawin\f45des.exe purgepus=yes"
   Only use this option when you get the duplicate program units error.  It
   will slow down the loading time of forms considerably.  As soon as the
   module has been opened, re-save the form and exit the Forms Designer.

c) Conversion to Text File from Binary and back.
   This technique is of most use with problem PLL files, and represents a 
   very good method for "cleaning up" a library file.
   The steps required to convert a library foo.pll are:

   1) To convert to Text
      f45gen module=foo module_type=library userid=scott/tiger script=yes 
   2) Then you can check the PLD file that has been generated for obvious  
      corruptions (PU's with no code, Duplicate PU names etc.).  This file
      is plain text.
   3) Revert back to a PLL using:
      f45gen module=foo module_type=library userid=scott/tiger parse=yes
        compile_all=yes

d) Drag and Drop Rebuild.
   Support have found this to be an excellent technique for recovering
   problem modules.  The exercise itself is relativly painless and
   basically results in a brand new form which is clean internally.
   Steps Required:

   1) Create a new form in designer
   2) Delete Window0 from the new form
   3) Change the Coordinate system & Cell size in the Form Property sheet 
      of the new form to match the problem form. Also add any other form 
      level properties such as the form title and comments.
   4) Attach any libraries that the problem form uses to the new form
   5) If the form contains referenced object groups or other objects then
      open each of the reference forms in turn and Drag in (to reference)
      the object groups and other objects.
   6) Open the problem form
   7) Open the Block Node of the problem form, shift-select all the 
      NON-REFRENCED blocks and Drag into the new form. Choose copy at this
      point.
      Accept the default for all the options in the copy dialog.  
      This should bring all the Canvases, windows etc with the blocks and
      items 
   8) Shift-Select all the program units from the problem form and drag to
      the new form this will automatically do a copy.
   9) Shift-select all the form level tiggers in the problem form (all the 
      block and item level triggers will have come across with the Blocks).
      Drag and drop the trigger selection into the new form.  Again choose
      COPY and accept the defaults.  
   10)Save the new version of the form.