TBldForm (09/05/02)

CRHM

TBldForm - Window to assemble models.

class TBldForm : public TForm{

__published: // IDE-managed Components

TListBox *ListBox1; // modules available.

TListBox *ListBox2; // modules selected

TLabel *Label1; // "modules available".

TLabel *Label2; //  "modules selected".

TBitBtn *BitBtn1; // "Build".

TBitBtn *BitBtn2; // "Cancel".

TStringGrid *StringGrid1;

TButton *Check; // "check".

TStatusBar *StatusBar1;

void __fastcall FormActivate(TObject *Sender);

void __fastcall ListBox2Click(TObject *Sender);

void __fastcall BitBtn1Click(TObject *Sender);

void __fastcall BitBtn2Click(TObject *Sender);

void __fastcall ListBox1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);

void __fastcall CheckClick(TObject *Sender);

void __fastcall FormClose(TObject *Sender, TCloseAction &Action);

void __fastcall FormDeactivate(TObject *Sender);

private: // User declarations

TStringList *List;

TStringList *ListNotFound;

public: // User declarations

__fastcall TBldForm(TComponent* Owner);

void __fastcall DisplayModule(String S);

long __fastcall CheckModel();

bool Execute;

};

typedef String KeyType2; //

typedef pair<KeyType2, KeyType2> Pairstr; //

typedef multimap<KeyType2, KeyType2> Mapstr; //

Member Functions.

void __fastcall FormActivate(TObject *Sender);

  1. Clears status bar.
  2. Clears Mapgetvar, Mapreadvar, Mapdeclvar and Mapdeclpar.
  3. Sets Global::BuildFlag = BUILD.
  4. Traverses Global::AllModulesList calling each modules decl() function thus populating the MAPs.
  5. Sets Global::BuildFlag = DECL.
  6. Traverses Global::AllModulesList copying module names and pointers to ListBox1.
  7. Clears ListBox2.
  8. Sets GiveWarning if Global::OurModulesList is not empty.
  9. Traverses Global::OurModulesListcopying module names and pointers to ListBox2.
  10. Sets Execute to false.

void __fastcall ListBox2Click(TObject *Sender);

    Calls DisplayModule(S) where S is item selected in ListBox2.

void __fastcall BitBtn1Click(TObject *Sender); // Build

  1. Calls CheckModel()
  2. Calls return if any errors reported and displays an informational MessageBox.
  3. If existing model (GiveWarning true) displays an informational MessageBox asking if parameter values should be saved first.
  4. Call Main->ClearModulesClick(Sender).
  5. If

void __fastcall BitBtn2Click(TObject *Sender);

    Closes the BldForm form.

void __fastcall ListBox1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);

    If mbRight then Add/Delete module from ListBox2, otherwise call DisplayModule().

void __fastcall CheckClick(TObject *Sender);

    Calls CheckModel().

void __fastcall FormClose(TObject *Sender, TCloseAction &Action);

    Clears ListBox1 and ListBox2.

void __fastcall FormDeactivate(TObject *Sender);

CRHM variables and routines.

TStringList *List;

TStringList *ListNotFound;

bool Execute;

void __fastcall DisplayModule(String S);

    S is the name of module to be displayed.

  1. Set TStringGrid options.
  2. Reset all TStringGrid cells to "".
  3. Set ColCount = 5 and RowCount = 1 and insert titles.
  4. Insert Observations used by module.
  5. Insert Variables used by module.
  6. Insert Variables declared by module.
  7. Inser Parameters declared by module.

long __fastcall CheckModel();

    Checks Model for errors.

Local Storage.

    TStringList *List - variables declared earlier <srcName + varName, useage count>

    TStringList *ListUsed - variables needed <srcName + varName, index to ListBox2 of module using variable>

index is made negative if  "srcName + varName" is not found or wild '*'.   If the wild variable is determine the index is made positive again.

    Check that any module used exists in model.

  1. Creates TStringList List and sets options todupAccept and Sorted = false.
  2. Creates TStringList ListNotFound and sets options todupAccept and Sorted = false.
  3. Clears status bar.
  4. Traverses ListBox2 and check that the model modules 'declgetvar' modules are in the ListBox2 module list.  
    1. If not, if the module exists in ListBox1 add the module to ListBox2,
    2. else if the module is not specified explicitly '*', then ignore,
    3. else log error that required module does not exist.
  5. If any additional added to model repeat traverse of ListBox2.

   Check that any  module 'declgetvar' exists as a modules 'declvar'.

  1. Traverses ListBox2 and for each module do the following:
  1. Insert in TStringList List all the current modules 'declvar' variables.
  2. Loop through current modules 'declgetvar' and verify they exist in List from earlier modules.
    1. If not add to ListNotFound,
    2. Else increment useage in List and .

    Check throw