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);
- Clears status bar.
- Clears Mapgetvar, Mapreadvar, Mapdeclvar and Mapdeclpar.
- Sets Global::BuildFlag = BUILD.
- Traverses Global::AllModulesList calling each modules decl() function thus populating the MAPs.
- Sets Global::BuildFlag = DECL.
- Traverses Global::AllModulesList copying module names and pointers to ListBox1.
- Clears ListBox2.
- Sets GiveWarning if Global::OurModulesList is not empty.
- Traverses Global::OurModulesListcopying module names and pointers to ListBox2.
- 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
- Calls CheckModel()
- Calls return if any errors reported and displays an informational MessageBox.
- If existing model (GiveWarning true) displays an informational MessageBox asking if parameter values should be saved first.
- Call Main->ClearModulesClick(Sender).
- 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.
- Set TStringGrid options.
- Reset all TStringGrid cells to "".
- Set ColCount = 5 and RowCount = 1 and insert titles.
- Insert Observations used by module.
- Insert Variables used by module.
- Insert Variables declared by module.
- 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.
- Creates TStringList List and sets options todupAccept and Sorted = false.
- Creates TStringList ListNotFound and sets options todupAccept and Sorted = false.
- Clears status bar.
- Traverses ListBox2 and check that the model modules 'declgetvar' modules are in the
ListBox2 module list.
- If not, if the module exists in ListBox1 add the module to ListBox2,
- else if the module is not specified explicitly '*', then ignore,
- else log error that required module does not exist.
- If any additional added to model repeat traverse of ListBox2.
Check that any module 'declgetvar' exists as a modules 'declvar'.
- Traverses ListBox2 and for each module do the following:
- Insert in TStringList List all the current modules 'declvar' variables.
- Loop through current modules 'declgetvar' and verify they exist in List from earlier modules.
- If not add to ListNotFound,
- Else increment useage in List and .
Check throw