// SAPP1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "SAPP1.h"
#include "SAPP1Dlg.h"
#include "string.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

HACCEL  m_hAccelTable;

// Greek alphabets
// aß?de???????µ???p??s?t?f???

#include <vector>

using namespace std;
int tabCtrlProjects = 0;

bool results_dialog_read_first_time = true;
bool add_dwelling_to_estate = false;
bool chk_if_project_saved   = false;
bool is_save_dialg_called   = false;
int lastTabNumber = 0;

vector <LineEntryInfo> stringsWithValues;
vector <OpenProjectInfo> projectInfo;
vector <projectFileNamesInTabs> projectFileNamesInTabs_1;
vector <openingsData> openingsData_New;
vector <openingListData> openingListData_New;
vector <secHtSysData> secHtSysData_New;
vector <SAPboilers> SAPboilers_db;
vector <SAPcostTable> SAPcostTable_New;
vector <EstateData> EstateDataValues;
vector <EstateData> EstateDataValuesBase;
vector <EstateData> EstateDataValuesImp1;
vector <EstateData> EstateDataValuesImp2;
vector <EstateData> EstateDataValuesImp3;
vector <EstateData> EstateDataValuesImp4;
vector <EstateData> EstateDataValuesImp5;

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()

#define PATH_TO_SEC_HT_EFF_FILE "..\\data\\SecHtEfficiencies.csv"
#define PATH_TO_SAP_BOILER_DB_FILE "SAPBoilers.csv"
#define PATH_TO_SAP_COST_TABLE "..\\data\\SAPcostTable.csv"
#define PATH_TO_WIND_DATA_FILE "..\\data\\windData.csv"
#define PATH_TO_WWHRS_DATA_FILE "..\\data\\WWHRS.csv"
#define PATH_TO_FGHRS_DATA_FILE "..\\data\\FGHRS.csv"
#define PATH_TO_SHCS_DATA_FILE "..\\data\\SHCS.csv"
//#define PATH_TO_SAP_BOILER_DB_FILE "..\\data\\SAPBoilers.csv"

bool is_file_opened_if_changing_tabs = false;
bool file_already_opened      = false;

// Flags for base and improvement buttons
bool is_results_values_read_first_time = false;
bool is_base_selected = false;
bool is_imp1_selected = false;
bool is_imp2_selected = false;
bool is_imp3_selected = false;
bool is_imp4_selected = false;
bool is_imp5_selected = false;

bool is_base_changed = false;
bool is_imp1_changed = false;
bool is_imp2_changed = false;
bool is_imp3_changed = false;
bool is_imp4_changed = false;
bool is_imp5_changed = false;

bool is_base_saved = false;
bool is_imp1_saved = false;
bool is_imp2_saved = false;
bool is_imp3_saved = false;
bool is_imp4_saved = false;
bool is_imp5_saved = false;


bool display_base_results = false;
bool display_imp1_results = false;
bool display_imp2_results = false;
bool display_imp3_results = false;
bool display_imp4_results= false;
bool display_imp5_results= false;

// These variables wil be used to calculate primary fuel
double primaryFuelUsed = 0;
double secFuelUsed     = 0;
double mainGasTotalFuel = 0;
double LPGTotalFuel     = 0;
double botGasTotalFuel  = 0;
double oilTotalFuel     = 0;
double houseCoalTotalFuel   = 0;
double smokelessTotalFuel   = 0;
double anthraciteTotalFuel  = 0;
double woodLogsTotalFuel    = 0;
double woodchipsTotalFuel   = 0;
double woodPelletsTotalFuel = 0;
double dualFuelTotalFuel    = 0;
double electricityTotalFuel = 0;
CString primaryFuelUsedString;
CString secFuelUsedString;

// CSAPP1Dlg dialog

CSAPP1Dlg::CSAPP1Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSAPP1Dlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSAPP1Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TAB1, m_tabCtrl);
	DDX_Control(pDX, IDC_TAB2, m_tabCtrlProjects);
	DDX_Control(pDX, IDC_TAB3, m_tabCtrlEstate);
}

BEGIN_MESSAGE_MAP(CSAPP1Dlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
	ON_COMMAND(ID_FILE_SAVE142, OnFileSave)
	ON_COMMAND(ID_FILE_OPEN143, OnFileOpen)
	ON_COMMAND(ID_FILE_NEW148, OnFileNew)
	ON_WM_CLOSE()
	ON_COMMAND(ID_FILE_EXIT, OnFileExit)
	ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)
	ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)

	
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB2, OnClickProjectsTab)
	ON_COMMAND(ID_FILE_CLOSE158, OnFileClose)
	ON_COMMAND(ID_FILE_ADDTOESTATE, OnFileAddToEstate)
	ON_COMMAND(ID_FILE_OPENESTATE, OnFileOpenEstate)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB3, OnTcnSelchangeTab3)
	ON_NOTIFY(NM_CLICK, IDC_TAB3, OnNMClickTab3)
	ON_COMMAND(ID_ESTATE_ADDTOESTATE, OnEstateAddToEstate)
	ON_COMMAND(ID_ESTATE_VIEWESTATE, OnEstateViewEstate)
	ON_COMMAND(ID_EXPORT_EXPORTTPESP, OnExportToEspr)
	ON_COMMAND(ID_EXPORT_EXPORTTOSAPINFORMATION, OnExportExporttosapinformation)
	ON_COMMAND(ID_FILE_READFROMSHCS, OnFileReadFromSHCS)
	ON_COMMAND(ID_ESTATE_SAVEESTATE, &CSAPP1Dlg::OnEstateSaveEstate)
	ON_COMMAND(ID_ESTATE_OPENESTATE, &CSAPP1Dlg::OnEstateOpenEstate)
	ON_COMMAND(ID_FILE_OPENESTATE32786, &CSAPP1Dlg::OnFileMenuOpenEstate)
END_MESSAGE_MAP()


// CSAPP1Dlg message handlers
CString projectFileName;
CString projectFileNameNoPath;
CString projectFileNameNoExt;
int fileFound = 0;
int currentProjectTabPosition = 0;
int baseSelected = 0;
int imp1Selected = 0;
int imp2Selected = 0;
int imp3Selected = 0;
int imp4Selected = 0;
int imp5Selected = 0;

vector <openingsForDlg> openingsForDlg1;

struct MonthlyValues effectiveInfiltrationRate;
struct MonthlyValues WindFactor;
struct MonthlyValues averageWindSpeed;
struct MonthlyValues monthlyNumOfDays;
struct MonthlyValues DHW_monthlyUsage;
struct MonthlyValues DHW_monthlyFactorsForHotWaterUse;;
struct MonthlyValues DHW_monthlyTempRise;
struct MonthlyValues DHW_coldWaterTemp;
struct MonthlyValues IfBalancedMVHR;      // If balanced mechanical ventilation with heat recovery (MVHR)
struct MonthlyValues IfBalancedMVnoHR;    // If balanced mechanical ventilation without heat recovery (MV)
struct MonthlyValues IfWholeHouseExractVentilationOrInputVentFromOutside; // If whole house extract ventilation or positive input ventilation from outside
struct MonthlyValues IfNaturalVentilationOrInputVentFromLoft;             // If natural ventilation or whole house positive input ventilation from loft
struct MonthlyValues IfPositiveInputFromOutside;
struct MonthlyValues EffectiveAirChangeRate;
struct MonthlyValues DSMResults;
struct MonthlyValues DSMResults1;
struct MonthlyValues DSMResults2;

vector <FGHRS_Data> FGHRS_combiData;
vector <WWHRSData> WWHRSData_1;
vector <WindData> WindData_1;
vector <ClimateData> ClimateData_1;
vector <ClimateData> ClimateData_towns;
vector <IndexDataNew> IndexDataNew_1;
vector <SHCSfileRead> SHCSfileRead1;

int addOpening = 0;
CString newOpeningName;
bool is_new_opeing_added = false;

bool enable_user_to_change_tab = false;
bool file_new_selected = true;
bool TFA_from_HEM = true;
bool yValue_from_HEM = true;
bool if_change_house_type = false;
bool if_change_flat_type  = false;

//---------------------------------------------------------
// GLOBAL VARIABLES FOR MULTISCALING
//---------------------------------------------------------
int numOfDwellings = 1;
CString caseOfDwellings = "Base";

//---------------------------------------------------------
// GLOBAL VARIABLES
//---------------------------------------------------------
// INITIALIZE WITH SOME VALUE
//---------------------------------------------------------
// RENEWABLES
//---------------------------------------------------------
CString isSHWPresent = "No";
CString isPVPresent  = "No";
CString isWTPresent  = "No";
CString uHydroyn	 = "No";
CString uCHPyn		 = "No";
CString MVHRyn		 = "No";

CString SHWCollectorType = "Flat plate - glazed";
CString SHWCollectorOrientation = "South";
CString SHWCollectorTilt = "30 deg";
CString SHWOvershading   = "Modest 20%-60%";
CString isSHWAreaGross   = "Yes";
CString isSHWSolarStoreCombined = "Yes";
CString SHWSolarCircPump = "Electrically powered";
double  SHWApertureArea = 4.0;
double  SHW_ZLCE = 70;
double  SHW_HeatLossCoefficient = 6;
double SHW_dedicatedSolarStorageVolumeFactor = 100;

CString PVCollectorOrientation = "South";
CString PVCollectorTilt = "30 deg";
CString PVOvershading = "Modest 20%-60%";

CString dwellingExposure = "Average";
CString CHPFuel = "Mains gas";

CString FGHRSpresent           = "No";
CString FGHRSstore			 = "No";
double  FGHRSstoreVolume     = 400;
double  FGHRSusefulFracHtRec_kf1 = 0.5;
CString FGHRSfittedMain      = "Yes";
CString FGHRSfittedSec       = "No";
CString FGHRStype			 = "system 1";
CString determineFGHRStype	 = "No";
double  FGHRStotFracHeatRec_kf2  = 0.5;
double  FGHRSauxelec   = 0.5;
CString FGHRSpvPoweredHt     = "No";
double FGHRSpvPkPower		 = 1.1;
CString FGHRSpvOrientation = "South";
CString FGHRSpvTilt			 = "Horizontal";
CString FGHRSpvOvershading   = "Heavy > 80%";
double FGHRScableLoss		 = 0.2;

CString WWHRSpresent = "No";
int WWHRSnumOfRooms  = 1;
CString WWHRS1Make;
CString WWHRS1Model;
CString	WWHRS1ModelQualifier;
int WWHRSnumMixerShowersWithBath1    = 1;
int WWHRSnumMixerShowersWithoutBath1 = 1;

CString WWHRS2Make;
CString WWHRS2Model;
CString	WWHRS2ModelQualifier;
int WWHRSnumMixerShowersWithBath2    = 1;
int WWHRSnumMixerShowersWithoutBath2 = 1;

bool is_locationString_changed = true;
bool is_hemHouseType_changed   = true;
bool is_hemYearOfBuild_changed = true;

// Misc variables used in calculations
double WWHRS_savings = 0;
double FGHRS_saving  = 0;
double FGHRS_PVinput = 0;

//---------------------------------------------------------
// BUILT FORM
//---------------------------------------------------------
CString locationString = "Select weather..";

CString dwellingType = "New dwelling as designed";
CString builtForm = "House";
CString Detachment    = "Detached" ;
CString FlatPosition     = "Ground floor";
CString dwellingTerrain = "Dense urban";

CString storey1Level = "Lowest occupied";
CString storey2Level = "Lowest occupied";
CString storey3Level = "Lowest occupied";
CString storey4Level = "Lowest occupied";
CString storey5Level = "Lowest occupied";
CString storey6Level = "Lowest occupied";

//---------------------------------------------------------
// WINDOWS
//---------------------------------------------------------
CString winOvershading = "Very little";
CString	winGlazing = "Single";

//---------------------------------------------------------
// VENTILATION
//---------------------------------------------------------
CString mechVentType = "Not present (natural)";
CString pressureTestYN = "No";
double structInf = 0.25;
double floorInf  =0.1;
CString draughtLobby = "No";
int perWindowDraughtStripped = 100;

//---------------------------------------------------------
// MAIM HEATING
//---------------------------------------------------------
CString mainFuel = "Mains gas";
CString electricityTarrif = "Standard";
CString mainHtType = "Boiler";
CString mainHtEffFrom = "Manufacturer declaration";
CString boilerType = "Standard";
CString isFanFluePresent = "No";
CString mainHtControls = "No time or thermostatic control of room temperature";
CString mainHtEmitter  = "Radiators";
CString isIterlockPresent = "No";
CString isPumpInHeatedSpace = "No";
CString mainHtSystem = "Direct acting";

//---------------------------------------------------------
// MAIN HETAING DETAILS
//---------------------------------------------------------
CString oilPumpInHeatedSpace = "No";
CString oilBoilerInstalled = "Before 1 April 2007";

CString isThereCHP= "No";
CString CHPfuel = "Mains gas";

//---------------------------------------------------------
// SECONDARY HEATING
//---------------------------------------------------------
CString isThereSecHeating = "No";
CString secHtEffFrom = "Manufacturer declaration";
CString secHtFuel = "Mains gas";

//---------------------------------------------------------
// WATER HEATING
//---------------------------------------------------------
int btnWaterHtFromMainState = 1;
CString WHtype = "Cylinder - indirect";
CString WHtCylinderWithinDwelling = "No";
CString WHtFuel;
CString WHtWaterSepTimed = "No";

CString WHtCylManufactLossFactor = "Unknown";
CString WHtCylInsType = "Loose jacket";

CString WHtCylThermostat = "No";
CString WHtCylInHeatedSpace = "No";
CString WHtCylPrimaryPipeworkInsulated = "No";
CString WHtCylPumpedPrimarySystem = "No";

CString WHtTSnCPSUinSingleUnit = "Yes";
CString WHtTSnCPSUPrimaryPipeworkLT1_5m = "Yes";
CString WHtTSnCPSUstoreInAirCupbrd = "Yes";

CString WHtCombiKeepHotYN = "Yes";
CString DHWfromCommunityScheme = "Yes";
CString DHWComSchemeSystem = "Yes";
CString WHtHeatPumpUsesImmer = "Yes";

CString WHtUsesSummerImmer= "Yes";

//--------------------------------------------------------
// JOB DETAILS GLOBAL VARIABLES
//--------------------------------------------------------
CString JobDetRefNum;
CString assessorName;
CString JobDetComments;
CString propertyFlatNameorNum;
CString propertyLetter;
CString propertyHouseNum;
CString propertyStreet;
CString propertyLocality;
CString propertyDistrict;
CString propertyTown;
CString propertyCounty;
CString propertyPostCode;
CString clientFlatNameorNum;
CString clientLetter;
CString clientHouseorBlockNum;
CString clientStreet;
CString clientLocality;
CString clientDistrict;
CString clientTown;
CString clientCounty;
CString clientPostCode;

//----------------------------------------
// BUILT FORM GLOBAL VARIABLES
//----------------------------------------
int dwellingShelteredSides = 1;
CString yearPropertBuilt; 

CString storey1;
CString storey2;
CString storey3;
CString storey4;
CString storey5;
CString storey6;

CString storey1Basement;
CString storey2Basement;
CString storey3Basement;
CString storey4Basement;
CString storey5Basement;
CString storey6Basement;

double storey1Area = 0.0;
double storey2Area = 0.0;
double storey3Area = 0.0;
double storey4Area = 0.0;
double storey5Area = 0.0;
double storey6Area = 0.0;

double storey1Height = 0.0;
double storey2Height = 0.0;
double storey3Height = 0.0;
double storey4Height = 0.0;
double storey5Height = 0.0;
double storey6Height = 0.0;

double multipleLinearRegCoeff = 0;
double multipleLinearRegCoeff1 = 0;
double multipleLinearRegCoeff2 = 0;

double thermBridgeYvalue_grossArea = 0;
double hem_yValueEntry = 0;

//-----------------------------------------------------
// FLOORS GLOBAL VARIABLES
//-----------------------------------------------------
CString floor1Selected;
CString floor2Selected;
CString floor3Selected;
CString floor4Selected;
CString floor5Selected;
CString floor6Selected;
CString floor7Selected;
CString floor8Selected;
CString floor9Selected;
CString floor10Selected;

CString floor1Name;
CString floor2Name;
CString floor3Name;
CString floor4Name;
CString floor5Name;
CString floor6Name;
CString floor7Name;
CString floor8Name;
CString floor9Name;
CString floor10Name;

CString floor1Type;
CString floor2Type;
CString floor3Type;
CString floor4Type;
CString floor5Type;
CString floor6Type;
CString floor7Type;
CString floor8Type;
CString floor9Type;
CString floor10Type;

CString floor1Construction;
CString floor2Construction;
CString floor3Construction;
CString floor4Construction;
CString floor5Construction;
CString floor6Construction;
CString floor7Construction;
CString floor8Construction;
CString floor9Construction;
CString floor10Construction;

CString isfloor1Sealed;
CString isfloor2Sealed;
CString isfloor3Sealed;
CString isfloor4Sealed;
CString isfloor5Sealed;
CString isfloor6Sealed;
CString isfloor7Sealed;
CString isfloor8Sealed;
CString isfloor9Sealed;
CString isfloor10Sealed;

double floor1Area;
double floor2Area;
double floor3Area;
double floor4Area;
double floor5Area;
double floor6Area;
double floor7Area;
double floor8Area;
double floor9Area;
double floor10Area;

double floor1Uvalue;
double floor2Uvalue;
double floor3Uvalue;
double floor4Uvalue;
double floor5Uvalue;
double floor6Uvalue;
double floor7Uvalue;
double floor8Uvalue;
double floor9Uvalue;
double floor10Uvalue;

//----------------------------------
// WALLS GLOBAL VARIABLES
//----------------------------------
CString wall1Selected;
CString wall2Selected;
CString wall3Selected;
CString wall4Selected;
CString wall5Selected;
CString wall6Selected;
CString wall7Selected;
CString wall8Selected;
CString wall9Selected;
CString wall10Selected;

CString wall1Name;
CString wall2Name;
CString wall3Name;
CString wall4Name;
CString wall5Name;
CString wall6Name;
CString wall7Name;
CString wall8Name;
CString wall9Name;
CString wall10Name;

CString wall1Construction;
CString wall2Construction;
CString wall3Construction;
CString wall4Construction;
CString wall5Construction;
CString wall6Construction;
CString wall7Construction;
CString wall8Construction;
CString wall9Construction;
CString wall10Construction;

CString wall1Basement;
CString wall2Basement;
CString wall3Basement;
CString wall4Basement;
CString wall5Basement;
CString wall6Basement;
CString wall7Basement;
CString wall8Basement;
CString wall9Basement;
CString wall10Basement;

double wall1Area;
double wall2Area;
double wall3Area;
double wall4Area;
double wall5Area;
double wall6Area;
double wall7Area;
double wall8Area;
double wall9Area;
double wall10Area;

double wall1Uvalue;
double wall2Uvalue;
double wall3Uvalue;
double wall4Uvalue;
double wall5Uvalue;
double wall6Uvalue;
double wall7Uvalue;
double wall8Uvalue;
double wall9Uvalue;
double wall10Uvalue;

//---------------------------------------------
// ROOFS GLOBAL VARIABLES
//---------------------------------------------
CString isRoof1Selected;
CString isRoof2Selected;
CString isRoof3Selected;
CString isRoof4Selected;
CString isRoof5Selected;
CString isRoof6Selected;
CString isRoof7Selected;
CString isRoof8Selected;
CString isRoof9Selected;
CString isRoof10Selected;

CString roof1Name;
CString roof2Name;
CString roof3Name;
CString roof4Name;
CString roof5Name;
CString roof6Name;
CString roof7Name;
CString roof8Name;
CString roof9Name;
CString roof10Name;

CString roof1Construction;
CString roof2Construction;
CString roof3Construction;
CString roof4Construction;
CString roof5Construction;
CString roof6Construction;
CString roof7Construction;
CString roof8Construction;
CString roof9Construction;
CString roof10Construction;

double roof1Area = 0.0;
double roof2Area = 0.0;
double roof3Area = 0.0;
double roof4Area = 0.0;
double roof5Area = 0.0;
double roof6Area = 0.0;
double roof7Area = 0.0;
double roof8Area = 0.0;
double roof9Area = 0.0;
double roof10Area= 0.0;

double roof1Uvalue = 0.0;
double roof2Uvalue = 0.0;
double roof3Uvalue = 0.0;
double roof4Uvalue = 0.0;
double roof5Uvalue = 0.0;
double roof6Uvalue = 0.0;
double roof7Uvalue = 0.0;
double roof8Uvalue = 0.0;
double roof9Uvalue = 0.0;
double roof10Uvalue= 0.0;

//---------------------------------------------------
// VENTILATION GLOBAL VARIABLES
//---------------------------------------------------
CString designAirPermeability;
CString pressureTestScotland;
CString accreditedDetailsScotland;
CString seekExemptionForLT3Dwellings;

double designAirPermRate = 0.0;
double asBuiltAirPermRate = 0.0;

CString airPermMeasuredInDwelling;
CString asBuiltRef;
CString asBuiltTestDate;

CString mechVentValuesFrom;
CString numsWetRooms;
CString ductInsulation;

int numsOpenFirePlaces   = 0;
int numsOpenFlues        = 0;
int numsFluelessGasFires = 0;

int numsExtractFans = 0;
int numsPassiveVents = 0;
CString isACPresent;
double ACEnergyUse = 0.0;
double measuredQ50;
int numOfStoreys;

double dewllingVolume = 0;
double infiltration_rate = 0;
double infiltration_rate18 = 0;
double shelterFactor = 0;
double infiltrationRateWithshelterFactor = 0;
double infliltrationOpenings = 0;
double additionalInfiltration = 0;
double windowInfiltration = 0;
int numOfShelteredSides = 0;
double totalWindSpeed = 0;
double totalWindFactor = 0;
double effInfiltrationRate = 0;

double achThrougSystem;
double valueIfExhaustAirHP;
double valueIfBalancedHR;

double effectiveACH = 0;
double effectiveACH_MVHR = 0;
double achMVHR1;
double achMVHR2;

double spaceHeatingDemandMVHR1;
double spaceHeatingDemandMVHR2;

//---------------------------------------------------------
// MAIN HEATING GLOBAL VARIABLES
//---------------------------------------------------------
CString boilerRef;
CString boilerModel;
CString isSecBoilerFuelPresent;
CString mainHtCompensator;
CString mainHtManufacturerDesc;
CString mainHtTestMethod;

double mainHtEff = 0.0;
double mainHtEffNominal=0.0;

double mainHtEffAdj = 0.0;
double mainHtTempAdj = 0.0;
double mainHtFractionSupplied = 1;

bool is_enhanced_load_compensator = false;
bool is_under_floor_system        = false;

//--------------------------------------------------------
// MAIN HEATING DETAILS GLOBAL VARIABLES
//--------------------------------------------------------
double CPSUoperatingTemp = 0.0;

double heatEmmFromCase   = 0.0;
double heatTransferredToWater = 0.0;
CString smokeControlledArea;

double fractOfHtFromCHP = 0.0;
double elecEffOfCHP = 0.0;
double heatingEffOfCHP = 0.0;

CString secComBoilerFuel;
CString secComBoilerSystem;
double secComBoilerEff = 0.0;
double secComBoilerFractOfHtFromBoiler2 = 0.0;
CString secComBoilerManufactDesc;

//------------------------------------------------------
// SEC HEATING GLOBAL VARIABLES
//------------------------------------------------------
CString secHtOpenFlueChimney;
CString secHtUnconnectedGasPoint;
CString secHtSystem;
CString secHtManufactDesc;
CString secHtTestMethod;
double secHtEff = 90;
double secHtFraction = 0.0;

double spaceHeatingEffAdj;
double waterHeatingEffAdj;

//----------------------------------------------
// WATER HEATING GLOBAL VARIABLES
//----------------------------------------------
double WHtCylDeclaredFactor= 0.0;
double WHtCylVolume= 0.0;
double WHtCylInsThickness= 0.0;

double WHtEff = 0;
double WHtEffAdj = 0;

CString WHtCombiKeepHotUsesElec;
double WHtCombiPowerRating= 0.0;

CString DHWComSchemeProvidedFrom;
double DHWComSchemeCHP2PowerRatio= 0.0;

double DHWComSchemeEff= 0.0;

//---------------------------------------------------------
// RENEWABLES 1
//---------------------------------------------------------
double SHW_overshadingFactor;
double SHW_annualSolarRadiation_pm2 ;
double SHW_collectorPerformanceRatio;
double SHW_solarEnergyAvailable;
double SHW_apertureArea;

double SHW_solarToLoadRatio;
double SHW_collectorPerformanceFactor;
double SHW_effectiveSolarVolume;
double SHW_utilizationFactor;
double N_OCC;
double SHW_annualHotWaterUsage;
double SHW_dailyHotWaterDemand_litres;
double SHW_volumeRatio;
double SHW_annualSolarInput;
double  SHWDedSolStoreVol = 100;

CString isRENAdditionalElectGenerated;
double  RENAddiationalElecGenerated = 0.0;
double  REN_TFA = 0.0;

double  installedPVPeakPower = 2;
double PV_overshadingFactor;
double PV_annualSolarRadiation_pm2 ;

int    WTNumOf    = 1;
double WTDiameter = 2;
double WTHeight   = 5;
double WTs3;

//---------------------------------------------------------
// RENEWABLES 2
//---------------------------------------------------------
double uHydroAnnualAvgHead = 4;
double uHydroAnnualAvgFlow = 50;
double uHydroEff =60;
double uHydroAnnualEnergy;

double uCHPheatToPowerRatio = 2;
double uCHPElectricEff      = 40;
double uCHPHeatingEff       = 50;
double uCHPHeatingFraction  = 1;
double uCHPAnnualElectricity     = 0;

double MVHRThermalEff = 75;
double lambda;
bool is_mvhr_eff_changed = false;
bool is_spf_changed = false;

//---------------------------------------------------------
// Factor for LZCT
//---------------------------------------------------------
double B_PV = 0.5;
double B_WT = 0.7;
double B_uHydro = 0.4;
double B_uCHP = 0.4;
double annualEnergy_PV;
double WTsupplyInput;
double uHydrosupplyInput;
double uCHPsupplyInput;

double LZCT_elecDisplaced;
double LZCT_elecSold;
double totalElectricalSupply;

//-------------------------------------------------------
// LIGHTS GLOBAL VARIABLES
//-------------------------------------------------------
double fractionLEL  = 0;
int IntLightsStdFittings = 0;
int IntLightsDedicatedLowEnergy = 0;
int IntLightsNonDedicatedLowEnergy = 0;
int IntLightsTotal = 0;

CString ExtLightsAssess;
CString ExtLightsFittingGT40Lumens;
CString ExtLightsLampsNGT150W;

//-------------------------------------------------
// THERMAL BRIDGES Global Variables
//-------------------------------------------------
double ThermBGFPerimeter;
double ThermBFloorWithingDwellinPerimeter;
double ThermBFloorBetweenDwellinPerimeter;
double ThermBBalconyWithingDwellingLength;
double ThermBBalconyBetweenDwellingLength;
double ThermBEavesAtCeiling;
double ThermBEavesAtRafter;
double ThermBGableAtCeiling;
double ThermBGableAtRafter;
double ThermBLengthNormalCorners;
double ThermBLengthInvertedCorners;
double ThermBPartWallBetweenDwelling;
double yValueEntry;

CString ThermBMetalBoxLintelUserDef;
CString ThermBOtherLintelUserDef;
CString ThermBSillUserDef;
CString ThermBJambUserDef;
CString ThermBGFPerimeterUserDef;
CString ThermBFloorWithinDwellingUserDef;
CString ThermBFloorBwDwellingUserDef;
CString ThermBBalcWithinDwellingLengthUserDef;
CString ThermBBalcBwDwellingLengthUserDef;
CString ThermBEavesInsAtCeilingUserDef;
CString ThermBEavesInsAtRafterUserDef;
CString ThermBGableInsAtCeilingUserDef;
CString ThermBGableInsAtRafetUserDef;
CString ThermBLengthOfNormalCornersUserDef;
CString ThermBLengthOfInvertedCornersUserDef;
CString ThermBPartWallBetweenDwellingUserDef;

double ThermBMetalBoxLintelSiValue;
double ThermBOtherLintelsSiValue;
double ThermBSillSiValue;
double ThermBJambSiValue;
double ThermBGFPerimeterSiValue;
double ThermBFloorWithinDwellingSiValue;
double ThermBFloorBetweenDwellingSiValue;
double ThermBBalconyWithinDwellingSiValue;
double ThermBBalconyBwDwellingSiValue;
double ThermBEavesInsAtCelingSiValue;
double ThermBEavesInsAtRafterSiValue;
double ThermBGableInsAtCeilingSiValue;
double ThermBGableInsAtRafterSiValue;
double ThermBLengthOfNormalCornersSiValue;
double ThermBLengthOfInvertedCornersSiValue;
double ThermBPartBwDwellingLengthSiValue;

double ThermBMetalBoxLintelResult;
double ThermBOtherLintelsResult;
double ThermBSillResult;
double ThermBJambResult;
double ThermBGFPerimeterResult;
double ThermBFloorWithinDwellingPerimeterResult;
double ThermBFloorBetweenDwellingPerimeterResult;
double ThermBBalcWithDwellingLengthResult;
double ThermBBalconyBwDwellingLengthResult;
double ThermBEavesInsCeilingResult;
double ThermBEavesInsRafterResult;
double ThermBGableInsCeilingResult;
double ThermBGableInsRafterResult;
double ThermBLengthNormalCornersResult;
double ThermBLengthInvertedCornersResult;
double ThermBPartyWallBwDwellingResult;

//---------------------------------------------
// SUMMER OVER HEATING GLOBAL VARIABLES
//---------------------------------------------
CString isTMPUserDef;
double TMPvalue;
CString TMPIntPartConstruction;
CString TMPPartyWallConstruction;
CString isVentUserDefined;
double airChangeRate;
CString isCrossVentOnMostFloors;
CString windowVentilation;
CString areCurtainsClosedDuringDay;
double fractCurtainsClosed;
CString blindCurtainType;
CString sourceUserDefValues;

double totalGlzArea;
double winNArea;
double winNEArea;
double winEArea;
double winSEArea;
double winSArea;
double winSWArea;
double winWArea;
double winNWArea;
double rooflightsArea;

double winNSolTrans;
double winNESolTrans;
double winESolTrans;
double winSESolTrans;
double winSSolTrans;
double winSWSolTrans;
double winWSolTrans;
double winNWSolTrans;
double rooflightsSolTrans;

double winNFrameFactor;
double winNEFrameFactor;
double winEFrameFactor;
double winSEFrameFactor;
double winSFrameFactor;
double winSWFrameFactor;
double winWFrameFactor;
double winNWFrameFactor;
double rooflightsFrameFactor;

//---------------------------------------------
// MISC VARIABLES FO RRESULTS DIALOG
//---------------------------------------------
int chkInsulation   = 0;
int chkAirtightness = 0;
int chkCapacity     = 0;
int chkSolarIngress = 0;
int chkOccupancy    = 0;
int chkControlledSpace= 0;
int chkHeatingEff = 0;
int chkDHWEff     = 0;

int chkSDHW   = 0;
int chkPV     = 0;
int chkWT     = 0;
int chkuCHP   = 0;
int chkuHydro = 0;
int chkPCM    = 0;
int chkMVHR   = 0;
int chkFGHRS  = 0;
int	chkWWHRS  = 0;

int chkActual  = 1;  
int	chkperm2   = 0;
int	chkEnergy  = 1; 
int	chkCost  = 0; 
int	chkEmissions = 0;

CString hemHouseType;
CString hemYearOfBuild;
double propertyFreqOfOccurence = 0;
int numOfFloors = 0;

CString hemCoolingFuel;
double hemCoolingEff;

CString hemX_exposure;
CString hemI_insulation;
CString hemI_insulation1;
CString hemI_insulation2;
CString hemA_ach;
CString hemC_capacity;
CString hemS_solarGains;
CString hemO_occupantDensity;
CString hemL_livingAreaFraction;
CString hemXIACSOL_string;
CString hemXIACSOL_string1;
CString hemXIACSOL_string2;
double hemx_1;
double hemx_2;
double hemy_1;
double hemy_2;
double hemTFA;

bool is_file_opened = false;
bool is_climate_changed_from_results = false;
bool is_house_type_changed_from_results = false;
bool is_year_of_build_changed = false;
bool is_ins_slider_moved_due_to_house_type_change = false;
bool is_ins_slider_moved_due_to_year_bilud_change = false;
bool is_make_eff_adjustments_slider_insulation = false;
bool is_make_eff_adjustments_slider_exposure = false;
bool is_make_eff_adjustments_slider_airChanges = false;
bool is_make_eff_adjustments_slider_capacity = false;
bool is_make_eff_adjustments_slider_occupancy = false;
bool is_make_eff_adjustments_slider_livingArea = false;
bool is_make_eff_adjustments_slider_solarIngress = false;

int hemI_insulationSliderPos;
int hemA_achSliderPos;
int hemC_capacitySliderPos;
int hemS_solarGainsSliderPos;
int hemO_OCCDensitySliderPos;
int hemL_LAFracSliderPos;
int hem_HeffSliderPos;
int hem_DHWeffSliderPos;

double iStat;
double dwellingVoulme;
double SFP;
double auxillaryElectricity;

double numOfOccupants;
double TFA;
double TFAfromHEM;
double EB;
double C1;
double ZL;
double gL;
double GL_total;
double C2;
double lightElectricity;

double Vd_avg;
double DHW_energy;
double distributionLoss;
double winterOpTemp = 85;
double tempFactor;
double storageLoss;
double lossFactor;
double tankVolume;
double volumeFacor;
double heatLossFactor;
double srorageLoss;
double primaryCircuitLoss;
double F_u;
double combiLoss;
double solarDHWInput;

double pvSupplyInput;

double DHWspaceHeatingGain = 0;
double usefulStorageLoss = 0;
bool isCylinderPresent = true;
double domesticHotWaterSupply;
double spaceHeatingDemand;
double totalRenElecSupply;
double totalRenElecSupply_fuelCost;
double totalRenElecSupply_Emm;
double totalRenElecSupply_PrimEnergyFactor;

double totalSpaceHtSupply_Disp = 0;
double totalSpaceCoolingSupply_Disp = 0;
double domesticHotWaterSupply_Disp = 0;
double lightElectricity_Disp = 0;
double auxillaryElectricity_Disp = 0;
double totalElectricalSupply_Disp = 0;
double mainSpaceHtSupply_Disp = 0;
double secSpaceHtSupply_Disp = 0;
double LZCTelecSold_Disp = 0;
double LZCTelecDisp_Disp = 0;
double primaryFuelUsed_Disp = 0;
double secFuelUsed_Disp = 0;

bool display_msg_only_once = true;
bool display_CPSUmsg_only_once = true;
int enterYValue = 1;

double mainSpaceHtSupply;
double secSpaceHtSupply;
double totalSpaceHtSupply;
double totalSpaceCoolingSupply = 0;

double totalEnergy;
double totalCost;
double totalEmissions;
double totalPrimaryEnergy;

double mainSpaceHtSupply_fuelCost;
double secSpaceHtSupply_fuelCost;
double domesticHotWaterSupply_fuelCost;
double auxillaryElectricity_fuelCost;
double lightElectricity_fuelCost;
double totalSpaceCoolingSupply_fuelCost;
double LZCT_elecSold_fuelCost;
double LZCT_elecDisp_fuelCost;
double primaryFuelUsed_fuelCost;
double secFuelUsed_fuelCost;

double mainSpaceHtSupply_Emm;
double secSpaceHtSupply_Emm;
double domesticHotWaterSupply_Emm;
double auxillaryElectricity_Emm;
double lightElectricity_Emm;
double totalSpaceCoolingSupply_Emm;
double LZCT_elecSold_Emm;
double LZCT_elecDisp_Emm;
double primaryFuelUsed_Emm;
double secFuelUsed_Emm;

double mainSpaceHtSupply_PrimEnergyFactor;
double secSpaceHtSupply_PrimEnergyFactor;
double domesticHotWaterSupply_PrimEnergyFactor;
double auxillaryElectricity_PrimEnergyFactor;
double lightElectricity_PrimEnergyFactor;
double totalSpaceCoolingSupply_PrimEnergyFactor;
double LZCT_elecSold_PrimEnergyFactor;
double LZCT_elecDisp_PrimEnergyFactor;

//---------------------------------------------
// GLOBAL VARIABLES FOR TC ID
//---------------------------------------------
bool ifReadFRDBfile = true;
bool fReadSAPcalcsFile = false;

// Create index number to read data from frdb.csv file
CString X_exposure;
CString I_insulation;
CString I_insulation1;
CString I_insulation2;
CString A_ach;
CString C_capacity;
CString S_solarGains;
CString O_occupantDensity;
CString L_livingAreaFraction;
CString XIACSOL_string;
CString XIACSOL_string1;
CString XIACSOL_string2;

CString A_ach_MVHR1;
CString A_ach_MVHR2;

double x_1;
double x_2;
double y_1;
double y_2;

// String for user display
CString XIACSOL_string_disp;
CString XIACSOL_string_disp1;
CString XIACSOL_string_disp2;

//---------------------------------
// Living room fraction limits
double L_limit1 = 0.25;
double L_limit2 = 0.3;
double L_limit3 = 0.35;
double L_limit4 = 0.4;
double L_limit5 = 0.5;

//---------------------------------
// Living room fraction range
double L_range1 = 0;
double L_range2 = 0;
double L_range3 = 0;
double L_range4 = 0;
double L_range5 = 0;

//---------------------------------
// Occupant density limits
double O_limit1 = 60;
double O_limit2 = 80;
double O_limit3 = 100;
double O_limit4 = 150;
double O_limit5 = 200;

//---------------------------------
// Occupant density range
double O_range1 = 0.0;
double O_range2 = 0.0;
double O_range3 = 0.0;
double O_range4 = 0.0;
double O_range5 = 0.0;

//---------------------------------
// Solar gains limits
double S_limit1 = 0.15;
double S_limit2 = 0.225;
double S_limit3 = 0.3;

//---------------------------------
// Solar gains range
double S_range1 = 0.0;
double S_range2 = 0.0;
double S_range3 = 0.0;

//---------------------------------
// Capacity limit
double C_limit = 250;

//---------------------------------
// Air change per hour limits
double A_limit1 = 0.1;
double A_limit2 = 0.25;
double A_limit3 = 0.65;
double A_limit4 = 1.0;
double A_limit5 = 1.5;

//---------------------------------
// Air change per hour range
double A_range1 = 0.0;
double A_range2 = 0.0;
double A_range3 = 0.0;
double A_range4 = 0.0;
double A_range5 = 0.0;

//---------------------------------
// Insulation limits
double I_limit1 = 0;
double I_limit2 = 0;
double I_limit3 = 0;
double I_limit4 = 0;
double I_limit5 = 0;

//---------------------------------
// Insulation range 
double I_range1 = 0;
double I_range2 = 0;
double I_range3 = 0;
double I_range4 = 0;
double I_range5 = 0;

//---------------------------------
// Exposure limits 
double X_limit1 = 0.5;
double X_limit2 = 1.5;
double X_limit3 = 2.5;
double X_limit4 = 2.8;
double X_limit5 = 3;

//---------------------------------
// Exposure range 
double X_range1 = 0;
double X_range2 = 0;
double X_range3 = 0;
double X_range4 = 0;
double X_range5 = 0;

//---------------------------------
// Misc variables used in ach calc
int numOfChimneys_multip         = 40;
int	numOfFlues_multip            = 20;  
int	numOfFansPassVents_multip    = 10;  
int	numOfFluelessGasFires_multip = 40;
double total_solarGains = 0;

int numOfChimneys_m3perh          = 0;
int	numOfFlues_m3perh             = 0;  
int	numOfFansPassVents_m3perh     = 0;  
int	numOfFluelessGasFires_m3perh  = 0;

//---------------------------------------------
// VIEW OPENINGS FOR WALL ROOF
//---------------------------------------------
CString WallRoofOpeningName;

//---------------------------------------------
// AREAS & U-VALUES
//---------------------------------------------
double grossAreaWall1;
double groosAreaRoof1;
double netAreaDoors;
double netAreaWindows;
double netAreaRoofLights;
double netAreaGF;
double netAreaExFloor;
double netAreaWallType1;
double netAreaWallType2;
double netAreaRoofType1;
double netAreaRoofType2;
double netAreaPartyWall;
double netAreaPartyFloor;
double netAreaPartyCeiling;
double netAreaInternalWall;
double netAreaInternalFloor;
double netAreaInternalCeiling;

double UvalueDoors;
double UvalueWindows;
double UvalueRooflights;
double UvalueGF;
double UvalueExposedFloor;
double UvalueWallType1;
double UvalueWallType2;
double UvalueRoofTYpe1;
double UvalueRoofType2;
double UvaluePartyWall;

double kValueGF;
double kValueExpFloor;
double kValueWallType1;
double kValueWallType2;
double kValueRoofType1;
double kValueRoofType2;
double kValuePartyWall;
double kValuePartyFloor;
double kValuePartyCeiling;
double kValueIntWall;
double kValueIntFloor;
double kValueIntCeiling;

double thermalMassParameter;
double livingRoomFraction;

double extAreaSum;
double exposureValue;
double extInsulationValue;
double extUvalueXareaSum;
double hem_extInsulationValue;

double hem_extAreaSum;
double hem_extUvalueXareaSum;

CString versionText;
CString titleBarText;

// Flags for RangeCheckFunction

// Overview dilaog
bool isCheckRange_TFA = false;
bool isCheckRange_costOfImprovement = false;

// Built form dialog
bool isCheckRange_areaStorey1 = false;
bool isCheckRange_areaStorey2 = false;
bool isCheckRange_areaStorey3 = false;
bool isCheckRange_areaStorey4 = false;
bool isCheckRange_areaStorey5 = false;
bool isCheckRange_areaStorey6 = false;

bool isCheckRange_heightStorey1 = false;
bool isCheckRange_heightStorey2 = false;
bool isCheckRange_heightStorey3 = false;
bool isCheckRange_heightStorey4 = false;
bool isCheckRange_heightStorey5 = false;
bool isCheckRange_heightStorey6 = false;

// Windows dialog
bool isCheckRange_winNArea = false;
bool isCheckRange_winNEArea = false;
bool isCheckRange_winEArea = false;
bool isCheckRange_winSEArea = false;
bool isCheckRange_winSArea = false;
bool isCheckRange_winSWArea = false;
bool isCheckRange_winWArea = false;
bool isCheckRange_winNWArea = false;
bool isCheckRange_rooflightsArea = false;

bool isCheckRange_winNSolTrans = false;
bool isCheckRange_winNESolTrans = false;
bool isCheckRange_winESolTrans = false;
bool isCheckRange_winSESolTrans = false;
bool isCheckRange_winSSolTrans = false;
bool isCheckRange_winSWSolTrans = false;
bool isCheckRange_winWSolTrans = false;
bool isCheckRange_winNWSolTrans = false;
bool isCheckRange_rooflightsSolTrans = false;

bool isCheckRange_winNFrameFactor = false;
bool isCheckRange_winNEFrameFactor = false;
bool isCheckRange_winEFrameFactor = false;
bool isCheckRange_winSEFrameFactor = false;
bool isCheckRange_winSFrameFactor = false;
bool isCheckRange_winSWFrameFactor = false;
bool isCheckRange_winWFrameFactor = false;
bool isCheckRange_winNWFrameFactor = false;
bool isCheckRange_rooflightsFrameFactor = false;

bool isCheckRange_fractionLEL = false;

// Area and u-Value dialog
bool isCheckRange_grossAreaWall1 = false;
bool isCheckRange_groosAreaRoof1 = false;
bool isCheckRange_netAreaDoors = false;
bool isCheckRange_netAreaWindows = false;
bool isCheckRange_netAreaRoofLights = false;
bool isCheckRange_netAreaGF = false;
bool isCheckRange_netAreaExFloor = false;
bool isCheckRange_netAreaWallType1 = false;
bool isCheckRange_netAreaWallType2 = false;
bool isCheckRange_netAreaRoofType1 = false;
bool isCheckRange_netAreaRoofType2 = false;
bool isCheckRange_netAreaPartyWall = false;
bool isCheckRange_netAreaPartyFloor = false;
bool isCheckRange_netAreaPartyCeiling = false;
bool isCheckRange_netAreaInternalWall = false;
bool isCheckRange_netAreaInternalFloor = false;
bool isCheckRange_netAreaInternalCeiling = false;

bool isCheckRange_UvalueDoors = false;
bool isCheckRange_UvalueWindows = false;
bool isCheckRange_UvalueRooflights = false;
bool isCheckRange_UvalueGF = false;
bool isCheckRange_UvalueExposedFloor = false;
bool isCheckRange_UvalueWallType1 = false;
bool isCheckRange_UvalueWallType2 = false;
bool isCheckRange_UvalueRoofTYpe1 = false;
bool isCheckRange_UvalueRoofType2 = false;
bool isCheckRange_UvaluePartyWall = false;

bool isCheckRange_kValueGF = false;
bool isCheckRange_kValueExpFloor = false;
bool isCheckRange_kValueWallType1 = false;
bool isCheckRange_kValueWallType2 = false;
bool isCheckRange_kValueRoofType1 = false;
bool isCheckRange_kValueRoofType2 = false;
bool isCheckRange_kValuePartyWall = false;
bool isCheckRange_kValuePartyFloor = false;
bool isCheckRange_kValuePartyCeiling = false;
bool isCheckRange_kValueIntWall = false;
bool isCheckRange_kValueIntFloor = false;
bool isCheckRange_kValueIntCeiling = false;

// Thermal bridge dialog
bool isCheckRange_yValueEntry = false;
bool isCheckRange_ThermBGFPerimeter = false;
bool isCheckRange_ThermBFloorWithingDwellinPerimeter = false;
bool isCheckRange_ThermBFloorBetweenDwellinPerimeter = false;
bool isCheckRange_ThermBBalconyWithingDwellingLength = false;
bool isCheckRange_ThermBBalconyBetweenDwellingLength = false;
bool isCheckRange_ThermBEavesAtCeiling = false;
bool isCheckRange_ThermBEavesAtRafter = false;
bool isCheckRange_ThermBGableAtCeiling = false;
bool isCheckRange_ThermBGableAtRafter = false;
bool isCheckRange_ThermBLengthNormalCorners = false;
bool isCheckRange_ThermBLengthInvertedCorners = false;
bool isCheckRange_ThermBPartWallBetweenDwelling = false;

bool isCheckRange_ThermBMetalBoxLintelSiValue = false;
bool isCheckRange_ThermBOtherLintelsSiValue = false;
bool isCheckRange_ThermBSillSiValue = false;
bool isCheckRange_ThermBJambSiValue = false;
bool isCheckRange_ThermBGFPerimeterSiValue = false;
bool isCheckRange_ThermBFloorWithinDwellingSiValue = false;
bool isCheckRange_ThermBFloorBetweenDwellingSiValue = false;
bool isCheckRange_ThermBBalconyWithinDwellingSiValue = false;
bool isCheckRange_ThermBBalconyBwDwellingSiValue = false;
bool isCheckRange_ThermBEavesInsAtCelingSiValue = false;
bool isCheckRange_ThermBEavesInsAtRafterSiValue = false;
bool isCheckRange_ThermBGableInsAtCeilingSiValue = false;
bool isCheckRange_ThermBGableInsAtRafterSiValue = false;
bool isCheckRange_ThermBLengthOfNormalCornersSiValue = false;
bool isCheckRange_ThermBLengthOfInvertedCornersSiValue = false;
bool isCheckRange_ThermBPartBwDwellingLengthSiValue = false;

// Ventilation dialog
bool isCheckRange_numsOpenFirePlaces = false;
bool isCheckRange_numsOpenFlues = false; 
bool isCheckRange_numsFluelessGasFires = false;
bool isCheckRange_numsExtractFans = false;
bool isCheckRange_numsPassiveVents = false;

bool isCheckRange_measuredQ50 = false;
bool isCheckRange_numOfStoreys = false;
bool isCheckRange_SFP = false;

// Main heating dialog
bool isCheckRange_mainHtEff = false;
bool isCheckRange_mainHtFractionSupplied = false;

// Secondary heating dilaog
bool isCheckRange_secHtEff = false;
bool isCheckRange_secHtFraction = false;

// Water heating dialog
bool isCheckRange_WHtCylDeclaredFactor = false;
bool isCheckRange_WHtCylVolume = false;
bool isCheckRange_WHtCylInsThickness = false;
bool isCheckRange_WHtEff = false;

// Renewables 1
// SDHW
bool isCheckRange_SHWApertureArea = false;
bool isCheckRange_SHW_ZLCE = false;
bool isCheckRange_SHW_HeatLossCoefficient = false;
bool isCheckRange_SHWDedSolStoreVol = false;

// PV
bool isCheckRange_installedPVPeakPower = false;

// WT
bool isCheckRange_WTNumOf = false;
bool isCheckRange_WTDiameter = false;
bool isCheckRange_WTHeight = false;

// Renewables 2
// uHydro
bool isCheckRange_uHydroAnnualAvgHead = false;
bool isCheckRange_uHydroAnnualAvgFlow = false;
bool isCheckRange_uHydroEff = false;

// uCHP
bool isCheckRange_uCHPheatToPowerRatio = false;
bool isCheckRange_uCHPElectricEff = false;
bool isCheckRange_uCHPHeatingEff = false;
bool isCheckRange_uCHPHeatingFraction = false;

// MVHR
bool isCheckRange_MVHRThermalEff = false;


// For tab
TCITEM tabItem;

void DisplayWarningMessages()
{
	// BUILT FORM

	// Storey area
	if(isCheckRange_areaStorey1 == true)
	{
		RangeCheckFunction(20, 2000, storey1Area );
		isCheckRange_areaStorey1 = false;
	}

	if(isCheckRange_areaStorey2 == true)
	{
		RangeCheckFunction(20, 2000, storey2Area );
		isCheckRange_areaStorey2 = false;
	}

	if(isCheckRange_areaStorey3 == true)
	{
		RangeCheckFunction(20, 2000, storey3Area );
		isCheckRange_areaStorey3 = false;
	}

	if(isCheckRange_areaStorey4 == true)
	{
		RangeCheckFunction(20, 2000, storey4Area );
		isCheckRange_areaStorey4 = false;
	}

	if(isCheckRange_areaStorey5 == true)
	{
		RangeCheckFunction(20, 2000, storey5Area );
		isCheckRange_areaStorey5 = false;
	}

	if(isCheckRange_areaStorey6 == true)
	{
		RangeCheckFunction(20, 2000, storey1Area );
		isCheckRange_areaStorey6 = false;
	}

	// Storey height
	if(isCheckRange_heightStorey1 == true)
	{
		RangeCheckFunction(1, 6, storey1Height );		
		isCheckRange_heightStorey1 = false;
	}

	if(isCheckRange_heightStorey2 == true)
	{
		RangeCheckFunction(1, 6, storey2Height );
		isCheckRange_heightStorey2 = false;
	}

	if(isCheckRange_heightStorey3 == true)
	{
		RangeCheckFunction(1, 6, storey3Height );
		isCheckRange_heightStorey3 = false;
	}

	if(isCheckRange_heightStorey4 == true)
	{
		RangeCheckFunction(1, 6, storey4Height );
		isCheckRange_heightStorey4 = false;
	}

	if(isCheckRange_heightStorey5 == true)
	{
		RangeCheckFunction(1, 6, storey5Height );
		isCheckRange_heightStorey5 = false;
	}

	if(isCheckRange_heightStorey6 == true)
	{
		RangeCheckFunction(1, 6, storey6Height );
		isCheckRange_heightStorey6 = false;
	}

    // WINDOWS
	// Areas
	if(isCheckRange_winNArea == true)
	{
		RangeCheckFunction(0.01, 30,winNArea);
		isCheckRange_winNArea = false;
	}

	if(isCheckRange_winNEArea == true)
	{
		RangeCheckFunction(0.01,30,winNEArea);
		isCheckRange_winNEArea = false;
	}

	if(isCheckRange_winEArea == true)
	{
		RangeCheckFunction(0.01,6,winEArea);
		isCheckRange_winEArea = false;
	}

	if(isCheckRange_winSEArea == true)
	{
		RangeCheckFunction(0.01,30,winSEArea);
		isCheckRange_winSEArea = false;
	}

	if(isCheckRange_winSArea == true)
	{
		RangeCheckFunction(0.01,30,winSArea);
		isCheckRange_winSArea = false;
	}

	if(isCheckRange_winSWArea == true)
	{
		RangeCheckFunction(0.01,30,winSWArea);
		isCheckRange_winSWArea = false;
	}

	if(isCheckRange_winWArea == true)
	{
		RangeCheckFunction(0.01,30 ,winWArea);
		isCheckRange_winWArea = false;
	}

	if(isCheckRange_winNWArea == true)
	{
		RangeCheckFunction(0.01,30,winNWArea);
		isCheckRange_winNWArea = false;
	}

	if(isCheckRange_rooflightsArea == true)
	{
		RangeCheckFunction(0.01,30,rooflightsArea);
		isCheckRange_rooflightsArea = false;
	}

	// Solar Transmittance
	if(isCheckRange_winNSolTrans == true)
	{
        RangeCheckFunction(0,1,winNSolTrans);
		isCheckRange_winNSolTrans = false;
	}

	if(isCheckRange_winNESolTrans == true)
	{
		RangeCheckFunction(0,1,winNESolTrans);
		isCheckRange_winNESolTrans = false;
	}

	if(isCheckRange_winESolTrans == true)
	{
		RangeCheckFunction(0,1,winESolTrans);
		isCheckRange_winESolTrans = false;
	}

	if(isCheckRange_winSESolTrans == true)
	{
		RangeCheckFunction(0,1,winSESolTrans);
		isCheckRange_winSESolTrans = false;
	}

	if(isCheckRange_winSSolTrans == true)
	{
		RangeCheckFunction(0,1,winSSolTrans);
		isCheckRange_winSSolTrans = false;
	}

	if(isCheckRange_winSWSolTrans == true)
	{
		RangeCheckFunction(0,1,winSWSolTrans);
		isCheckRange_winSWSolTrans = false;
	}

	if(isCheckRange_winWSolTrans == true)
	{
		RangeCheckFunction(0,1,winWSolTrans);
		isCheckRange_winWSolTrans = false;
	}

	if(isCheckRange_winNWSolTrans == true)
	{
		RangeCheckFunction(0,1,winNWSolTrans);
		isCheckRange_winNWSolTrans = false;
	}

	if(isCheckRange_rooflightsSolTrans == true)
	{
		RangeCheckFunction(0,1,rooflightsSolTrans);
		isCheckRange_rooflightsSolTrans = false;
	}

	// Frame factor
	if(isCheckRange_winNFrameFactor == true)
	{
		RangeCheckFunction(0,1,winNFrameFactor);
		isCheckRange_winNFrameFactor = false;
	}
	if(isCheckRange_winNEFrameFactor == true)
	{		
		RangeCheckFunction(0,1,winNEFrameFactor);
		isCheckRange_winNEFrameFactor = false;
	}
	if(isCheckRange_winEFrameFactor == true)
	{
		RangeCheckFunction(0,1,winEFrameFactor);
		isCheckRange_winEFrameFactor = false;
	}
	if(isCheckRange_winSEFrameFactor == true)
	{
		RangeCheckFunction(0,1,winSEFrameFactor);
		isCheckRange_winSEFrameFactor = false;
	}
	if(isCheckRange_winSFrameFactor == true)
	{
        RangeCheckFunction(0,1,winSFrameFactor);
		isCheckRange_winSFrameFactor = false;
	}
	if(isCheckRange_winSWFrameFactor ==true)
	{
        RangeCheckFunction(0,1,winSWFrameFactor);
		isCheckRange_winSWFrameFactor = false;
	}
	if(isCheckRange_winWFrameFactor == true)
	{
        RangeCheckFunction(0,1,winWFrameFactor);
		isCheckRange_winWFrameFactor = false;
	}
	if(isCheckRange_winNWFrameFactor == true)
	{
        RangeCheckFunction(0,1,winNWFrameFactor);
		isCheckRange_winNWFrameFactor = false;
	}
	if(isCheckRange_rooflightsFrameFactor == true)
	{
        RangeCheckFunction(0,1,rooflightsFrameFactor);
		isCheckRange_rooflightsFrameFactor = false;
	}
	if(isCheckRange_fractionLEL == true)
	{		
		RangeCheckFunction(0,1,isCheckRange_fractionLEL);	
		isCheckRange_fractionLEL = false;
	}

	// AREA AND U-VALUE
	// Areas
	if(isCheckRange_grossAreaWall1 == true)
	{
        RangeCheckFunction(0,1000,grossAreaWall1);
		isCheckRange_grossAreaWall1 = false;
	}

	if( isCheckRange_groosAreaRoof1 == true)
	{
        RangeCheckFunction(0,1000,groosAreaRoof1 );
		isCheckRange_groosAreaRoof1 = false;
	}

	if( isCheckRange_netAreaDoors== true)
	{
        RangeCheckFunction(0,1000,netAreaDoors  );
		isCheckRange_netAreaDoors = false;
	}

	if( isCheckRange_netAreaGF == true)
	{
        RangeCheckFunction(0,1000,netAreaGF  );
		isCheckRange_netAreaGF = false;
	}

	if( isCheckRange_netAreaExFloor == true)
	{
        RangeCheckFunction(0,1000,netAreaExFloor);
		isCheckRange_netAreaExFloor = false;
	}

	if( isCheckRange_netAreaWallType2 == true)
	{
		RangeCheckFunction(0,1000,netAreaWallType2);
		isCheckRange_netAreaWallType2 = false;
	}

	if( isCheckRange_netAreaRoofType2 == true)
	{
		RangeCheckFunction(0,1000,netAreaRoofType2);
		isCheckRange_netAreaRoofType2 = false;
	}

	if( isCheckRange_netAreaPartyWall == true)
	{
        RangeCheckFunction(0,1000,netAreaPartyWall);
		isCheckRange_netAreaPartyWall = false;
	}

	if( isCheckRange_netAreaPartyFloor == true)
	{
        RangeCheckFunction(0,1000,netAreaPartyFloor);
		isCheckRange_netAreaPartyFloor = false;
	}

	if( isCheckRange_netAreaPartyCeiling == true)
	{
		RangeCheckFunction(0,1000,netAreaPartyCeiling);
		isCheckRange_netAreaPartyCeiling = false;
	}

	if( isCheckRange_netAreaInternalWall == true)
	{
		RangeCheckFunction(0,1000,netAreaInternalWall);
		isCheckRange_netAreaInternalWall = false;
	}

	if( isCheckRange_netAreaInternalFloor == true)
	{		
		RangeCheckFunction(0,1000,netAreaInternalFloor);
		isCheckRange_netAreaInternalFloor = false;
	}

	if( isCheckRange_netAreaInternalCeiling == true)
	{
        RangeCheckFunction(0,1000,netAreaInternalCeiling);
		isCheckRange_netAreaInternalCeiling = false;
	}

	//U-values
	if( isCheckRange_UvalueDoors == true)
	{
        RangeCheckFunction(0.01,6,UvalueDoors);
		isCheckRange_UvalueDoors = false;
	}

	if( isCheckRange_UvalueWindows == true)
	{
        RangeCheckFunction(0.01,6,UvalueWindows);
		isCheckRange_UvalueWindows = false;
	}

	if( isCheckRange_UvalueRooflights == true)
	{
        RangeCheckFunction(0.01,6,UvalueRooflights);
		isCheckRange_UvalueRooflights = false;
	}

	if( isCheckRange_UvalueGF == true)
	{
        RangeCheckFunction(0.01,6,UvalueGF);
		isCheckRange_UvalueGF = false;
	}

	if( isCheckRange_UvalueExposedFloor == true)
	{
		RangeCheckFunction(0.01,6,UvalueExposedFloor);
		isCheckRange_UvalueExposedFloor = false;
	}

	if( isCheckRange_UvalueWallType1 == true)
	{
        RangeCheckFunction(0.01,6,UvalueWallType1 );
		isCheckRange_UvalueWallType1 = false;
	}

	if( isCheckRange_UvalueWallType2 == true)
	{
		RangeCheckFunction(0.01,6,UvalueWallType2 );
		isCheckRange_UvalueWallType2 = false;
	}

	if( isCheckRange_UvalueRoofTYpe1 == true)
	{
		RangeCheckFunction(0.01,6,UvalueRoofTYpe1 );
		isCheckRange_UvalueRoofTYpe1 = false;
	}

	if( isCheckRange_UvalueRoofType2 == true)
	{
		RangeCheckFunction(0.01,6,UvalueRoofType2 );
		isCheckRange_UvalueRoofType2 = false;
	}

	if( isCheckRange_UvaluePartyWall == true)
	{
		RangeCheckFunction(0.01,6,UvaluePartyWall );
		isCheckRange_UvaluePartyWall = false;
	}

	// k-values
	if( isCheckRange_kValueGF == true)
	{
		RangeCheckFunction(5,300,kValueGF  );
		isCheckRange_kValueGF = false;
	}

	if( isCheckRange_kValueExpFloor == true)
	{
		RangeCheckFunction(5,300,kValueExpFloor  );
		isCheckRange_kValueExpFloor = false;
	}

	if( isCheckRange_kValueWallType1 == true)
	{
		RangeCheckFunction(5,300,kValueWallType1);
		isCheckRange_kValueWallType1 = false;
	}

	if( isCheckRange_kValueWallType2 == true)
	{
		RangeCheckFunction(5,300,kValueWallType2);
		isCheckRange_kValueWallType2 = false;
	}

	if( isCheckRange_kValueRoofType1 == true)
	{	
		RangeCheckFunction(5,300,kValueRoofType1);
		isCheckRange_kValueRoofType1 = false;
	}

	if( isCheckRange_kValueRoofType2 == true)
	{
		RangeCheckFunction(5,300,kValueRoofType2);
		isCheckRange_kValueRoofType2 = false;
	}

	if( isCheckRange_kValuePartyWall == true)
	{
		RangeCheckFunction(5,300,kValuePartyWall);
		isCheckRange_kValuePartyWall = false;
	}

	if( isCheckRange_kValuePartyFloor == true)
	{
		RangeCheckFunction(5,300,kValuePartyFloor);
		isCheckRange_kValuePartyFloor = false;
	}

	if( isCheckRange_kValuePartyCeiling == true)
	{
		RangeCheckFunction(5,300,kValuePartyCeiling);
		isCheckRange_kValuePartyCeiling = false;
	}

	if( isCheckRange_kValueIntWall == true)
	{
		RangeCheckFunction(5,300,kValueIntWall);
		isCheckRange_kValueIntWall = false;
	}

	if( isCheckRange_kValueIntFloor == true)
	{
		RangeCheckFunction(5,300,kValueIntFloor);
		isCheckRange_kValueIntFloor = false;
	}

	if( isCheckRange_kValueIntCeiling == true)
	{
		RangeCheckFunction(5,300,kValueIntCeiling);
		isCheckRange_kValueIntCeiling = false;
	}

	// THERMAL BRIDGING
	// y-value
	if( isCheckRange_yValueEntry == true)
	{
		RangeCheckFunction(0.01,0.3,yValueEntry);
		isCheckRange_yValueEntry = false;
	}

	// Length
	if( isCheckRange_ThermBGFPerimeter == true)
	{
		RangeCheckFunction(0,1000,ThermBGFPerimeter);
		isCheckRange_ThermBGFPerimeter = false;
	}

	if( isCheckRange_ThermBFloorWithingDwellinPerimeter == true)
	{
		RangeCheckFunction(0,1000,ThermBFloorWithingDwellinPerimeter );
		isCheckRange_ThermBFloorWithingDwellinPerimeter = false;
	}

	if( isCheckRange_ThermBFloorBetweenDwellinPerimeter == true)
	{
		RangeCheckFunction(0,1000,ThermBFloorBetweenDwellinPerimeter );
		isCheckRange_ThermBFloorBetweenDwellinPerimeter = false;
	}

	if( isCheckRange_ThermBBalconyWithingDwellingLength == true)
	{
		RangeCheckFunction(0,1000,ThermBBalconyWithingDwellingLength );
		isCheckRange_ThermBBalconyWithingDwellingLength = false;
	}

	if( isCheckRange_ThermBBalconyBetweenDwellingLength == true)
	{
		RangeCheckFunction(0,1000,ThermBBalconyBetweenDwellingLength );
		isCheckRange_ThermBBalconyBetweenDwellingLength = false;
	}

	if( isCheckRange_ThermBEavesAtCeiling == true)
	{
		RangeCheckFunction(0,1000,ThermBEavesAtCeiling  );
		isCheckRange_ThermBEavesAtCeiling = false;
	}

	if( isCheckRange_ThermBEavesAtRafter == true)
	{
		RangeCheckFunction(0,1000,ThermBEavesAtRafter);
		isCheckRange_ThermBEavesAtRafter = false;
	}

	if( isCheckRange_ThermBGableAtCeiling == true)
	{
		RangeCheckFunction(0,1000,ThermBGableAtCeiling);
		isCheckRange_ThermBGableAtCeiling = false;
	}

	if( isCheckRange_ThermBGableAtRafter == true)
	{
		RangeCheckFunction(0,1000,ThermBGableAtRafter);
		isCheckRange_ThermBGableAtRafter = false;
	}

	if( isCheckRange_ThermBLengthNormalCorners == true)
	{
		RangeCheckFunction(0,1000,ThermBLengthNormalCorners);
		isCheckRange_ThermBLengthNormalCorners = false;
	}

	if( isCheckRange_ThermBLengthInvertedCorners == true)
	{
		RangeCheckFunction(0,1000,ThermBLengthInvertedCorners);
		isCheckRange_ThermBLengthInvertedCorners = false;
	}

	if( isCheckRange_ThermBPartWallBetweenDwelling == true)
	{
		RangeCheckFunction(0,1000,ThermBPartWallBetweenDwelling);
		isCheckRange_ThermBPartWallBetweenDwelling = false;
	}

	// Si-value
	if( isCheckRange_ThermBGFPerimeterSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBGFPerimeterSiValue);
		isCheckRange_ThermBGFPerimeterSiValue = false;
	}

	if( isCheckRange_ThermBFloorWithinDwellingSiValue == true)
	{		
		RangeCheckFunction(-0.5,0.5,ThermBFloorWithinDwellingSiValue);
		isCheckRange_ThermBFloorWithinDwellingSiValue = false;
	}

	if( isCheckRange_ThermBFloorBetweenDwellingSiValue == true)
	{
        RangeCheckFunction(-0.5,0.5,ThermBFloorBetweenDwellingSiValue);
		isCheckRange_ThermBFloorBetweenDwellingSiValue = false;
	}

	if( isCheckRange_ThermBBalconyWithinDwellingSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBBalconyWithinDwellingSiValue);
		isCheckRange_ThermBBalconyWithinDwellingSiValue = false;
	}

	if( isCheckRange_ThermBBalconyBwDwellingSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBBalconyBwDwellingSiValue);
		isCheckRange_ThermBBalconyBwDwellingSiValue = false;
	}

	if( isCheckRange_ThermBEavesInsAtCelingSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBEavesInsAtCelingSiValue);
		isCheckRange_ThermBEavesInsAtCelingSiValue = false;
	}

	if( isCheckRange_ThermBEavesInsAtRafterSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBEavesInsAtRafterSiValue);
		isCheckRange_ThermBEavesInsAtRafterSiValue = false;
	}

	if( isCheckRange_ThermBGableInsAtCeilingSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBGableInsAtCeilingSiValue);
		isCheckRange_ThermBGableInsAtCeilingSiValue = false;
	}

	if( isCheckRange_ThermBGableInsAtRafterSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBGableInsAtRafterSiValue);
		isCheckRange_ThermBGableInsAtRafterSiValue = false;
	}

	if( isCheckRange_ThermBLengthOfNormalCornersSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBLengthOfNormalCornersSiValue );
		isCheckRange_ThermBLengthOfNormalCornersSiValue = false;
	}

	if( isCheckRange_ThermBLengthOfInvertedCornersSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBLengthOfInvertedCornersSiValue );
		isCheckRange_ThermBLengthOfInvertedCornersSiValue = false;
	}

	if( isCheckRange_ThermBPartBwDwellingLengthSiValue == true)
	{
		RangeCheckFunction(-0.5,0.5,ThermBPartBwDwellingLengthSiValue  );
		isCheckRange_ThermBPartBwDwellingLengthSiValue = false;
	}

	// Ventilation dialog
	if( isCheckRange_numsOpenFirePlaces == true)
	{		
        RangeCheckFunction(0,10,numsOpenFirePlaces);
		isCheckRange_numsOpenFirePlaces = false;
	}

	if( isCheckRange_numsOpenFlues == true)
	{
        RangeCheckFunction(0,10,numsOpenFlues);
		isCheckRange_numsOpenFlues = false; 
	}

	if( isCheckRange_numsFluelessGasFires == true)
	{       
		RangeCheckFunction(0,10,numsFluelessGasFires );
		isCheckRange_numsFluelessGasFires = false;
	}

	if( isCheckRange_numsExtractFans == true)
	{
		RangeCheckFunction(0,10,numsExtractFans );
		isCheckRange_numsExtractFans = false;
	}

	if( isCheckRange_numsPassiveVents == true)
	{
		RangeCheckFunction(0,10,numsPassiveVents);
		isCheckRange_numsPassiveVents = false;
	}

	if( isCheckRange_measuredQ50 == true)
	{
		RangeCheckFunction(0,10,measuredQ50);
		isCheckRange_measuredQ50 = false;
	}

	if( isCheckRange_numOfStoreys == true)
	{
		RangeCheckFunction(0,6,numOfStoreys);
		isCheckRange_numOfStoreys = false;
	}

	if( isCheckRange_SFP == true)
	{
		RangeCheckFunction(0,4,SFP);
		isCheckRange_SFP = false;
	}

	// Main heating dialog
	if( isCheckRange_mainHtEff == true)
	{	
		RangeCheckFunction(0,1000,  mainHtEffNominal);
		isCheckRange_mainHtEff = false;
	}

	if( isCheckRange_mainHtFractionSupplied == true)
	{
		RangeCheckFunction(0.5,1,mainHtFractionSupplied);
		isCheckRange_mainHtFractionSupplied = false;
	}

	// Secondary heating dilaog
	if( isCheckRange_secHtEff == true)
	{
		RangeCheckFunction(0,100,secHtEff);
		isCheckRange_secHtEff = false;
	}

	if( isCheckRange_secHtFraction == true)
	{
		RangeCheckFunction(0,100,secHtFraction);
		isCheckRange_secHtFraction = false;
	}

	// Water heating dialog
	if( isCheckRange_WHtCylDeclaredFactor == true)
	{
		RangeCheckFunction(0,100,WHtCylDeclaredFactor);
		isCheckRange_WHtCylDeclaredFactor = false;
	}

	if( isCheckRange_WHtCylVolume == true)
	{
		RangeCheckFunction(0,400,WHtCylVolume);
		isCheckRange_WHtCylVolume = false;
	}

	if( isCheckRange_WHtCylInsThickness == true)
	{
		RangeCheckFunction(0,500,WHtCylInsThickness);
		isCheckRange_WHtCylInsThickness = false;
	}

	if( isCheckRange_WHtEff == true)
	{
		RangeCheckFunction(0,100,WHtEff);
		isCheckRange_WHtEff = false;
	}

	// Renewables 1
	// SDHW
	if( isCheckRange_SHWApertureArea == true)
	{	
		RangeCheckFunction(0,12,SHWApertureArea );
		isCheckRange_SHWApertureArea = false;
	}

	if( isCheckRange_SHW_ZLCE == true)
	{
		RangeCheckFunction(0,100,SHW_ZLCE);
		isCheckRange_SHW_ZLCE = false;
	}

	if( isCheckRange_SHW_HeatLossCoefficient == true)
	{
		RangeCheckFunction(0,10,SHW_HeatLossCoefficient);
		isCheckRange_SHW_HeatLossCoefficient = false;
	}

	if( isCheckRange_SHWDedSolStoreVol == true)
	{
		RangeCheckFunction(0,400,SHWDedSolStoreVol );
		isCheckRange_SHWDedSolStoreVol = false;
	}

	// PV
	if( isCheckRange_installedPVPeakPower == true)
	{		
		RangeCheckFunction(0,10,installedPVPeakPower);
		isCheckRange_installedPVPeakPower = false;
	}

	// WT
	if( isCheckRange_WTNumOf == true)
	{		
		RangeCheckFunction(0,4,WTNumOf);
		isCheckRange_WTNumOf = false;
	}

	if( isCheckRange_WTDiameter == true)
	{
		RangeCheckFunction(0,10,WTDiameter);
		isCheckRange_WTDiameter = false;
	}

	if( isCheckRange_WTHeight == true)
	{
		RangeCheckFunction(0,20,WTHeight );
		isCheckRange_WTHeight = false;
	}

	// Renewables 2
	// uHydro
	if( isCheckRange_uHydroAnnualAvgHead == true)
	{
		RangeCheckFunction(0,10,uHydroAnnualAvgHead );
		isCheckRange_uHydroAnnualAvgHead = false;
	}

	if( isCheckRange_uHydroAnnualAvgFlow == true)
	{
		RangeCheckFunction(0,1000,uHydroAnnualAvgFlow );
		isCheckRange_uHydroAnnualAvgFlow = false;
	}

	if( isCheckRange_uHydroEff == true)
	{
		RangeCheckFunction(0,100,uHydroEff );
		isCheckRange_uHydroEff = false;
	}

	// uCHP
	if( isCheckRange_uCHPheatToPowerRatio == true)
	{		
		RangeCheckFunction(0,4,uCHPheatToPowerRatio );
		isCheckRange_uCHPheatToPowerRatio = false;
	}

	if( isCheckRange_uCHPElectricEff == true)
	{
		RangeCheckFunction(0,100,uCHPElectricEff );
		isCheckRange_uCHPElectricEff = false;
	}

	if( isCheckRange_uCHPHeatingEff == true)
	{
		RangeCheckFunction(0,100,uCHPHeatingEff );
		isCheckRange_uCHPHeatingEff = false;
	}

	if( isCheckRange_uCHPHeatingFraction == true)
	{
		RangeCheckFunction(0,1,uCHPHeatingFraction );
		isCheckRange_uCHPHeatingFraction = false;
	}

	// MVHR
	if( isCheckRange_MVHRThermalEff == true)
	{
		RangeCheckFunction(0,100,MVHRThermalEff );
		isCheckRange_MVHRThermalEff = false;
	}

	if(isCheckRange_TFA == true)
	{
		RangeCheckFunction(20,2000,TFA);
		isCheckRange_TFA = false;
	}
	
}
// RangeCheckFunction
// This function wil check range of a number
void RangeCheckFunction(double lowerLimit, double upperLimit, double number)
{
	char buffer[2000];

	CString variableName;
	CString variableUnit;

	// RESULTS
	if(isCheckRange_TFA == true)
	{
		variableName = "TFA";
		variableUnit = "m²";
	}
	
	// BUILT FORM

	// Storey area
	if(isCheckRange_areaStorey1 == true)
	{
		variableName = "Storey 1 area";
		variableUnit = "m²";
	}

	if(isCheckRange_areaStorey2 == true)
	{
		variableName = "Storey 2 area";
		variableUnit = "m²";
	}

	if(isCheckRange_areaStorey3 == true)
	{
		variableName = "Storey 3 area";
		variableUnit = "m²";
	}

	if(isCheckRange_areaStorey4 == true)
	{
		variableName = "Storey 4 area";
		variableUnit = "m²";
	}

	if(isCheckRange_areaStorey5 == true)
	{
		variableName = "Storey 5 area";
		variableUnit = "m²";
	}

	if(isCheckRange_areaStorey6 == true)
	{
		variableName = "Storey 6 area";
		variableUnit = "m²";
	}

	// Storey height
	if(isCheckRange_heightStorey1 == true)
	{
		variableName = "Storey 1 height";
		variableUnit = "m";
	}

	if(isCheckRange_heightStorey2 == true)
	{
		variableName = "Storey 2 height";
		variableUnit = "m";
	}

	if(isCheckRange_heightStorey3 == true)
	{
		variableName = "Storey 3 height";
		variableUnit = "m";
	}

	if(isCheckRange_heightStorey4 == true)
	{
		variableName = "Storey 4 height";
		variableUnit = "m";
	}

	if(isCheckRange_heightStorey5 == true)
	{
		variableName = "Storey 5 height";
		variableUnit = "m";
	}

	if(isCheckRange_heightStorey6 == true)
	{
		variableName = "Storey 6 height";
		variableUnit = "m";
	}

    // WINDOWS
	// Areas
	if(isCheckRange_winNArea == true)
	{
		variableName = "North Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winNEArea == true)
	{
		variableName = "North-East Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winEArea == true)
	{
		variableName = "East Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winSEArea == true)
	{
		variableName = "South-East Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winSArea == true)
	{
		variableName = "South Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winSWArea == true)
	{
		variableName = "South-West Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winWArea == true)
	{
		variableName = "West Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_winNWArea == true)
	{
		variableName = "North-West Window area";
		variableUnit = "m²";
	}

	if(isCheckRange_rooflightsArea == true)
	{
		variableName = "Rooflights area";
		variableUnit = "m²";
	}

	// Solar Transmittance
	if(isCheckRange_winNSolTrans == true)
	{
        variableName = "North Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winNESolTrans == true)
	{
		variableName = "North-East Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winESolTrans == true)
	{
		variableName = "East Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winSESolTrans == true)
	{
		variableName = "South-East Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winSSolTrans == true)
	{
		variableName = "South Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winSWSolTrans == true)
	{
		variableName = "South-West Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winWSolTrans == true)
	{
		variableName = "West Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_winNWSolTrans == true)
	{
		variableName = "North-West Window solar transmittance";
		variableUnit = " ";
	}

	if(isCheckRange_rooflightsSolTrans == true)
	{
		variableName = "Rooflights solar transmittance";
		variableUnit = " ";
	}

	// Frame factor
	if(isCheckRange_winNFrameFactor == true)
	{
		variableName = "North Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_winNEFrameFactor == true)
	{		
		variableName = "North-East Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_winEFrameFactor == true)
	{
		variableName = "East Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_winSEFrameFactor == true)
	{
		variableName = "South-East Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_winSFrameFactor == true)
	{
       variableName = "South Window frame factor";
	   variableUnit = " ";
	}
	if(isCheckRange_winSWFrameFactor ==true)
	{
       variableName = "South-West Window frame factor";
	   variableUnit = " ";
	}
	if(isCheckRange_winWFrameFactor == true)
	{
		variableName = "West Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_winNWFrameFactor == true)
	{
        variableName = "North-West Window frame factor";
		variableUnit = " ";
	}
	if(isCheckRange_rooflightsFrameFactor == true)
	{
       variableName = "Rooflights frame factor";
	   variableUnit = " ";
	}
	if(isCheckRange_fractionLEL == true)
	{		
		variableName = "Fraction of low energy lighting(0-100 %)";
		variableUnit = " ";
	}

	// AREA AND U-VALUE
	// Areas
	if(isCheckRange_grossAreaWall1 == true)
	{
        variableName = "Wall type 1 gross area";
		variableUnit = "m²";
	}

	if( isCheckRange_groosAreaRoof1 == true)
	{
        variableName = "Roof type 1 gross area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaDoors== true)
	{
        variableName = "Doors net area";
		variableUnit = "m²";	
	}

	if( isCheckRange_netAreaGF == true)
	{
       variableName = "Ground floor net area";
	   variableUnit = "m²";
	}

	if( isCheckRange_netAreaExFloor == true)
	{
        variableName = "Exposed floor net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaWallType2 == true)
	{
		variableName = "Wall type 2 net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaRoofType2 == true)
	{
		variableName = "Roof type 2 net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaPartyWall == true)
	{
        variableName = "Party wall net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaPartyFloor == true)
	{
       variableName = "Party floor net area";
	   variableUnit = "m²";
	}

	if( isCheckRange_netAreaPartyCeiling == true)
	{
		variableName = "Party ceiling net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaInternalWall == true)
	{
		variableName = "Internal wall net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaInternalFloor == true)
	{		
		variableName = "Internal floor net area";
		variableUnit = "m²";
	}

	if( isCheckRange_netAreaInternalCeiling == true)
	{
		variableName = "Internal ceiling net area";
		variableUnit = "m²";
	}

	//U-values
	if( isCheckRange_UvalueDoors == true)
	{
        variableName = "Doors U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueWindows == true)
	{
        variableName = "Windows U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueRooflights == true)
	{
       variableName = "Rooflights U-value";
	   variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueGF == true)
	{
        variableName = "Ground floor U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueExposedFloor == true)
	{
		variableName = "Exposed floor U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueWallType1 == true)
	{
       variableName = "Wall type 1 U-value";
	   variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueWallType2 == true)
	{
		variableName = "Wall type 2 U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueRoofTYpe1 == true)
	{
		variableName = "Roof type 1 U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvalueRoofType2 == true)
	{
		variableName = "Roof type 2 U-value";
		variableUnit = "W/m³K";
	}

	if( isCheckRange_UvaluePartyWall == true)
	{
		variableName = "Party wall U-value";
		variableUnit = "W/m³K";
	}

	// k-values
	if( isCheckRange_kValueGF == true)
	{
		variableName = "Ground floor k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueExpFloor == true)
	{
		variableName = "Exposed floor k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueWallType1 == true)
	{
		variableName = "Wall type 1 k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueWallType2 == true)
	{
		variableName = "Wall type 2 k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueRoofType1 == true)
	{	
		variableName = "Roof type 1 k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueRoofType2 == true)
	{
		variableName = "Roof type 2 k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValuePartyWall == true)
	{
		variableName = "Party wall k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValuePartyFloor == true)
	{
		variableName = "Party floor k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValuePartyCeiling == true)
	{
		variableName = "Party ceiling k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueIntWall == true)
	{
		variableName = "Internal wall k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueIntFloor == true)
	{
		variableName = "Internal floor k-value";
		variableUnit = "kJ/m²K";
	}

	if( isCheckRange_kValueIntCeiling == true)
	{
		variableName = "Internal ceiling k-value";
		variableUnit = "kJ/m²K";
	}

	// THERMAL BRIDGING
	// y-value
	if( isCheckRange_yValueEntry == true)
	{
		variableName = "y-value";
		variableUnit = " ";
	}

	// Length
	if( isCheckRange_ThermBGFPerimeter == true)
	{
		variableName = "Ground floor perimeter";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBFloorWithingDwellinPerimeter == true)
	{
		variableName = "Floor within dwelling perimeter";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBFloorBetweenDwellinPerimeter == true)
	{
		variableName = "Floor between dwelling perimeter";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBBalconyWithingDwellingLength == true)
	{
		variableName = "Balcony within dwelling perimeter length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBBalconyBetweenDwellingLength == true)
	{
		variableName = "Balcony between dwelling perimeter length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBEavesAtCeiling == true)
	{
		variableName = "Eaves (insulation at ceiling) length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBEavesAtRafter == true)
	{
		variableName = "Eaves (insulation at rafter) length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBGableAtCeiling == true)
	{
		variableName = "Gable (insulation at ceiling) length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBGableAtRafter == true)
	{
		variableName = "Gable (insulation at rafter) length";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBLengthNormalCorners == true)
	{
		variableName = "Total length of noraml corners";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBLengthInvertedCorners == true)
	{
		variableName = "Total length of inverted corners";
		variableUnit = "m";
	}

	if( isCheckRange_ThermBPartWallBetweenDwelling == true)
	{
		variableName = "Party wall between dwelling length";
		variableUnit = "m";
	}

	// Si-value
	if( isCheckRange_ThermBGFPerimeterSiValue == true)
	{
		variableName = "Ground floor ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBFloorWithinDwellingSiValue == true)
	{		
		variableName = "Floor within dwelling ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBFloorBetweenDwellingSiValue == true)
	{
        variableName = "Floor between dwelling ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBBalconyWithinDwellingSiValue == true)
	{
		variableName = "Balcony within dwelling ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBBalconyBwDwellingSiValue == true)
	{
		variableName = "Balcony between dwelling ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBEavesInsAtCelingSiValue == true)
	{
		variableName = "Eaves (insulation at ceiling) ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBEavesInsAtRafterSiValue == true)
	{
		variableName = "Eaves (insulation at rafter) ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBGableInsAtCeilingSiValue == true)
	{
		variableName = "Gable (insulation at ceiling) ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBGableInsAtRafterSiValue == true)
	{
		variableName = "Gable (insulation at rafter) ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBLengthOfNormalCornersSiValue == true)
	{
		variableName = "Noraml corners ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBLengthOfInvertedCornersSiValue == true)
	{
		variableName = "Inverted corners ?-value";
		variableUnit = "W/mK";
	}

	if( isCheckRange_ThermBPartBwDwellingLengthSiValue == true)
	{
		variableName = "Party wall between dwelling ?-value";
		variableUnit = "W/mK";
	}

	// Ventilation dialog
	if( isCheckRange_numsOpenFirePlaces == true)
	{		
		variableName = "Open fire places";
		variableUnit = " ";
	}

	if( isCheckRange_numsOpenFlues == true)
	{
        variableName = "Open flues"; 
		variableUnit = " ";
	}

	if( isCheckRange_numsFluelessGasFires == true)
	{       
		variableName = "Flueless gas fires";
		variableUnit = " ";
	}

	if( isCheckRange_numsExtractFans == true)
	{
		variableName = "Extract fans";
		variableUnit = " ";
	}

	if( isCheckRange_numsPassiveVents == true)
	{
		variableName = "Passive vents";
		variableUnit = " ";
	}

	if( isCheckRange_measuredQ50 == true)
	{
		variableName = "Measured q50";
		variableUnit = " ";
	}

	if( isCheckRange_numOfStoreys == true)
	{
		variableName = "Number of storeys";
		variableUnit = " ";
	}

	if( isCheckRange_SFP == true)
	{
		variableName = "SFP";
		variableUnit = "W/l/s";
	}

	// Main heating dialog
	if( isCheckRange_mainHtEff == true)
	{	
		variableName = "Efficiency of main heating";
		variableUnit = "%";
	}

	if( isCheckRange_mainHtFractionSupplied == true)
	{
		variableName = "Fraction of main heating";
		variableUnit = " ";
	}

	// Secondary heating dilaog
	if( isCheckRange_secHtEff == true)
	{
		variableName = "Efficiency of secondary heating";
		variableUnit = "%";
	}

	if( isCheckRange_secHtFraction == true)
	{
		variableName = "Fraction of secondary heating";
		variableUnit = " ";
	}

	// Water heating dialog
	if( isCheckRange_WHtCylDeclaredFactor == true)
	{
		variableName = "Declared factor";
		variableUnit = "kWh/day ";
	}

	if( isCheckRange_WHtCylVolume == true)
	{
		variableName = "Cylinder volume";
		variableUnit = "l";
	}

	if( isCheckRange_WHtCylInsThickness == true)
	{
		variableName = "Insulation thickness of cylinder";
		variableUnit = "mm";
	}

	if( isCheckRange_WHtEff == true)
	{
		variableName = "Efficieny";
		variableUnit = "%";
	}

	// Renewables 1
	// SDHW
	if( isCheckRange_SHWApertureArea == true)
	{	
		variableName = "Aperture/groos area of solar pannel";
		variableUnit = "m²";
	}

	if( isCheckRange_SHW_ZLCE == true)
	{
		variableName = "Zero loss collector efficiency";
		variableUnit = "%";
	}

	if( isCheckRange_SHW_HeatLossCoefficient == true)
	{
		variableName = "Heat loss coefficient of collector";
		variableUnit = " ";
	}

	if( isCheckRange_SHWDedSolStoreVol == true)
	{
		variableName = "Dedicated solar store volume";
		variableUnit = "l";
	}

	// PV
	if( isCheckRange_installedPVPeakPower == true)
	{		
		variableName = "Installed peak power for PV";
		variableUnit = "kWp";
	}

	// WT
	if( isCheckRange_WTNumOf == true)
	{		
		variableName = "Number of wind turbines";
		variableUnit = " ";
	}

	if( isCheckRange_WTDiameter == true)
	{
		variableName = "Diameter of wind turbine";
		variableUnit = "m";
	}

	if( isCheckRange_WTHeight == true)
	{
		variableName = "Height of wind turbine";
		variableUnit = "m";
	}

	// Renewables 2
	// uHydro
	if( isCheckRange_uHydroAnnualAvgHead == true)
	{
		variableName = "Average annual head";
		variableUnit = "m";
	}

	if( isCheckRange_uHydroAnnualAvgFlow == true)
	{
		variableName = "Average annual flow";
		variableUnit = "l/s";
	}

	if( isCheckRange_uHydroEff == true)
	{
		variableName = "Efficiency of electricity generator";
		variableUnit = "%";
	}

	// uCHP
	if( isCheckRange_uCHPheatToPowerRatio == true)
	{		
		variableName = "CHP heat to power ratio";
		variableUnit = " ";
	}

	if( isCheckRange_uCHPElectricEff == true)
	{
		variableName = "CHP electric effeciency";
		variableUnit = "%";
	}

	if( isCheckRange_uCHPHeatingEff == true)
	{
		variableName = "CHP heating effeciency";
		variableUnit = "%";
	}

	if( isCheckRange_uCHPHeatingFraction == true)
	{
		variableName = "CHP heating fraction";
		variableUnit = " ";
	}

	// MVHR
	if( isCheckRange_MVHRThermalEff == true)
	{
		variableName = "MVHR thermal efficiency";
		variableUnit = "%";
	}

	// Create text for message box
	sprintf ( buffer, "The value of %s should be between %.0f and %.0f %s." , variableName, lowerLimit, upperLimit,variableUnit );
	
	if((number<lowerLimit) || (number>upperLimit))
	{
		// Display message box
		MessageBox(0,buffer,"Warning",MB_OK);
	}
}

// 
// Function to add space character between two consecutive commas
// This will be used while reading data from csv file to avoid errors
// IMPORTANT: Note strtok() fn FAILS when no character found between two consecutive string tokens
void strSpecialCopy(char *sourceStr, char *destStr)
{
      int i = 0, j = 0;
      char lastChar = 0, currChar = 0; 

      while (sourceStr[i] != NULL)
      {
            currChar = sourceStr[i++];
            if ( (lastChar == ',')  && (currChar == ',') )
            {
                  destStr[j++] = ' ';
            }

            destStr[j++] = currChar;
            lastChar = currChar;   
      }

       destStr[j] = NULL;
}

void SetAllValuesToDefault()
{
	//-------------------------
	// 1. JOB DETAILS
	//-------------------------
	JobDetRefNum = " "; 
	assessorName = " "; 
	JobDetComments = " "; 

	propertyFlatNameorNum = " "; 
	propertyLetter = " "; 
	propertyHouseNum = " "; 
	propertyStreet = " "; 
	propertyLocality = " "; 
	propertyDistrict = " "; 
	propertyTown = " "; 
	propertyCounty = " "; 
	propertyPostCode = " "; 

	clientFlatNameorNum = " "; 
	clientLetter = " "; 
	clientHouseorBlockNum = " "; 
	clientStreet = " "; 
	clientLocality = " "; 
	clientDistrict = " "; 
	clientTown = " "; 
	clientCounty = " "; 
	clientPostCode = " "; 

	//--------------------------
	// 2. BUILT FORM
	//--------------------------

	//-----------------------------------------------
	// YEAR BUILT
	//-----------------------------------------------
	yearPropertBuilt = " "; 

	//-----------------------------------------------
	// SHELTERED SIDES
	//-----------------------------------------------
	dwellingShelteredSides = 1;

	//-----------------------------------------------
	// BASEMENT FOR STOREYS SELECTED
	//-----------------------------------------------	
	storey1Basement = "no";
	storey2Basement = "no";
	storey3Basement = "no";
	storey4Basement = "no";
	storey5Basement = "no";
	storey6Basement = "no";

	//-----------------------------------------------
	// TYPE OF DWELLING
	//-----------------------------------------------
	dwellingType = "New dwelling as designed";

	//-----------------------------------------------
	// PROPERTY TYPE
	//-----------------------------------------------
	builtForm = "House";

	//-----------------------------------------------
	// BUILT FORM
	//-----------------------------------------------
	Detachment    = "Detached" ;

	//-----------------------------------------------
	// FLAT TYPE
	//-----------------------------------------------
	FlatPosition     = "Ground floor";

	//-----------------------------------------------
	// DEGREE DAY LOCATION
	//-----------------------------------------------
	locationString = "Select weather..";


	//-----------------------------------------------
	// TERRAIN
	//-----------------------------------------------
	dwellingTerrain = "Dense urban";

	//-----------------------------------------------
	// NUMBER OF STOREYS SELECTED
	//-----------------------------------------------
	storey1 = "no";
	storey2 = "no";
	storey3 = "no";
	storey4 = "no";
	storey5 = "no";
	storey6 = "no";

	storey1Area = 0.0;
	storey2Area = 0.0;
	storey3Area = 0.0;
	storey4Area = 0.0;
	storey5Area = 0.0;
	storey6Area = 0.0;

	storey1Height = 0.0;
	storey2Height = 0.0;
	storey3Height = 0.0;
	storey4Height = 0.0;
	storey5Height = 0.0;
	storey6Height = 0.0;

	//-----------------------------------------------
	// LEVEL OF STOREYS 
	//-----------------------------------------------		
	storey1Level = "Lowest occupied";
	storey2Level = "1";
	storey3Level = "2";
	storey4Level = "3";
	storey5Level = "4";
	storey6Level = "5";

	//------------------------------------
	// 3. WINDOWS
	//------------------------------------
	winNArea = 0;
	winNEArea = 0;
	winEArea = 0;
	winSEArea = 0;
	winSArea = 0;
	winSWArea = 0;
	winWArea = 0;
	winNWArea = 0;
	rooflightsArea = 0;

	winNSolTrans = 0;
	winNESolTrans = 0;
	winESolTrans = 0;
	winSESolTrans = 0;
	winSSolTrans = 0;
	winSWSolTrans = 0;
	winWSolTrans = 0;
	winNWSolTrans = 0;
	rooflightsSolTrans = 0;

	winNFrameFactor = 0;
	winNEFrameFactor = 0;
	winEFrameFactor = 0;
	winSEFrameFactor = 0;
	winSFrameFactor = 0;
	winSWFrameFactor = 0;
	winWFrameFactor = 0;
	winNWFrameFactor = 0;
	rooflightsFrameFactor = 0;

	totalGlzArea = 0;
	fractionLEL = 0;

	winOvershading = "Very little";
	winGlazing = "Single";

	//------------------------------------
	// 4. AREAS AND U-VALUES
	//------------------------------------
	grossAreaWall1 = 0;
	groosAreaRoof1  = 0;
	netAreaDoors   = 0;
	netAreaWindows = 0;
	netAreaRoofLights = 0;
	netAreaGF = 0;
	netAreaExFloor   = 0;
	netAreaWallType1 = 0;
	netAreaWallType2 = 0;
	netAreaRoofType1 = 0;
	netAreaRoofType2 = 0;
	netAreaPartyWall = 0;
	netAreaPartyFloor = 0;
	netAreaPartyCeiling  = 0;
	netAreaInternalWall  = 0;
	netAreaInternalFloor = 0;
	netAreaInternalCeiling = 0;

	UvalueDoors = 0;
	UvalueWindows = 0;
	UvalueRooflights = 0;
	UvalueGF = 0;
	UvalueExposedFloor = 0;
	UvalueWallType1 = 0;
	UvalueWallType2 = 0;
	UvalueRoofTYpe1 = 0;
	UvalueRoofType2 = 0;
	UvaluePartyWall = 0;

	kValueGF        = 0;
	kValueExpFloor  = 0;
	kValueWallType1 = 0;
	kValueWallType2 = 0;
	kValueRoofType1 = 0;
	kValueRoofType2 = 0;
	kValuePartyWall = 0;
	kValuePartyFloor = 0;
	kValuePartyCeiling = 0;
	kValueIntWall      = 0;
	kValueIntFloor     = 0;
	kValueIntCeiling   = 0;

	thermalMassParameter = 0;
	livingRoomFraction   = 0;

	//------------------------------------
	// 5. THERMAL BRIDGING
	//------------------------------------
	yValueEntry = 0;
	ThermBGFPerimeter = 0;
	ThermBFloorWithingDwellinPerimeter = 0;
	ThermBFloorBetweenDwellinPerimeter = 0;
	ThermBBalconyWithingDwellingLength = 0;
	ThermBBalconyBetweenDwellingLength = 0;
	ThermBEavesAtCeiling = 0;
	ThermBEavesAtRafter  = 0;
	ThermBGableAtCeiling = 0;
	ThermBGableAtRafter  = 0;
	ThermBLengthNormalCorners     = 0;
	ThermBLengthInvertedCorners   = 0;
	ThermBPartWallBetweenDwelling = 0;

	ThermBMetalBoxLintelSiValue = 0;
	ThermBOtherLintelsSiValue  = 0;
	ThermBSillSiValue = 0;
	ThermBJambSiValue = 0;
	ThermBGFPerimeterSiValue = 0;
	ThermBFloorWithinDwellingSiValue   = 0;
	ThermBFloorBetweenDwellingSiValue  = 0;
	ThermBBalconyWithinDwellingSiValue = 0;
	ThermBBalconyBwDwellingSiValue = 0;
	ThermBEavesInsAtCelingSiValue  = 0;
	ThermBEavesInsAtRafterSiValue  = 0;
	ThermBGableInsAtCeilingSiValue = 0;
	ThermBGableInsAtRafterSiValue  = 0;
	ThermBLengthOfNormalCornersSiValue   = 0;
	ThermBLengthOfInvertedCornersSiValue = 0;
	ThermBPartBwDwellingLengthSiValue    = 0;

	ThermBMetalBoxLintelResult = 0;
	ThermBOtherLintelsResult = 0;
	ThermBSillResult = 0;
	ThermBJambResult = 0;
	ThermBGFPerimeterResult = 0;
	ThermBFloorWithinDwellingPerimeterResult  = 0;
	ThermBFloorBetweenDwellingPerimeterResult = 0;
	ThermBBalcWithDwellingLengthResult  = 0;
	ThermBBalconyBwDwellingLengthResult = 0;
	ThermBEavesInsCeilingResult = 0;
	ThermBEavesInsRafterResult  = 0;
	ThermBGableInsCeilingResult = 0;
	ThermBGableInsRafterResult  = 0;
	ThermBLengthNormalCornersResult   = 0;
	ThermBLengthInvertedCornersResult = 0;
	ThermBPartyWallBwDwellingResult   = 0;

	ThermBMetalBoxLintelUserDef = "No";
	ThermBOtherLintelUserDef = "No";
	ThermBSillUserDef ="No";
	ThermBJambUserDef = "No";
	ThermBGFPerimeterUserDef = "No";
	ThermBFloorWithinDwellingUserDef = "No";
	ThermBFloorBwDwellingUserDef ="No";
	ThermBBalcWithinDwellingLengthUserDef = "No";
	ThermBBalcBwDwellingLengthUserDef = "No";
	ThermBEavesInsAtCeilingUserDef = "No";
	ThermBEavesInsAtRafterUserDef = "No";
	ThermBGableInsAtCeilingUserDef = "No";
	ThermBGableInsAtRafetUserDef ="No";
	ThermBLengthOfNormalCornersUserDef = "No";
	ThermBLengthOfInvertedCornersUserDef = "No";
	ThermBPartWallBetweenDwellingUserDef ="No";

	//------------------------------------
	// 6. VENTLATION
	//------------------------------------
	numsOpenFirePlaces   = 0;
	numsOpenFlues        = 0;
	numsFluelessGasFires = 0;
	numsExtractFans  = 0;
	numsPassiveVents = 0;

	mechVentType = "Not present (natural)";
	MVHRThermalEff = 0;
	SFP = 0;

	numOfShelteredSides = 0;		
	pressureTestYN = "No";
	measuredQ50    = 0;
	numOfStoreys   = 0;
	structInf= 0.25;
	floorInf= 0.1;
	draughtLobby = "No";
	perWindowDraughtStripped= 100;

	// Variables no longer needed
	pressureTestScotland = " ";
	designAirPermeability = " ";
	accreditedDetailsScotland = " ";
	seekExemptionForLT3Dwellings = " ";

	designAirPermRate  = 0;
	asBuiltAirPermRate = 0;

	airPermMeasuredInDwelling = " ";
	asBuiltRef = " ";
	asBuiltTestDate = " ";		
	isACPresent = " ";
	ACEnergyUse = 0;

	//------------------------------------
	// 7. MAIN HEATING
	//------------------------------------
	mainFuel          = "Mains gas";
	electricityTarrif = "Standard";
	mainHtType        = "Boiler";
	mainHtEffFrom     = "Manufacturer declaration";
	boilerType        = "Standard";
	isFanFluePresent  = "No";
	mainHtControls    = "No time or thermostatic control of room temperature";
	mainHtEmitter     = "Radiators";
	isIterlockPresent = "No";
	isPumpInHeatedSpace = "No";
	mainHtSystem = "Direct acting";

	mainHtManufacturerDesc = "Generic boiler";	
	mainHtTestMethod = " ";	
	mainHtEffNominal              = 0;
	mainHtEff     =0;

	mainHtEffAdj  = 0;
	mainHtTempAdj = 0;
	mainHtFractionSupplied = 1;

	// Variables not used
	isSecBoilerFuelPresent = " ";			
	mainHtCompensator = " ";

	//------------------------------------
	// 8. MAIN HEATING DETAILS
	//------------------------------------
	oilPumpInHeatedSpace = " ";
	oilBoilerInstalled = " ";

	CPSUoperatingTemp = 0;
	heatEmmFromCase   = 0;
	heatTransferredToWater = 0;

	smokeControlledArea = " ";
	isThereCHP = " ";
	CHPfuel = " ";

	fractOfHtFromCHP = 0;
	elecEffOfCHP     = 0;
	heatingEffOfCHP  = 0;

	secComBoilerFuel = " ";
	secComBoilerSystem = " ";

	secComBoilerEff = 0;
	secComBoilerFractOfHtFromBoiler2 = 0;
	secComBoilerManufactDesc = " ";

	//------------------------------------
	// 9. SECONDARY HEATING
	//------------------------------------
	isThereSecHeating = "No";
	secHtEffFrom  = "Manufacturer declaration";
	secHtFuel     = "Mains gas";
	secHtEff      = 90;
	secHtFraction = 0;

	// Variables not being used
	secHtOpenFlueChimney = " ";
	secHtUnconnectedGasPoint = " ";
	secHtSystem = " ";
	secHtManufactDesc = " ";
	secHtTestMethod = " ";

	//------------------------------------
	// 10. WATER HEATING
	//------------------------------------
	btnWaterHtFromMainState = 1;
	WHtype = "Cylinder - indirect";
	WHtCylinderWithinDwelling = "No";
	WHtFuel;
	WHtWaterSepTimed = "No";

	WHtCylManufactLossFactor = "Unknown";
	WHtCylInsType = "Loose jacket";
	WHtCylThermostat = "No";

	WHtCylInHeatedSpace = "No";
	WHtCylPrimaryPipeworkInsulated = "No";
	WHtCylPumpedPrimarySystem = "No";

	WHtTSnCPSUinSingleUnit = "Yes";
	WHtTSnCPSUPrimaryPipeworkLT1_5m = "Yes";
	WHtTSnCPSUstoreInAirCupbrd = "Yes";

	WHtCombiKeepHotYN = "Yes";
	DHWfromCommunityScheme = "Yes";
	DHWComSchemeSystem = "Yes";
	WHtHeatPumpUsesImmer = "Yes";

	WHtUsesSummerImmer = "Yes";
	WHtCylDeclaredFactor = 0;
	WHtCylVolume         = 0;
	WHtCylInsThickness   = 0;
	WHtEff    = 0;
	WHtEffAdj = 0;		

	//------------------------------------
	// 11. RENEWABLES 1
	//------------------------------------
	isSHWPresent = "No";
	isPVPresent  = "No";
	isWTPresent  = "No";
	uHydroyn	 = "No";
	uCHPyn		 = "No";
	MVHRyn		 = "No";

	SHWCollectorType = "Flat plate - glazed";
	SHWCollectorOrientation = "South";
	SHWCollectorTilt = "30 deg";
	SHWOvershading   = "Modest 20%-60%";
	isSHWAreaGross   = "Yes";
	isSHWSolarStoreCombined = "Yes";
	SHWSolarCircPump = "Electrically powered";
	SHWApertureArea = 4.0;
	SHW_ZLCE = 70;
	SHW_HeatLossCoefficient = 6;
	SHWDedSolStoreVol = 100;

	PVCollectorOrientation = "South";
	PVCollectorTilt = "30 deg";
	PVOvershading = "Modest 20%-60%";

	dwellingExposure = "Average";
	CHPFuel = "Mains gas";
				
	isRENAdditionalElectGenerated = " ";
	RENAddiationalElecGenerated = 0;
	REN_TFA = 0;

	installedPVPeakPower = 2;
	WTNumOf    = 1;
	WTDiameter = 2;
	WTHeight   = 5;

	//------------------------------------
	// 12. RENEWABLES 2
	//------------------------------------
	uHydroAnnualAvgHead = 4;
	uHydroAnnualAvgFlow = 50;
	uHydroEff = 60;
	uHydroAnnualEnergy = 0;

	uCHPheatToPowerRatio = 2;
	uCHPElectricEff      = 40;
	uCHPHeatingEff       = 50;
	uCHPHeatingFraction  = 1;
	uCHPAnnualElectricity     = 0;

	uHydroyn	 = "No";
	uCHPyn		 = "No";
	MVHRyn		 = "No";
	CHPFuel = "Mains gas";

	MVHRThermalEff = 75;

	FGHRSpresent = "No";
	FGHRSstore = "No";
	FGHRSstoreVolume     = 400;
	FGHRSusefulFracHtRec_kf1 = 0.5;
	FGHRSfittedMain      = "Yes";
	FGHRSfittedSec       = "No";
	//FGHRStype			 = "system 1";
	determineFGHRStype =  "No";
	FGHRStotFracHeatRec_kf2  = 0.5;
	FGHRSauxelec   = 0.5;
	FGHRSpvPoweredHt     = "No";
	FGHRSpvPkPower		 = 1.1;
	FGHRSpvOrientation = "South";
	FGHRSpvTilt			 = "Horizontal";
	FGHRSpvOvershading   = "Heavy > 80%";
	FGHRScableLoss		 = 0.2;

	WWHRSpresent = "No";
	WWHRSnumOfRooms  = 1;
	WWHRSnumMixerShowersWithBath1    = 1;
	WWHRSnumMixerShowersWithoutBath1 = 1;
	WWHRSnumMixerShowersWithBath2   = 1;
	WWHRSnumMixerShowersWithoutBath2 = 1;

	//----------------------------
	//RESULTS
	//----------------------------		
	iStat = 0;
	dwellingVoulme = 0;
	SFP   = 0;
	auxillaryElectricity   = 0;
	
	numOfOccupants= 0;
	TFA= 0;
	EB= 0;
	C1= 0;
	ZL= 0;
	gL= 0;
	GL_total= 0;
	C2= 0;
	lightElectricity = 0;

	Vd_avg= 0;
	DHW_energy= 0;
	distributionLoss= 0;
	tempFactor= 0;
	storageLoss= 0;
	lossFactor= 0;
	tankVolume= 0;
	volumeFacor= 0;
	heatLossFactor= 0;
	srorageLoss;
	primaryCircuitLoss= 0;
	F_u= 0;
	combiLoss= 0;
	solarDHWInput= 0;
	domesticHotWaterSupply = 0;
	btnWaterHtFromMainState = 1;

	//---------------------------------------------------------
	// GLOBAL VARIABLES FOR MULTISCALING
	//---------------------------------------------------------
	numOfDwellings = 1;
	caseOfDwellings = "Base";

	is_base_selected = false;
	is_imp1_selected = false;
	is_imp2_selected = false;
	is_imp3_selected = false;
	is_imp4_selected = false;
	is_imp5_selected = false;

	baseSelected = 0;
	imp1Selected = 0;
	imp2Selected = 0;
	imp3Selected = 0;
	imp4Selected = 0;
	imp5Selected = 0;
}


void WriteSHCSDataToDialogs()
{
	// line 00

	//-----------------------------------------------
	// 1. TYPE OF DWELLING
	//-----------------------------------------------
	dwellingType = "Other";

	//-------------------------
	// 2. JOB DETAILS, all blanks
	//-------------------------
	JobDetRefNum = " "; 
	assessorName = " "; 
	JobDetComments = " "; 

	propertyFlatNameorNum = " "; 
	propertyLetter = " "; 
	propertyHouseNum = " "; 
	propertyStreet = " "; 
	propertyLocality = " "; 
	propertyDistrict = " "; 
	propertyTown = " "; 
	propertyCounty = " "; 
	propertyPostCode = " "; 

	clientFlatNameorNum = " "; 
	clientLetter = " "; 
	clientHouseorBlockNum = " "; 
	clientStreet = " "; 
	clientLocality = " "; 
	clientDistrict = " "; 
	clientTown = " "; 
	clientCounty = " "; 
	clientPostCode = " "; 

	//-----------------------------------------------
	// 3. WEATHER
	//-----------------------------------------------
	// Do not change, as selected form overview tab

	//-----------------------------------------------
	// 4. SHELTERED SIDES
	//-----------------------------------------------
	dwellingShelteredSides = 1;

	//-----------------------------------------------
	// 5. TERRAIN
	//-----------------------------------------------
	dwellingTerrain = "Dense urban";

	//------------------------------------
	// 6. THERMAL BRIDGING
	//------------------------------------
	ThermBGFPerimeter = 0;
	ThermBFloorWithingDwellinPerimeter = 0;
	ThermBFloorBetweenDwellinPerimeter = 0;
	ThermBBalconyWithingDwellingLength = 0;
	ThermBBalconyBetweenDwellingLength = 0;
	ThermBEavesAtCeiling = 0;
	ThermBEavesAtRafter  = 0;
	ThermBGableAtCeiling = 0;
	ThermBGableAtRafter  = 0;
	ThermBLengthNormalCorners     = 0;
	ThermBLengthInvertedCorners   = 0;
	ThermBPartWallBetweenDwelling = 0;

	ThermBMetalBoxLintelSiValue = 0;
	ThermBOtherLintelsSiValue  = 0;
	ThermBSillSiValue = 0;
	ThermBJambSiValue = 0;
	ThermBGFPerimeterSiValue = 0;
	ThermBFloorWithinDwellingSiValue   = 0;
	ThermBFloorBetweenDwellingSiValue  = 0;
	ThermBBalconyWithinDwellingSiValue = 0;
	ThermBBalconyBwDwellingSiValue = 0;
	ThermBEavesInsAtCelingSiValue  = 0;
	ThermBEavesInsAtRafterSiValue  = 0;
	ThermBGableInsAtCeilingSiValue = 0;
	ThermBGableInsAtRafterSiValue  = 0;
	ThermBLengthOfNormalCornersSiValue   = 0;
	ThermBLengthOfInvertedCornersSiValue = 0;
	ThermBPartBwDwellingLengthSiValue    = 0;

	ThermBMetalBoxLintelResult = 0;
	ThermBOtherLintelsResult = 0;
	ThermBSillResult = 0;
	ThermBJambResult = 0;
	ThermBGFPerimeterResult = 0;
	ThermBFloorWithinDwellingPerimeterResult  = 0;
	ThermBFloorBetweenDwellingPerimeterResult = 0;
	ThermBBalcWithDwellingLengthResult  = 0;
	ThermBBalconyBwDwellingLengthResult = 0;
	ThermBEavesInsCeilingResult = 0;
	ThermBEavesInsRafterResult  = 0;
	ThermBGableInsCeilingResult = 0;
	ThermBGableInsRafterResult  = 0;
	ThermBLengthNormalCornersResult   = 0;
	ThermBLengthInvertedCornersResult = 0;
	ThermBPartyWallBwDwellingResult   = 0;

	ThermBMetalBoxLintelUserDef = "No";
	ThermBOtherLintelUserDef = "No";
	ThermBSillUserDef ="No";
	ThermBJambUserDef = "No";
	ThermBGFPerimeterUserDef = "No";
	ThermBFloorWithinDwellingUserDef = "No";
	ThermBFloorBwDwellingUserDef ="No";
	ThermBBalcWithinDwellingLengthUserDef = "No";
	ThermBBalcBwDwellingLengthUserDef = "No";
	ThermBEavesInsAtCeilingUserDef = "No";
	ThermBEavesInsAtRafterUserDef = "No";
	ThermBGableInsAtCeilingUserDef = "No";
	ThermBGableInsAtRafetUserDef ="No";
	ThermBLengthOfNormalCornersUserDef = "No";
	ThermBLengthOfInvertedCornersUserDef = "No";
	ThermBPartWallBetweenDwellingUserDef ="No";

	//--------------------------
	// 7. PRESSURE TEST
	//--------------------------
	pressureTestYN = "No";

	//--------------------------
	// 8. STRUCT INFILTRATION
	//--------------------------
	structInf= 0.25;

	//--------------------------
	// 9. SUSPENDED FLOOR INFILTRATION
	//--------------------------
	floorInf= 0.1;

	//--------------------------
	// 10. 
	draughtLobby = "No";

	//--------------------------
	// 11.  
	perWindowDraughtStripped= 100;

	//--------------------------
	// 12. 
	mainHtType        = "Boiler";

	//--------------------------
	// 13.
	mainHtEffFrom     = "Manufacturer declaration";	

	//--------------------------
	// 13.
	mainHtEmitter     = "Radiators";

	//--------------------------
	// 14.
	mainHtManufacturerDesc = "Generic boiler";	

	//--------------------------
	// 15.
	mainHtFractionSupplied = 1;

	//--------------------------
	// 16. ??

	//--------------------------
	// 17. ??

	//--------------------------
	// 18.
	btnWaterHtFromMainState = 1;

	//--------------------------
	// 19.
	WHtCylManufactLossFactor = "Known";

	//--------------------------
	// 20. ??
	

	//--------------------------
	// 21.
	WHtTSnCPSUPrimaryPipeworkLT1_5m = "Yes";

	//--------------------------
	// 22.
	WHtTSnCPSUstoreInAirCupbrd = "Yes";

	//--------------------------
	// 23.
	WHtCombiKeepHotYN = "Yes";

	//--------------------------
	// 24.
	DHWfromCommunityScheme = "Yes";

	//--------------------------
	// 25.
	WHtHeatPumpUsesImmer = "Yes";

	//--------------------------
	// 26.
	WHtUsesSummerImmer = "Yes";

	//--------------------------
	// 27. FGHRS, is addressed in 28

	//--------------------------
	// 28. renewables 1 and 2

	//------------------------------------
	// 11. RENEWABLES 1
	//------------------------------------
	isSHWPresent = "No";
	isPVPresent  = "No";
	isWTPresent  = "No";
	uHydroyn	 = "No";
	uCHPyn		 = "No";
	MVHRyn		 = "No";

	SHWCollectorType = "Flat plate - glazed";
	SHWCollectorOrientation = "South";
	SHWCollectorTilt = "30 deg";
	SHWOvershading   = "Modest 20%-60%";
	isSHWAreaGross   = "Yes";
	isSHWSolarStoreCombined = "Yes";
	SHWSolarCircPump = "Electrically powered";
	SHWApertureArea = 4.0;
	SHW_ZLCE = 70;
	SHW_HeatLossCoefficient = 6;
	SHWDedSolStoreVol = 100;

	PVCollectorOrientation = "South";
	PVCollectorTilt = "30 deg";
	PVOvershading = "Modest 20%-60%";

	dwellingExposure = "Average";
	CHPFuel = "Mains gas";
				
	isRENAdditionalElectGenerated = " ";
	RENAddiationalElecGenerated = 0;
	REN_TFA = 0;

	installedPVPeakPower = 2;
	WTNumOf    = 1;
	WTDiameter = 2;
	WTHeight   = 5;

	//------------------------------------
	// 12. RENEWABLES 2
	//------------------------------------
	uHydroAnnualAvgHead = 4;
	uHydroAnnualAvgFlow = 50;
	uHydroEff = 60;
	uHydroAnnualEnergy = 0;

	uCHPheatToPowerRatio = 2;
	uCHPElectricEff      = 40;
	uCHPHeatingEff       = 50;
	uCHPHeatingFraction  = 1;
	uCHPAnnualElectricity     = 0;

	uHydroyn	 = "No";
	uCHPyn		 = "No";
	MVHRyn		 = "No";
	CHPFuel = "Mains gas";

	MVHRThermalEff = 75;

	FGHRSpresent = "No";
	FGHRSstore = "No";
	FGHRSstoreVolume     = 400;
	FGHRSusefulFracHtRec_kf1 = 0.5;
	FGHRSfittedMain      = "Yes";
	FGHRSfittedSec       = "No";
	//FGHRStype			 = "system 1";
	determineFGHRStype = "No";
	FGHRStotFracHeatRec_kf2  = 0.5;
	FGHRSauxelec   = 0.5;
	FGHRSpvPoweredHt     = "No";
	FGHRSpvPkPower		 = 1.1;
	FGHRSpvOrientation = "South";
	FGHRSpvTilt			 = "Horizontal";
	FGHRSpvOvershading   = "Heavy > 80%";
	FGHRScableLoss		 = 0.2;

	WWHRSpresent = "No";
	WWHRSnumOfRooms  = 1;
	WWHRSnumMixerShowersWithBath1    = 1;
	WWHRSnumMixerShowersWithoutBath1 = 1;

	WWHRSnumMixerShowersWithBath2    = 1;
	WWHRSnumMixerShowersWithoutBath2 = 1;
	
	unsigned int i = 0;

	for(i= 0; i<SHCSfileRead1.size();i++)
	{
		if((strcmp(hemHouseType,SHCSfileRead1[i].houseTypeName)==0) &&
			(strcmp(hemYearOfBuild,SHCSfileRead1[i].yearOfBuild)==0))
		{
			//--------------------------------------------------------------
			// line 01 data
			//--------------------------------------------------------------
			// BUILT FORM
			//--------------------------------------------------------------
			hemHouseType   = SHCSfileRead1[i].houseTypeName;        // 1
			hemYearOfBuild = SHCSfileRead1[i].yearOfBuild;	        // 2
			propertyFreqOfOccurence = SHCSfileRead1[i].frequencyOfOccurence; // 3
			builtForm    = SHCSfileRead1[i].builtForm;				// 4
			Detachment   = SHCSfileRead1[i].detachment;				// 5
			FlatPosition = SHCSfileRead1[i].flatPosition;		    // 6
			numOfStoreys = SHCSfileRead1[i].numOfFloors;            // 7
			storey1Area  = SHCSfileRead1[i].floorArea1stFloor;		// 8
			storey2Area  = SHCSfileRead1[i].floorArea2ndFloor;		// 9
			storey3Area  = SHCSfileRead1[i].floorArea3rdFloor;		// 10
			storey4Area  = SHCSfileRead1[i].floorArea4thFloor;		// 11
			storey5Area  = SHCSfileRead1[i].floorArea5thFloor;		// 12
			storey6Area  = SHCSfileRead1[i].floorArea6thFloor;		// 13

			storey1Height = SHCSfileRead1[i].height1stFloor;		// 14
			storey2Height = SHCSfileRead1[i].height2ndFloor;		// 15
			storey3Height = SHCSfileRead1[i].height3rdFloor;		// 16
			storey4Height = SHCSfileRead1[i].height4thFloor;		// 17
			storey5Height = SHCSfileRead1[i].height5thFloor;		// 18
			storey6Height = SHCSfileRead1[i].height6thFloor;		// 19
			
			//--------------------------------------------------------------
			// line 02 data
			//--------------------------------------------------------------
			TFA            = SHCSfileRead1[i].TFA;						// 1
			TFA = storey1Area+ storey2Area+ storey3Area+ storey4Area+ storey5Area+ storey6Area;
			TFAfromHEM = TFA;
			yValueEntry    = SHCSfileRead1[i].thermBridgeyValue;		// 2
			hem_extAreaSum = SHCSfileRead1[i].totalExtWalArea;			// 3
			hem_extUvalueXareaSum = SHCSfileRead1[i].uValueXextArea;	// 4
			// ach = SHCSfileRead1[i].ach;					            // 5
			fractionLEL          = SHCSfileRead1[i].LEL;				// 6
			thermalMassParameter = SHCSfileRead1[i].TMP;				// 7
			winOvershading       = SHCSfileRead1[i].overshading;		// 8
			winGlazing           = SHCSfileRead1[i].glazing;			// 9
			livingRoomFraction   = SHCSfileRead1[i].livingAreaFraction;	// 10

			//--------------------------------------------------------------
			// line 03 data
			//--------------------------------------------------------------
			// MAIN HEATING
			//--------------------------------------------------------------
			mainFuel            = SHCSfileRead1[i].mainFuel;			// 1
			mainHtType          = SHCSfileRead1[i].heatGenerator;		// 2
			boilerType          = SHCSfileRead1[i].bolerType;			// 3
			mainHtEffNominal           = SHCSfileRead1[i].boilerEff;			// 4
			isFanFluePresent    = SHCSfileRead1[i].isFanFlue;			// 5

			if(SHCSfileRead1[i].controls == 0) // 6
			mainHtControls = "No time or thermostatic control of room temperature";
			
			else if(SHCSfileRead1[i].controls == 1) 
			mainHtControls ="Programmer - no thermostat";
			
			else if(SHCSfileRead1[i].controls == 2) 
			mainHtControls ="Room thermostat only";
			
			else if(SHCSfileRead1[i].controls == 3) 
			mainHtControls ="Programmer and room thermostat";
			
			else if(SHCSfileRead1[i].controls == 4) 
			mainHtControls ="Programmer and atleast two room thermostats";
			
			else if(SHCSfileRead1[i].controls == 5) 
			mainHtControls ="Programmer - room thermostat and TRVs";
			
			else if(SHCSfileRead1[i].controls == 6) 
			mainHtControls ="Programmer - TRVs and bypass";
			
			else if(SHCSfileRead1[i].controls == 7) 
			mainHtControls ="Programmer - TRVs and flow switch";
			
			else if(SHCSfileRead1[i].controls == 8) 
			mainHtControls ="Programmer - TRVs and boiler energy manager";
			
			else if(SHCSfileRead1[i].controls == 9) 
			mainHtControls ="Time and temperature zone control";
			
			else if(SHCSfileRead1[i].controls == 10) 
			mainHtControls ="Delayed start thermostat";
			
			else if(SHCSfileRead1[i].controls == 11) 
			mainHtControls ="Programmer and delayed start thermostat";
			
			else if(SHCSfileRead1[i].controls == 12) 
			mainHtControls ="Programmer and atleast 2 room thermostat including a delayed start thermostat";
			
			else if(SHCSfileRead1[i].controls == 13) 
			mainHtControls ="Programmer - delayed start thermostat and TRVs";
		
			isIterlockPresent   = SHCSfileRead1[i].interlock;			// 7
			isPumpInHeatedSpace = SHCSfileRead1[i].isPumpInHeatedSpace; // 8

			//--------------------------------------------------------------
			// line 04 data
			//--------------------------------------------------------------
			// DOMESTIC HOT WATER
			//--------------------------------------------------------------
			//= SHCSfileRead1[i].DHWfuel;			        // 1 SHOULD MATCH AN ENRTY FORM MAIN
			WHtEff                    = SHCSfileRead1[i].DHWeff;					  // 2
			WHtCylinderWithinDwelling = SHCSfileRead1[i].isCylWithinDwelling;	      // 3
			WHtWaterSepTimed          = SHCSfileRead1[i].isCylSepTimed;		          // 4
			WHtCylDeclaredFactor  = SHCSfileRead1[i].cylMaufacturerLossFactor;        // 5
			WHtCylVolume              = SHCSfileRead1[i].cylVolume;				      // 6
			WHtCylInsType             = SHCSfileRead1[i].cylInsType;			      // 7
			WHtCylInsThickness        = SHCSfileRead1[i].cylInsThickness;			  // 8
			WHtCylThermostat          = SHCSfileRead1[i].isThereThermostat;		      // 9
			WHtCylInHeatedSpace       = SHCSfileRead1[i].isCylInHeaterSpace;		  // 10
			WHtCylPrimaryPipeworkInsulated= SHCSfileRead1[i].isPrimPipeworkInsulated; // 11
			WHtCylPumpedPrimarySystem = SHCSfileRead1[i].isPumpedSystem;			  // 12
			WHtype                    = SHCSfileRead1[i].waterHtType;				  // 13
			
			//--------------------------------------------------------------
			// line 05 data
			//--------------------------------------------------------------
			// WINDOWS, TRANSMITTANCE FRAME FACTOR
			//--------------------------------------------------------------
			winNArea  = SHCSfileRead1[i].winNArea;				// 1
			winNEArea = SHCSfileRead1[i].winNEArea;				// 2
			winEArea  = SHCSfileRead1[i].winEArea;				// 3
			winSEArea = SHCSfileRead1[i].winSEArea;				// 4
			winSArea  = SHCSfileRead1[i].winSArea;				// 5
			winSWArea = SHCSfileRead1[i].winSWArea;				// 6
			winWArea  = SHCSfileRead1[i].winWArea;				// 7
			winNWArea = SHCSfileRead1[i].winNWArea;				// 8
			rooflightsArea= SHCSfileRead1[i].rooflightsArea;	// 9

			winNSolTrans  = SHCSfileRead1[i].winNSolTrans;		// 10
			winNESolTrans = SHCSfileRead1[i].winNESolTrans;		// 11
			winESolTrans  = SHCSfileRead1[i].winESolTrans;		// 12
			winSESolTrans = SHCSfileRead1[i].winSESolTrans;		// 13
			winSSolTrans  = SHCSfileRead1[i].winSSolTrans;      // 14
			winSWSolTrans = SHCSfileRead1[i].winSWSolTrans;		// 15
			winWSolTrans  = SHCSfileRead1[i].winWSolTrans;		// 16
			winNWSolTrans = SHCSfileRead1[i].winNWSolTrans;		// 17
			rooflightsSolTrans= SHCSfileRead1[i].rooflightsSolTrans;	// 18

			winNFrameFactor  = SHCSfileRead1[i].winNFrameFactor;	// 19
			winNEFrameFactor = SHCSfileRead1[i].winNEFrameFactor;	// 20
			winEFrameFactor  = SHCSfileRead1[i].winEFrameFactor;	// 21
			winSEFrameFactor = SHCSfileRead1[i].winSEFrameFactor;	// 22
			winSFrameFactor  = SHCSfileRead1[i].winSFrameFactor;	// 23
			winSWFrameFactor = SHCSfileRead1[i].winSWFrameFactor;	// 24
			winWFrameFactor  = SHCSfileRead1[i].winWFrameFactor;	// 25
			winNWFrameFactor = SHCSfileRead1[i].winNWFrameFactor;	// 26
			rooflightsFrameFactor= SHCSfileRead1[i].rooflightsFrameFactor;// 27		

			//--------------------------------------------------------------
			// line 06 data
			//--------------------------------------------------------------
			// WINDOW AREAS 
			//--------------------------------------------------------------
			netAreaDoors           = SHCSfileRead1[i].doorArea;			    // 1
			netAreaGF			   = SHCSfileRead1[i].GFnetArea;			// 2
			netAreaExFloor		   = SHCSfileRead1[i].expFloorNetArea;		// 3
			grossAreaWall1		   = SHCSfileRead1[i].wallType1GrossArea;	// 4
			netAreaWallType2	   = SHCSfileRead1[i].wallType2NetArea;		// 5
			groosAreaRoof1		   = SHCSfileRead1[i].roofType1GrossArea;	// 6
			netAreaRoofType2	   = SHCSfileRead1[i].roofType2NetArea;		// 7
			netAreaPartyWall	   = SHCSfileRead1[i].partyWallArea;		// 8
			netAreaPartyFloor	   = SHCSfileRead1[i].partyFloorArea;		// 9
			netAreaPartyCeiling    = SHCSfileRead1[i].partyCeilingArea;		// 10
			netAreaInternalWall	   = SHCSfileRead1[i].intWallArea;			// 11
			netAreaInternalFloor   = SHCSfileRead1[i].intFloorArea;			// 12
			netAreaInternalCeiling = SHCSfileRead1[i].intCeilingArea;		// 13

			//--------------------------------------------------------------
			// line 07 data
			//--------------------------------------------------------------
			// WINDOW U-VALUES 
			//--------------------------------------------------------------
			UvalueDoors       = SHCSfileRead1[i].doorUvalue;			// 1
			UvalueWindows     = SHCSfileRead1[i].windowsUvalue;			// 2
			UvalueRooflights  = SHCSfileRead1[i].rooflightsUvalue;		// 3
			UvalueGF          = SHCSfileRead1[i].GFUvalue;				// 4
			UvalueExposedFloor= SHCSfileRead1[i].exposedFloorUvalue;	// 5
			UvalueWallType1   = SHCSfileRead1[i].wallType1Uvalue;		// 6
			UvalueWallType2   = SHCSfileRead1[i].wallType2Uvalue;		// 7
			UvalueRoofTYpe1   = SHCSfileRead1[i].roofType1Uvalue;		// 8
			UvalueRoofType2   = SHCSfileRead1[i].roofType2Uvalue;		// 9
			UvaluePartyWall   = SHCSfileRead1[i].partyWallUvalue;		// 10

			//--------------------------------------------------------------
			// Line 08 data
			//--------------------------------------------------------------
			// WINDOW K-VALUES 
			//--------------------------------------------------------------
			kValueGF           = SHCSfileRead1[i].GFkValue;				// 1
			kValueExpFloor     = SHCSfileRead1[i].exposedFloorkValue;	// 2
			kValueWallType1    = SHCSfileRead1[i].wallType1kValue;		// 3
			kValueWallType2    = SHCSfileRead1[i].wallType2kValue;		// 4
			kValueRoofType1    = SHCSfileRead1[i].roofType1kValue;		// 5
			kValueRoofType2    = SHCSfileRead1[i].roofType2kValue;		// 6
			kValuePartyWall    = SHCSfileRead1[i].partyWallkValue;		// 7
			kValuePartyFloor   = SHCSfileRead1[i].partyFloorkValue;		// 8
			kValuePartyCeiling = SHCSfileRead1[i].partyCeilingkValue;   // 9
			kValueIntWall      = SHCSfileRead1[i].intWallkValue;	    // 10
			kValueIntFloor     = SHCSfileRead1[i].intFloorkValue;		// 11
			kValueIntCeiling   = SHCSfileRead1[i].intCeilingkValue;		// 12

			//--------------------------------------------------------------
			// Line 09 data
			//--------------------------------------------------------------
			// VENTILATION
			//--------------------------------------------------------------
			numsOpenFirePlaces     = SHCSfileRead1[i].numOfFirePlaces;			// 1
			numsOpenFlues		   = SHCSfileRead1[i].numOfFlues;				// 2
			numsFluelessGasFires   = SHCSfileRead1[i].numOfFluelessGasFires;	// 3
			numsExtractFans        = SHCSfileRead1[i].numOfExtractFans;		    // 4
			numsPassiveVents       = SHCSfileRead1[i].numOfPasiveVents;		    // 5
			mechVentType           = SHCSfileRead1[i].ventilationType;			// 6
			dwellingShelteredSides = SHCSfileRead1[i].numOfShelteredSides;		// 7

		}
	}
	
	//-----------------------------------------------
	// BASEMENT FOR STOREYS SELECTED
	//-----------------------------------------------	
	storey1Basement = "no";
	storey2Basement = "no";
	storey3Basement = "no";
	storey4Basement = "no";
	storey5Basement = "no";
	storey6Basement = "no";	

	//-----------------------------------------------
	// NUMBER OF STOREYS SELECTED
	//-----------------------------------------------
	storey1 = "no";
	storey2 = "no";
	storey3 = "no";
	storey4 = "no";
	storey5 = "no";
	storey6 = "no";

	//-----------------------------------------------
	// LEVEL OF STOREYS 
	//-----------------------------------------------		
	storey1Level = "Lowest occupied";
	storey2Level = "1";
	storey3Level = "2";
	storey4Level = "3";
	storey5Level = "4";
	storey6Level = "5";
}

BOOL CSAPP1Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	
	// Default values
	isSHWPresent = "No"; 

	ReadSAPandClimateDataFile();
	ReadFDBRFile();
	ReadWWHRSDataFile();
	ReadFGHRScombiDataFile();
	ReadDataFromSHCSFile();
	ReadWindDataFile();
	ReadSecHtEffFile();
	ReadsSAPboilers();
	ReadsSAPcostTable();
		
	tabItem.mask = TCIF_TEXT;
	
	// Text to display in title bar
	versionText = "HUE ver 1.8";
	projectFileNameNoPath = "";

	titleBarText = versionText;
	SetWindowText(titleBarText);

	//--------------------------------------------
	// Set titles for each tab
	//--------------------------------------------
    tabItem.pszText = _T("Overview");
	m_tabCtrl.InsertItem(0,&tabItem);

	tabItem.pszText = _T("Job Details");
	m_tabCtrl.InsertItem(1,&tabItem);

	tabItem.pszText = _T("Built Form");
	m_tabCtrl.InsertItem(2,&tabItem);

	tabItem.pszText = _T("Windows");
	m_tabCtrl.InsertItem(3,&tabItem);

	tabItem.pszText = _T("Areas and U-values");
	m_tabCtrl.InsertItem(4,&tabItem);

	tabItem.pszText = _T("Thermal Bridging");
	m_tabCtrl.InsertItem(5,&tabItem);

	tabItem.pszText = _T("Ventilation");
	m_tabCtrl.InsertItem(6,&tabItem);

	tabItem.pszText = _T("Main Heating");
	m_tabCtrl.InsertItem(7,&tabItem);

	tabItem.pszText = _T("Main Heating Details");
	m_tabCtrl.InsertItem(8,&tabItem);

	tabItem.pszText = _T("Secondary Heating");
	m_tabCtrl.InsertItem(9,&tabItem);

	tabItem.pszText = _T("Water Heating");
	m_tabCtrl.InsertItem(10,&tabItem);

	tabItem.pszText = _T("LZCT 1");
	m_tabCtrl.InsertItem(11,&tabItem);

	tabItem.pszText = _T("LZCT 2");
	m_tabCtrl.InsertItem(12,&tabItem);
	
	//--------------------------------------------
	// Create all dialogs at start up. 
	// Display only the first dialog
	//--------------------------------------------
	m_Results= new CDlg_Results ;
	m_Results ->Create(IDD_RESULTS,this);	
	m_Results->ShowWindow(SW_SHOW);

	m_JobDetails = new CDlg_JobDetails;
	m_JobDetails->Create(IDD_JOBDETAILS,this);
	
	m_BuiltForm = new CDlg_BuiltForm;
	m_BuiltForm->Create(IDD_BUILTFORM,this);	

	m_ThermalBridging = new CDlg_ThermalBridging ;
	m_ThermalBridging ->Create(IDD_THERMALBRIDGING,this);	
    
	m_Ventilation = new CDlg_Ventilation;
	m_Ventilation->Create(IDD_VENTILATION,this);

	m_MainHeating = new CDlg_MainHeating;
	m_MainHeating->Create(IDD_MAINHEATING,this);

	m_MainHeatingDetails = new CDlg_MainHeatingDetails;
	m_MainHeatingDetails->Create(IDD_MAINHEATINGDETAILS,this);

	m_SecHeating = new CDlg_SecHeating;
	m_SecHeating->Create(IDD_SECONDARYHEATING,this);

	m_WaterHeating = new CDlg_WaterHeating;
	m_WaterHeating->Create(IDD_WATERHEATING,this);

	m_Renewables = new CDlg_Renewables ;
	m_Renewables ->Create(IDD_RENEWABLES,this);

	m_Renewables1 = new CDlg_Renewables1 ;
	m_Renewables1 ->Create(IDD_RENEWABLES1,this);

	m_Windows= new CDlg_Windows ;
	m_Windows ->Create(IDD_WINDOWS,this);

	m_AreaAndUvalues= new CDlg_AreaAndUvalues ;
	m_AreaAndUvalues ->Create(IDD_AREAUVALUES,this);
	
	//--------------------------------------------------------------------
	// Destroy all dialogs except first 
	//--------------------------------------------------------------------
	m_JobDetails->DestroyWindow();
	delete m_JobDetails;
	m_JobDetails=NULL;
	
	m_BuiltForm->DestroyWindow();
	delete m_BuiltForm;
	m_BuiltForm=NULL;

	m_Ventilation->DestroyWindow();
	delete m_Ventilation;
	m_Ventilation=NULL;

	m_MainHeating->DestroyWindow();
	delete m_MainHeating;
	m_MainHeating=NULL;

	m_MainHeatingDetails->DestroyWindow();
	delete m_MainHeatingDetails;
	m_MainHeatingDetails=NULL;

	m_SecHeating->DestroyWindow();
	delete m_SecHeating;
	m_SecHeating=NULL;

	m_WaterHeating->DestroyWindow();
	delete m_WaterHeating;
	m_WaterHeating=NULL;

	m_Renewables->DestroyWindow();
	delete m_Renewables;
	m_Renewables=NULL;

	m_Renewables1->DestroyWindow();
	delete m_Renewables1;
	m_Renewables1=NULL;

	m_ThermalBridging->DestroyWindow();
	delete m_ThermalBridging;
	m_ThermalBridging=NULL;	

	m_Windows->DestroyWindow();
	delete m_Windows;
	m_Windows=NULL;	

	m_AreaAndUvalues->DestroyWindow();
	delete m_AreaAndUvalues;
	m_AreaAndUvalues=NULL;	

	// Add only one tab to Estate item
	m_tabCtrlEstate.InsertItem(0,"Estate");

	m_tabCtrlProjects.InsertItem(0,"Untitled");

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSAPP1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view modelQualifier,
//  this is automatically done for you by the framework.

void CSAPP1Dlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSAPP1Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CSAPP1Dlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)
{	
	if(enable_user_to_change_tab == false)
	{
		MessageBox("Please select weather before moving to other tabs","Warning",MB_OK);
		m_tabCtrl.SetCurSel(0);
		return;
	}

	// DisplayWarningMessages calls RangeCheckFunction()
	DisplayWarningMessages();

	int TabIndex = 0;

	//------------------------------------------------------
	// Get the number of the currently selected tab 
	TabIndex = m_tabCtrl.GetCurSel();

	DestroyModlessDialogs();

	//------------------------------------------------------------------
	// Show new dialog selected by tab control
	//------------------------------------------------------------------
	if (TabIndex==0)
	{
		m_Results = new CDlg_Results;
		m_Results->Create(IDD_RESULTS,this);
		m_Results->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==1)
	{
		m_JobDetails = new CDlg_JobDetails;
		m_JobDetails->Create(IDD_JOBDETAILS, this);
		m_JobDetails->ShowWindow(SW_SHOW);
	}
	else if (TabIndex==2)
	{
		m_BuiltForm = new CDlg_BuiltForm;
		m_BuiltForm->Create(IDD_BUILTFORM,this);
		m_BuiltForm->ShowWindow(SW_SHOW);
	}
	else if (TabIndex==3)
	{
		m_Windows = new CDlg_Windows;
		m_Windows->Create(IDD_WINDOWS,this);
		m_Windows->ShowWindow(SW_SHOW);			
	}

	else if (TabIndex==4)
	{
		m_AreaAndUvalues = new CDlg_AreaAndUvalues;
		m_AreaAndUvalues->Create(IDD_AREAUVALUES,this);
		m_AreaAndUvalues->ShowWindow(SW_SHOW);			
	}

	else if (TabIndex==5)
	{
		m_ThermalBridging = new CDlg_ThermalBridging;
		m_ThermalBridging->Create(IDD_THERMALBRIDGING,this);
		m_ThermalBridging->ShowWindow(SW_SHOW);			
	}

	else if (TabIndex==6)
	{
		m_Ventilation = new CDlg_Ventilation;
		m_Ventilation->Create(IDD_VENTILATION,this);
		m_Ventilation->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==7)
	{
		m_MainHeating = new CDlg_MainHeating;
		m_MainHeating->Create(IDD_MAINHEATING,this);
		m_MainHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==8)
	{
		m_MainHeatingDetails = new CDlg_MainHeatingDetails;
		m_MainHeatingDetails->Create(IDD_MAINHEATINGDETAILS,this);
		m_MainHeatingDetails->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==9)
	{
		m_SecHeating = new CDlg_SecHeating;
		m_SecHeating->Create(IDD_SECONDARYHEATING,this);
		m_SecHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==10)
	{
		m_WaterHeating = new CDlg_WaterHeating;
		m_WaterHeating->Create(IDD_WATERHEATING,this);
		m_WaterHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==11)
	{
		m_Renewables = new CDlg_Renewables;
		m_Renewables->Create(IDD_RENEWABLES,this);
		m_Renewables->ShowWindow(SW_SHOW);			
	}

	else if (TabIndex==12)
	{
		m_Renewables1 = new CDlg_Renewables1;
		m_Renewables1->Create(IDD_RENEWABLES1,this);
		m_Renewables1->ShowWindow(SW_SHOW);			
	}
	
	*pResult = 0;
}


BOOL CSAPP1Dlg::DestroyModlessDialogs()
{
	//------------------------------------------------------------------
	// Destroy current dialog box before drawing the new one
	//------------------------------------------------------------------
	 if(m_Results)
	{
		m_Results->DestroyWindow();
		delete m_Results;
		m_Results=NULL;	
	}
	else if (m_JobDetails)
	{
		m_JobDetails->DestroyWindow();
		delete m_JobDetails;
		m_JobDetails=NULL;
	}
	else if(m_BuiltForm)
	{
		m_BuiltForm->DestroyWindow();
		delete m_BuiltForm;
		m_BuiltForm=NULL;
	}
	else if(m_ThermalBridging)
	{
		m_ThermalBridging->DestroyWindow();
		delete m_ThermalBridging;
		m_ThermalBridging=NULL;	
	}
	else if(m_Ventilation)
	{
		m_Ventilation->DestroyWindow();
		delete m_Ventilation;
		m_Ventilation=NULL;
	}
	else if(m_MainHeating)
	{
		m_MainHeating->DestroyWindow();
		delete m_MainHeating;
		m_MainHeating=NULL;
	}
	else if(m_MainHeatingDetails)
	{
		m_MainHeatingDetails->DestroyWindow();
		delete m_MainHeatingDetails;
		m_MainHeatingDetails=NULL;
	}
	else if(m_SecHeating)
	{
		m_SecHeating->DestroyWindow();
		delete m_SecHeating;
		m_SecHeating=NULL;
	}
	else if(m_WaterHeating)
	{
		m_WaterHeating->DestroyWindow();
		delete m_WaterHeating;
		m_WaterHeating=NULL;
	}
	else if(m_Renewables)
	{
		m_Renewables->DestroyWindow();
		delete m_Renewables;
		m_Renewables=NULL;
	}
	else if(m_Renewables1)
	{
		m_Renewables1->DestroyWindow();
		delete m_Renewables1;
		m_Renewables1=NULL;
	}
	else if(m_Windows)
	{
		m_Windows->DestroyWindow();
		delete m_Windows;
		m_Windows=NULL;	
	}
	else if(m_AreaAndUvalues)
	{
		m_AreaAndUvalues->DestroyWindow();
		delete m_AreaAndUvalues;
		m_AreaAndUvalues=NULL;	
	}
	
	return TRUE;
}


void CSAPP1Dlg::OnFileSave()
{
	//--------------------------------------------------------------------
	// IF NO FILE IS PREVIOUSLY OPENED
	//--------------------------------------------------------------------
   if(strcmp(projectFileNameNoPath,"")==0)
	{
		//--------------------------------------------------------------------
		// Save dialog to save the project name
		// Warn user not to change the directory
		CFileDialog m_idFile( false, "proj", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, // false to save
			"Project files (*.csv)|*.csv|*.csv|", AfxGetMainWnd());
		m_idFile.m_ofn.lpstrInitialDir = "..\\projects"; // default directory os one step up the executable

		// If user choses to Save File..
		if (m_idFile.DoModal()==IDOK)
		{
			CString strPathName = m_idFile.GetPathName();
			projectFileName     = m_idFile.GetPathName();// GetFileName();
			projectFileNameNoPath = m_idFile.GetFileName();

			AfxExtractSubString(projectFileNameNoExt, projectFileNameNoPath, 0, '.'); 

			//------------------------------------------------
			// If opened tab is untitled, delete it
			//------------------------------------------------
			// Read title of selected tab
			//------------------------------------------------
			is_save_dialg_called = true;
			DeleteUntitledTab();
			SaveProjectFile_2();

			//-------------------------------------------------------------------
			// Copy file name to vector
			//-------------------------------------------------------------------
			OpenProjectInfo tempEntry;
			tempEntry.projectFileName       = projectFileName;
			tempEntry.projectFileNameNoPath = projectFileNameNoPath;		
			tempEntry.projectFileNameNoExt  = projectFileNameNoExt;
			projectInfo.push_back(tempEntry);
		}
		else
		{
			return;
		}	
	}
	//--------------------------------------------------------------------
	// ELSE IF A FILE IS OPENED, OVERWRITE IT
	//--------------------------------------------------------------------
   else
   {
	   file_already_opened = true;
	   SaveProjectFile_2();
   }

   //-------------------------------------------------------------------
	// This flag ia added to ensure that estate can only display
	// saved projects
	chk_if_project_saved     = true;

	titleBarText = versionText + " " + "-" + " " + projectFileNameNoExt;
	SetWindowText(titleBarText);
}


void CSAPP1Dlg::OnFileNew()
{
	projectFileNameNoExt = "Untitled";

	//----------------------------------------------
	// Add new tab when OnFileNew is called from menu
	// else just open an untitled file
	//----------------------------------------------
	OpenNewTabForProjectFile();
	lastTabNumber = m_tabCtrlProjects.GetCurSel();

	is_results_values_read_first_time = true;

	is_base_selected = false;
	is_imp1_selected = false;
	is_imp2_selected = false;
	is_imp3_selected = false;
	is_imp4_selected = false;
	is_imp5_selected = false;

	int TabIndex = 0;
	file_new_selected = true;
	is_climate_changed_from_results = false;
	is_house_type_changed_from_results = false;
	is_year_of_build_changed = false;

	//------------------------------------------------------
	// Get the number of the currently selected tab 
	TabIndex = m_tabCtrl.GetCurSel();

	DestroyModlessDialogs();

	//--------------------------------------
	// Reset variables as following
	//--------------------------------------
	SetAllValuesToDefault();	

	//------------------------------------------------------------------
	// Create new instances of all dialogs
	//------------------------------------------------------------------
	if (TabIndex==0)
	{
		m_Results = new CDlg_Results;
		m_Results->Create(IDD_RESULTS,this);
		m_Results->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==1)
	{
		m_JobDetails = new CDlg_JobDetails;
	    m_JobDetails->Create(IDD_JOBDETAILS, this);
		m_JobDetails->ShowWindow(SW_SHOW);
	}
	else if (TabIndex==2)
	{	
		m_BuiltForm = new CDlg_BuiltForm;
		m_BuiltForm->Create(IDD_BUILTFORM,this);
		m_BuiltForm->ShowWindow(SW_SHOW);
	}
	else if (TabIndex==3)
	{
		m_Windows = new CDlg_Windows;
		m_Windows->Create(IDD_WINDOWS,this);
		m_Windows->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==4)
	{
		m_AreaAndUvalues = new CDlg_AreaAndUvalues;
		m_AreaAndUvalues->Create(IDD_AREAUVALUES,this);
		m_AreaAndUvalues->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==5)
	{	
		m_ThermalBridging = new CDlg_ThermalBridging;
		m_ThermalBridging->Create(IDD_THERMALBRIDGING,this);
		m_ThermalBridging->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==6)
	{		
		m_Ventilation = new CDlg_Ventilation;
		m_Ventilation->Create(IDD_VENTILATION,this);
		m_Ventilation->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==7)
	{	
		m_MainHeating = new CDlg_MainHeating;
		m_MainHeating->Create(IDD_MAINHEATING,this);
		m_MainHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==8)
	{		
		m_MainHeatingDetails = new CDlg_MainHeatingDetails;
		m_MainHeatingDetails->Create(IDD_MAINHEATINGDETAILS,this);
		m_MainHeatingDetails->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==9)
	{
		m_SecHeating = new CDlg_SecHeating;
		m_SecHeating->Create(IDD_SECONDARYHEATING,this);
		m_SecHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==10)
	{		
		m_WaterHeating = new CDlg_WaterHeating;
		m_WaterHeating->Create(IDD_WATERHEATING,this);
		m_WaterHeating->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==11)
	{		
		m_Renewables = new CDlg_Renewables;
		m_Renewables->Create(IDD_RENEWABLES,this);
		m_Renewables->ShowWindow(SW_SHOW);			
	}
	else if (TabIndex==12)
	{		
		m_Renewables1 = new CDlg_Renewables1;
		m_Renewables1->Create(IDD_RENEWABLES1,this);
		m_Renewables1->ShowWindow(SW_SHOW);			
	}
	
	

	file_new_selected = false;	

	projectFileNameNoPath = "";
	titleBarText = versionText;
	SetWindowText(titleBarText);
}

void CSAPP1Dlg::ReadsSAPboilers()
{
	//--------------------------------------------
	// Clear vectors before writing data
	//--------------------------------------------
	SAPboilers_db.clear();	

	//char *tempString;

	FILE *fptr;
	char tempStr[1000];
	char tempStr2[1010];
	char tempString[1000];

	char *pError;
	char *pch;
	SAPboilers tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;
	int temp = 0;
	int length = 0;
	int num = 0;

	//--------------------------------------------------------------------------	
	// Open the file
	fptr = fopen(PATH_TO_SAP_BOILER_DB_FILE,"r");
	if (fptr == NULL)
	{
		return;
	}

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	
	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,1000,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		strSpecialCopy(tempStr,tempStr2);

		//Now run strtoke on str. Notice as second argument to strtok() ONLY comma characters are being passed
		//--------------------------------------------------------------------
		// 1.	Read the "entry label" for the combo box
		pch = strtok (tempStr2, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempCBoxEntry.boilerRef,pch);

		//--------------------------------------------------------------------
		// 2.	Skip 2nd coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}	
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 3.	Read the "entry string" for this entry
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempCBoxEntry.boilerModel,pch);

		//--------------------------------------------------------------------
		// 4.	Skip 4th coloumn

		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 5.	Skip 5th coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 6.	Skip 6th coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 7.	Skip 7th coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 8.	Skip 8th coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 9.	Skip 9th coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempString,pch);

		//--------------------------------------------------------------------
		// 10.	Read the "entry string" for this entry
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		tempCBoxEntry.effeciency = atof(pch);
		SAPboilers_db.push_back(tempCBoxEntry);			
	}
}


void CSAPP1Dlg::ReadsSAPcostTable()
{
	//--------------------------------------------
	// Clear vectors before writing data
	//--------------------------------------------
	SAPcostTable_New.clear();	

	//char *tempString;

	FILE *fptr;
	char tempStr[1000];

	char *pError;
	char *pch;
	SAPcostTable tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;
	int temp = 0;
	int length = 0;
	int num = 0;

	//--------------------------------------------------------------------------	
	// Open the file
	fptr = fopen(PATH_TO_SAP_COST_TABLE,"r");
	if (fptr == NULL)
	{
		return;
	}

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	
	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,9000,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}


		if(linesRead >1)
		{

			//--------------------------------------------------------------------
			// 1.	Read the "entry label" for the combo box
			pch = strtok (tempStr, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.fuelType,pch);

			//--------------------------------------------------------------------
			// 2.	Skip 2nd coloumn
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.tariff,pch);

			//--------------------------------------------------------------------
			// 3.	Read the "entry string" for this entry
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.unitPrice = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Skip 4th coloumn

			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.emissions = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Skip 5th coloumn
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.primaryEnergyFactor = atof(pch);	

			SAPcostTable_New.push_back(tempCBoxEntry);	
		}
	}
}

void CSAPP1Dlg::ReadSecHtEffFile()
{
	//--------------------------------------------
	// Clear vectors before writing data
	//--------------------------------------------
	secHtSysData_New.clear();		

	FILE *fptr;
	char tempStr[1000];
	char *pError;
	char *pch;
	secHtSysData tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;

	//--------------------------------------------------------------------------	
	// Open the file
	fptr = fopen(PATH_TO_SEC_HT_EFF_FILE,"r");
	if (fptr == NULL)
	{
		return;
	}

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	
	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,1000,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		//--------------------------------------------------------------------
		// 1.	Read 1st coloumn for boiler ref
		pch = strtok (tempStr, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempCBoxEntry.fuelType,pch);		

		//--------------------------------------------------------------------
		// 2.	Read 3rd coloumn
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		strcpy(tempCBoxEntry.systemType,pch);		

		//--------------------------------------------------------------------
		// 3.	Read the 2nd coloumn, efficiency
		pch = strtok (NULL, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}
		tempCBoxEntry.effeciency = atoi(pch);

		secHtSysData_New.push_back(tempCBoxEntry);
	}
}

FILE *fptrSAPandClimateFile;

void CSAPP1Dlg::ReadSAPandClimateDataFile()
{
	//--------------------------------------------------------------------------	
	// Clear the vectors before start writing again
	ClimateData_1.clear();

	//--------------------------------------------------------------------------
	// Read SAP weather file
	//--------------------------------------------------------------------------
	fptrSAPandClimateFile = fopen(PATH_TO_SAP_CLIMATE_FILE,"r");
	if (fptrSAPandClimateFile == NULL)
	{
		// Error message;return FALSE;
	}
	else
	{
		ReadClimateDataFile();
	}

	//--------------------------------------------------------------------------
	// Read detailed regions weather file
	//--------------------------------------------------------------------------
	fptrSAPandClimateFile = fopen(PATH_TO_REGIONS_WEATHER_FILE,"r");
	if (fptrSAPandClimateFile == NULL)
	{
		// Error message;return FALSE;
	}
	else
	{
		ReadClimateDataFile();
	}

	//--------------------------------------------------------------------------
	// Read detailed towns weather file
	//--------------------------------------------------------------------------
	fptrSAPandClimateFile = fopen(PATH_TO_TOWNS_WEATHER_FILE,"r");
	if (fptrSAPandClimateFile == NULL)
	{
		// Error message;return FALSE;
	}
	else
	{
		ReadClimateDataFile();
	}
}

void CSAPP1Dlg::ReadWindDataFile()
{
	// Read from file and ad data to vectors
	FILE *fptr;
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	WindData tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;

	//--------------------------------------------------------------------------
	// Data to be read from two files
	// 1. First read SAP climate data file
	//--------------------------------------------------------------------------
	// Open the file
	fptr = fopen(PATH_TO_WIND_DATA_FILE,"r");

	if (fptr == NULL)
	{
		//;return FALSE;
	}

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	

	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		//--------------------------------------------------------------------
		// Read location name and s3
		//--------------------------------------------------------------------
		if (linesRead >1 )
		{	
			//--------------------------------------------------------------------
			// A.	Read Location
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.locationName,pch);

			//--------------------------------------------------------------------
			// B.	Read s3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.s3 = atoi(pch);

			// Add data to vector
			WindData_1.push_back(tempCBoxEntry);
		}
	}
	fclose(fptr);
}

void CSAPP1Dlg::ReadDataFromSHCSFile()
{
	//--------------------------------------------------------------------------	
	// Clear the vectors before start writing again
	SHCSfileRead1.clear();

	//--------------------------------------------------------------------------
	// Read from file and ad data to vectors
	FILE *fptr;
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char tempStr2[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	SHCSfileRead tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;
	bool populateSHCSVector = false;

	fptr = fopen(PATH_TO_SHCS_DATA_FILE,"r");	

	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		//--------------------------------------------------------------------
		// If # character is found at the beginning of a line, skip it
		if(tempStr[0]== '#')
		{
			continue;
		}

		//--------------------------------------------------------------------
		// Add space character between any consecutive commas
		strSpecialCopy(tempStr,tempStr2);

		//--------------------------------------------------------------------
		// A.	Read the tag
		pch = strtok (tempStr2, ",");

		// If some error has occured
		if (pch == NULL)
		{
			isOk = FALSE;
			break;
		}

		//--------------------------------------------------------------------
		// If tag is line 01
		if(strcmp(tempStr2,"line 01")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.houseTypeName,pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.yearOfBuild, pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.frequencyOfOccurence = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.builtForm,pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.detachment,pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.flatPosition,pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfFloors = atoi(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea1stFloor = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea2ndFloor = atof(pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea3rdFloor = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read 11th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea4thFloor = atof(pch);

			//--------------------------------------------------------------------
			// 12.	Read 12th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea5thFloor = atof(pch);

			//--------------------------------------------------------------------
			// 13.	Read 13th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.floorArea6thFloor = atof(pch);

			//--------------------------------------------------------------------
			// 14.	Read 14th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height1stFloor = atof(pch);

			//--------------------------------------------------------------------
			// 15.	Read 15th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height2ndFloor = atof(pch);

			//--------------------------------------------------------------------
			// 16.	Read 16th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height3rdFloor = atof(pch);

			//--------------------------------------------------------------------
			// 17.	Read 17th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height4thFloor = atof(pch);

			//--------------------------------------------------------------------
			// 18.	Read 18th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height5thFloor = atof(pch);

			//--------------------------------------------------------------------
			// 19.	Read 19th entry for line 01
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.height6thFloor = atof(pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 02
		if(strcmp(tempStr2,"line 02")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.TFA = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.thermBridgeyValue = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.totalExtWalArea = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.uValueXextArea = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.ach = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.LEL = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.TMP = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.overshading,pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.glazing,pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 02
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.livingAreaFraction = atof(pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 03
		if(strcmp(tempStr2,"line 03")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.mainFuel,pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.heatGenerator,pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.bolerType,pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.boilerEff = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.controls = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isFanFlue,pch);
			

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.interlock,pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 03
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isPumpInHeatedSpace,pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 04
		if(strcmp(tempStr2,"line 04")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.DHWfuel,pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.DHWeff = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isCylWithinDwelling,pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isCylSepTimed,pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.cylMaufacturerLossFactor = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.cylVolume = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.cylInsType,pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.cylInsThickness = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isThereThermostat,pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isCylInHeaterSpace,pch);

			//--------------------------------------------------------------------
			// 11.	Read 11th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isPrimPipeworkInsulated,pch);

			//--------------------------------------------------------------------
			// 12.	Read 12th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.isPumpedSystem,pch);

			//--------------------------------------------------------------------
			// 13.	Read 13th entry for line 04
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.waterHtType,pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 05
		if(strcmp(tempStr2,"line 05")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNArea = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNEArea = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winEArea = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSEArea = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSArea = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSWArea = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winWArea = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNWArea = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.rooflightsArea = atof(pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read 11th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNESolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 12.	Read 12th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winESolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 13.	Read 13th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSESolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 14.	Read 14th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 15.	Read 15th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSWSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 16.	Read 16th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winWSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 17.	Read 17th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNWSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 18.	Read 18th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.rooflightsSolTrans = atof(pch);

			//--------------------------------------------------------------------
			// 19.	Read 19th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 20.	Read 20th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNEFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 21.	Read 21st entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winEFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 22.	Read 22nd entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSEFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 23.	Read 23rd entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 24.	Read 24th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winSWFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 25.	Read 25th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winWFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 26.	Read 26th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.winNWFrameFactor = atof(pch);

			//--------------------------------------------------------------------
			// 27.	Read 27th entry for line 05
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.rooflightsFrameFactor = atof(pch);			
		}

		//--------------------------------------------------------------------
		// If tag is line 06
		if(strcmp(tempStr2,"line 06")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.doorArea = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.GFnetArea = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.expFloorNetArea = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType1GrossArea = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType2NetArea = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType1GrossArea = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType2NetArea = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyWallArea = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyFloorArea = atof(pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyCeilingArea = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read 11th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intWallArea = atof(pch);

			//--------------------------------------------------------------------
			// 12.	Read 12th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intFloorArea = atof(pch);

			//--------------------------------------------------------------------
			// 13.	Read 13th entry for line 06
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intCeilingArea = atof(pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 07
		if(strcmp(tempStr2,"line 07")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.doorUvalue = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.windowsUvalue = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.rooflightsUvalue = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.GFUvalue = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.exposedFloorUvalue = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 1st entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType1Uvalue = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType2Uvalue = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType1Uvalue = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 1st entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType2Uvalue = atof(pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 07
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyWallUvalue = atof(pch);
		}
		
		//--------------------------------------------------------------------
		// If tag is line 08
		if(strcmp(tempStr2,"line 08")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.GFkValue = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.exposedFloorkValue = atof(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType1kValue = atof(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.wallType2kValue = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType1kValue = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.roofType2kValue = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyWallkValue = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read 8th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyFloorkValue = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read 9th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.partyCeilingkValue = atof(pch);

			//--------------------------------------------------------------------
			// 10.	Read 10th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intWallkValue = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read 11th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intFloorkValue = atof(pch);

			//--------------------------------------------------------------------
			// 12.	Read 12th entry for line 08
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.intCeilingkValue = atof(pch);
		}

		//--------------------------------------------------------------------
		// If tag is line 09
		if(strcmp(tempStr2,"line 09")==0)
		{
			//--------------------------------------------------------------------
			// 1.	Read 1st entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfFirePlaces = atoi(pch);

			//--------------------------------------------------------------------
			// 2.	Read 2nd entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfFlues = atoi(pch);

			//--------------------------------------------------------------------
			// 3.	Read 3rd entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfFluelessGasFires = atoi(pch);

			//--------------------------------------------------------------------
			// 4.	Read 4th entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfExtractFans = atoi(pch);

			//--------------------------------------------------------------------
			// 5.	Read 5th entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfPasiveVents = atoi(pch);

			//--------------------------------------------------------------------
			// 6.	Read 6th entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			strcpy(tempCBoxEntry.ventilationType,pch);

			//--------------------------------------------------------------------
			// 7.	Read 7th entry for line 09
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}	
			tempCBoxEntry.numOfShelteredSides = atoi(pch);

			populateSHCSVector = true;
		}

		//--------------------------------------------------------------------	
		// Enter this information in the  vector
		if(populateSHCSVector == true)
		{
			SHCSfileRead1.push_back(tempCBoxEntry);
			populateSHCSVector = false;
		}
	}

	unsigned int i = 0;
	i = SHCSfileRead1.size();
	fclose(fptr);
}

void CSAPP1Dlg::ReadFGHRScombiDataFile()
{
	//--------------------------------------------------------------------------	
	// Clear the vectors before start writing again
	FGHRS_combiData.clear();

	//--------------------------------------------------------------------------
	// Read from file and ad data to vectors
	FILE *fptr;
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	FGHRS_Data tempCBoxEntry;
	int device = 2;
	bool isOk = TRUE;
	int linesRead = 0;
	bool populateFGHRScombiVector = false;

	fptr = fopen(PATH_TO_FGHRS_DATA_FILE,"r");

	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		if (linesRead == device)
		{
			//--------------------------------------------------------------------
			// 1.	Read the location name
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			
			strcpy( tempCBoxEntry.FGHRSname, pch);

			// If have read end-of-line character, replace it with null
			if (tempCBoxEntry.FGHRSname[strlen(pch)-1] == 0x0A)
			{
				tempCBoxEntry.FGHRSname[strlen(pch)-1] = 0;
			}
		}
		//--------------------------------------------------------------------
		// Qsp 1 data
		//--------------------------------------------------------------------
		else if (linesRead == device + 1)
		{	
			// 1.	Read Qsp_1
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp1a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp1b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp1c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp1a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp1b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 1.	Read Qsp1c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp1c_otherCombi = atof(pch);
		}

		//--------------------------------------------------------------------
		// Qsp data
		//--------------------------------------------------------------------
		else if (linesRead == device + 2)
		{	
			// 1.	Read Qsp_2
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_2 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp2a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp2b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp2c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp2a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp2b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read Qsp2c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp2c_otherCombi = atof(pch);
		}

		//--------------------------------------------------------------------
		// Qsp data
		//--------------------------------------------------------------------
		else if (linesRead == device + 3)
		{	
			// 1.	Read Qsp_3
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_3 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp3a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp3b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp3c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp3a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read Qsp3b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp3c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp3c_otherCombi = atof(pch);
		}

		//--------------------------------------------------------------------
		// Qsp data
		//--------------------------------------------------------------------
		else if (linesRead == device + 4)
		{	
			// 1.	Read Qsp_4
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_4 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp4a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp4b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp4c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp4a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp4b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read Qsp4c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp4c_otherCombi = atof(pch);
		}
		//--------------------------------------------------------------------
		// Qsp data
		//--------------------------------------------------------------------
		else if (linesRead == device + 5)
		{	
			// 1.	Read Qsp_5
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_5 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp5a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp5b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp5c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp5a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp5b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read Qsp5c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp5c_otherCombi = atof(pch);
		}
		//--------------------------------------------------------------------
		// Qsp data
		//--------------------------------------------------------------------
		else if (linesRead == device + 6)
		{	
			// 1.	Read Qsp_6
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp_6 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Qsp6a_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6a_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Qsp6b_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6b_keepHot = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Qsp6c_keepHot
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6c_keepHot = atof(pch);

			//--------------------------------------------------------------------
			// 5.	Read Qsp6a_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6a_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read Qsp6b_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6b_otherCombi = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read Qsp6c_otherCombi
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Qsp6c_otherCombi = atof(pch);

			device = device + 7;
			populateFGHRScombiVector = true;
		}

		if(populateFGHRScombiVector == true)
		{
			FGHRS_combiData.push_back(tempCBoxEntry);
			populateFGHRScombiVector = false;
		}
	}
	fclose(fptr);
}

void CSAPP1Dlg::ReadWWHRSDataFile()
{
	// Read from file and ad data to vectors
	FILE *fptr;
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	WWHRSData tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;

	//--------------------------------------------------------------------------
	// Data to be read from two files
	// 1. First read SAP climate data file
	//--------------------------------------------------------------------------
	// Open the file
	fptr = fopen(PATH_TO_WWHRS_DATA_FILE,"r");

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	

	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		//--------------------------------------------------------------------
		// Read data for all lines except first
		//--------------------------------------------------------------------
		if (linesRead >1 )
		{	
			//--------------------------------------------------------------------
			// 1.	Read WWHRS type
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.type,pch);

			//--------------------------------------------------------------------
			// 2.	Read make
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.make,pch);

			//--------------------------------------------------------------------
			// 3.	Read modelQualifier
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.model,pch);

			//--------------------------------------------------------------------
			// 4.	Read modelQualifier qualifier
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.modelQualifier,pch);

			//--------------------------------------------------------------------
			// 5.	Read effeciencyMixer
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.effeciencyMixer = atof(pch);

			//--------------------------------------------------------------------
			// 6.	Read effeciencyInstElec
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.effeciencyInstElec = atof(pch);

			//--------------------------------------------------------------------
			// 7.	Read UfMixer
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.UfMixer = atof(pch);

			//--------------------------------------------------------------------
			// 8.	Read UfinstElec
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.UfinstElec = atof(pch);

			//--------------------------------------------------------------------
			// Add data to vector
			WWHRSData_1.push_back(tempCBoxEntry);
		}
	}
	fclose(fptr);
}

void CSAPP1Dlg::ReadFDBRFile()
{
	// Read from file and ad data to vectors
	FILE *fptr;
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	IndexDataNew tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;
	int i = 0;
	int index = 1;
	bool populateIndexVector = false;
	double temp = 0;
	
	//--------------------------------------------------------------------------
	// Data to be read from two files
	// 1. First read SAP climate data file
	//--------------------------------------------------------------------------
	// Open the file
	fptr = fopen(PATH_TO_DATA_FILE,"r");

	if (fptr == NULL)
	{
		//;return FALSE;
	}

	// Keep on reading (and proessing) each line from the CSV file
	// until reached end of file OR some error occured	

	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptr);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		//--------------------------------------------------------------------
		// 1. JANUARY DATA
		//--------------------------------------------------------------------
		if (linesRead == index)
		{	
			//--------------------------------------------------------------------
			// A.	Read index
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.index,pch);

			//--------------------------------------------------------------------
			// B.	Read month
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.month1,pch);

			//--------------------------------------------------------------------
			// 1.	Read Jan1
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Jan2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Jan3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Jan4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Jan5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Jan6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Jan7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Jan8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Jan9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan9 = atof(pch);	

			//--------------------------------------------------------------------
			// 10.	Read Jan10
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan10 = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read Jan11
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan11 = atof(pch);
		}

		else if (linesRead == index + 1)
		{
			//--------------------------------------------------------------------
			// 2. FEBRUARY DATA
			//--------------------------------------------------------------------

			//--------------------------------------------------------------------
			// A.	Read index
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.index,pch);

			//--------------------------------------------------------------------
			// B.	Read month
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.month2,pch);

			// 1.	Read Feb1
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Feb2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Feb3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Feb4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Feb5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Feb6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Feb7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Feb8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb8 = atof(pch);
			//--------------------------------------------------------------------
			// 10.	Read Feb10
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb9 = atof(pch);

			//--------------------------------------------------------------------
			// 11.	Read Feb11
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb10 = atof(pch);


			//--------------------------------------------------------------------
			// 9.	Read Feb9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb11 = atof(pch);
		}

		else if (linesRead == index + 2)
		{
			//--------------------------------------------------------------------
			// A.	Read index
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.index,pch);

			//--------------------------------------------------------------------
			// B.	Read month
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.month3,pch);

			//--------------------------------------------------------------------
			// 3. MARCH DATA
			//--------------------------------------------------------------------
			// 1.	Read Mar1
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Mar2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Mar3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Mar4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Mar5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Mar6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Mar7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Mar8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Mar9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar9 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Mar9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar10 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Mar9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar11 = atof(pch);
		}

		else if (linesRead == index + 3)
		{
			//--------------------------------------------------------------------
			// A.	Read index
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.index,pch);

			//--------------------------------------------------------------------
			// B.	Read month
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			strcpy(tempCBoxEntry.month4,pch);

			//--------------------------------------------------------------------
			// 4. APRIL DATA
			//--------------------------------------------------------------------
			// 1.	Read Apr1
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Apr2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Apr3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Apr4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Apr5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Apr6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Apr7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Apr8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Apr9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr9 = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read Apr9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr10 = atof(pch);

			//--------------------------------------------------------------------
			// 9.	Read Apr9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr11 = atof(pch);

			}

			else if (linesRead == index + 4)
			{

				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month5,pch);

				//--------------------------------------------------------------------
				// 5. MAY DATA
				//--------------------------------------------------------------------
				// 1.	Read May1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read May2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read May3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read May4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read May5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read May6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read May7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read May8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read May9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May9 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read May9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May10 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read May9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May11= atof(pch);
			}

			else if (linesRead == index + 5)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month6,pch);

				//--------------------------------------------------------------------
				// 6. JUNE DATA
				//--------------------------------------------------------------------
				// 1.	Read Jun1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Jun2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jun3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Jun4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Jun5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Jun6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Jun7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Jun8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Jun9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Jun9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Jun9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun11 = atof(pch);
			}

			else if (linesRead == index + 6)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month7,pch);

				//--------------------------------------------------------------------
				// 7. JULY DATA
				//--------------------------------------------------------------------
				// 1.	Read Jul1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Jul2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jul3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Jan4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Jan5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Jan6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Jan7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Jul8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read ul9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read ul9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul10 = atof(pch);


				//--------------------------------------------------------------------
				// 9.	Read ul9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul11 = atof(pch);
			}
			else if (linesRead == index + 7)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month8,pch);

				//--------------------------------------------------------------------
				// 8. AUGUST DATA
				//--------------------------------------------------------------------
				// 1.	Read Aug1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug1= atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Aug2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Aug3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Aug4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Aug5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Aug6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Aug7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Aug8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Aug9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug9 = atof(pch);


				//--------------------------------------------------------------------
				// 9.	Read Aug9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Aug9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug11 = atof(pch);				
			}

			else if (linesRead == index + 8)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month9,pch);

				//--------------------------------------------------------------------
				// 9. SEPTEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Sep1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Sep2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Sep3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Sep4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Sep5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Sep6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Sep7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Sep8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Sep9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Sep9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Sep9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep11 = atof(pch);
			}

			else if (linesRead == index + 9)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month10,pch);

				//--------------------------------------------------------------------
				// 10. OCTOBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Oct1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Oct2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Oct3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Oct4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Oct5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Oct6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Oct7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Oct8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Oct9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Oct9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Oct9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct11 = atof(pch);
			}

			else if (linesRead == index + 10)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month11,pch);

				//--------------------------------------------------------------------
				// 11. NOVEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Nov1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Nov2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Nov3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Nov4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Nov5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Nov6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Nov7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Nov8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Nov9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Nov9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Nov9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov11 = atof(pch);
			}

			else if (linesRead == index + 11)
			{
				//--------------------------------------------------------------------
				// A.	Read index
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.index,pch);

				//--------------------------------------------------------------------
				// B.	Read month
				pch = strtok (NULL, ",");
				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				strcpy(tempCBoxEntry.month12,pch);

				//--------------------------------------------------------------------
				// 12. DECEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Dec1
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Dec2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jan3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Dec4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Dec5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Dec6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Dec7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Dec8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Dec9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec9 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Dec9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec10 = atof(pch);

				//--------------------------------------------------------------------
				// 9.	Read Dec9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec11 = atof(pch);

				index = index + 12;
				populateIndexVector = true;
			}

			
			//--------------------------------------------------------------------	
			// Enter this information in the  vector
			if(populateIndexVector == true)
			{
				IndexDataNew_1.push_back(tempCBoxEntry);
				populateIndexVector = false;
			}
	} 

	// for debug
	//unsigned int jjhu = 0;
	//jjhu = IndexDataNew_1.size();
	//strcpy(temStrng,IndexDataNew_1[0].month1);
	//temp = IndexDataNew_1[0].Jan1;
	//temp = IndexDataNew_1[0].Dec1;

	//strcpy(temStrng, IndexDataNew_1[1].month1);
	//temp = IndexDataNew_1[10].Jan1;
	//temp = IndexDataNew_1[10].Dec1;

	fclose(fptr);

	
}
void CSAPP1Dlg::ReadClimateDataFile()
{
	// Read from file and ad data to vectors
	char tempStr[MAX_CHARS_IN_A_ROW_CLIMATE_FILE];
	char *pError;
	char *pch;
	ClimateData tempCBoxEntry;
	bool isOk = TRUE;
	int linesRead = 0;
	int i = 0;
	int climate = 1;
	bool populateClimateVector = false;
	double temp = 0;
	
	//--------------------------------------------------------------------------
	// Data to be read from two files
	// 1. First read SAP climate data file
	//--------------------------------------------------------------------------
	
	while (TRUE)
	{
		// Read a line from a CSV file
		pError = fgets(tempStr,MAX_CHARS_IN_A_ROW_CLIMATE_FILE,fptrSAPandClimateFile);
		linesRead ++;

		// if reached end of file
		if(pError == NULL)
		{	
			break;
		}

		if (linesRead == climate)
		{
			//--------------------------------------------------------------------
			// 1.	Read the location name
			pch = strtok (tempStr,",");


			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			
			strcpy( tempCBoxEntry.locationName, pch);

			// If have read end-of-line character, replace it with null
			if (tempCBoxEntry.locationName[strlen(pch)-1] == 0x0A)
			{
				tempCBoxEntry.locationName[strlen(pch)-1] = 0;
			}
		}

		//--------------------------------------------------------------------
		// 1. JANUARY DATA
		//--------------------------------------------------------------------
		else if (linesRead == climate + 1)
		{	
			// 1.	Read Jan1
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Jan2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Jan3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Jan4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Jan5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Jan6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Jan7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Jan8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Jan9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Jan9 = atof(pch);			
		}

		else if (linesRead == climate + 2)
		{
			//--------------------------------------------------------------------
			// 2. FEBRUARY DATA
			//--------------------------------------------------------------------
			// 1.	Read Feb1
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Feb2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Feb3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Feb4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Feb5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Feb6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Feb7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Feb8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Feb9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Feb9 = atof(pch);
		}

		else if (linesRead == climate + 3)
		{
			//--------------------------------------------------------------------
			// 3. MARCH DATA
			//--------------------------------------------------------------------
			// 1.	Read Mar1
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Mar2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Mar3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Mar4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Mar5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Mar6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Mar7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Mar8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Mar9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Mar9 = atof(pch);
		}

		else if (linesRead == climate + 4)
		{
			//--------------------------------------------------------------------
			// 4. APRIL DATA
			//--------------------------------------------------------------------
			// 1.	Read Apr1
			pch = strtok (tempStr,",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr1 = atof(pch);

			//--------------------------------------------------------------------
			// 2.	Read Apr2
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr2 = atof(pch);
			//--------------------------------------------------------------------
			// 3.	Read Apr3
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr3 = atof(pch);
			//--------------------------------------------------------------------
			// 4.	Read Apr4
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr4 = atof(pch);
			//--------------------------------------------------------------------
			// 5.	Read Apr5
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr5 = atof(pch);
			//--------------------------------------------------------------------
			// 6.	Read Apr6
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr6 = atof(pch);
			//--------------------------------------------------------------------
			// 7.	Read Apr7
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr7 = atof(pch);
			//--------------------------------------------------------------------
			// 8.	Read Apr8
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr8 = atof(pch);
			//--------------------------------------------------------------------
			// 9.	Read Apr9
			pch = strtok (NULL, ",");

			// If some error has occured
			if (pch == NULL)
			{
				isOk = FALSE;
				break;
			}
			tempCBoxEntry.Apr9 = atof(pch);

			}

			else if (linesRead == climate + 5)
			{
				//--------------------------------------------------------------------
				// 5. MAY DATA
				//--------------------------------------------------------------------
				// 1.	Read May1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read May2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read May3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read May4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read May5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read May6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read May7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read May8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read May9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.May9 = atof(pch);
			}
			else if (linesRead == climate + 6)
			{
				//--------------------------------------------------------------------
				// 6. JUNE DATA
				//--------------------------------------------------------------------
				// 1.	Read Jun1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Jun2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jun3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Jun4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Jun5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Jun6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Jun7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Jun8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Jun9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jun9 = atof(pch);
			}

			else if (linesRead == climate + 7)
			{
				//--------------------------------------------------------------------
				// 7. JULY DATA
				//--------------------------------------------------------------------
				// 1.	Read Jul1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Jul2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jul3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Jan4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Jan5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Jan6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Jan7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Jul8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read ul9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Jul9 = atof(pch);
			}
			else if (linesRead == climate + 8)
			{
				//--------------------------------------------------------------------
				// 8. AUGUST DATA
				//--------------------------------------------------------------------
				// 1.	Read Aug1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Aug2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Aug3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Aug4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Aug5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Aug6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Aug7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Aug8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Aug9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Aug9 = atof(pch);
			}

			else if (linesRead == climate + 9)
			{
				//--------------------------------------------------------------------
				// 9. SEPTEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Sep1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Sep2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Sep3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Sep4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Sep5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Sep6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Sep7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Sep8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Sep9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Sep9 = atof(pch);
			}

			else if (linesRead == climate + 10)
			{
				//--------------------------------------------------------------------
				// 10. OCTOBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Oct1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Oct2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Oct3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Oct4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Oct5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Oct6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Oct7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Oct8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Oct9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Oct9 = atof(pch);
			}

			else if (linesRead == climate + 11)
			{
				//--------------------------------------------------------------------
				// 11. NOVEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Nov1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Nov2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Nov3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Nov4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Nov5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Nov6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Nov7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Nov8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Nov9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Nov9 = atof(pch);
			}

			else if (linesRead == climate + 12)
			{

				//--------------------------------------------------------------------
				// 12. DECEMBER DATA
				//--------------------------------------------------------------------
				// 1.	Read Dec1
				pch = strtok (tempStr,",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec1 = atof(pch);

				//--------------------------------------------------------------------
				// 2.	Read Dec2
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec2 = atof(pch);
				//--------------------------------------------------------------------
				// 3.	Read Jan3
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec3 = atof(pch);
				//--------------------------------------------------------------------
				// 4.	Read Dec4
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec4 = atof(pch);
				//--------------------------------------------------------------------
				// 5.	Read Dec5
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec5 = atof(pch);
				//--------------------------------------------------------------------
				// 6.	Read Dec6
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec6 = atof(pch);
				//--------------------------------------------------------------------
				// 7.	Read Dec7
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec7 = atof(pch);
				//--------------------------------------------------------------------
				// 8.	Read Dec8
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec8 = atof(pch);
				//--------------------------------------------------------------------
				// 9.	Read Dec9
				pch = strtok (NULL, ",");

				// If some error has occured
				if (pch == NULL)
				{
					isOk = FALSE;
					break;
				}
				tempCBoxEntry.Dec9 = atof(pch);

				climate = climate + 13;
				populateClimateVector = true;
			}

			
			//--------------------------------------------------------------------	
			// Enter this information in the  vector
			if(populateClimateVector == true)
			{
				ClimateData_1.push_back(tempCBoxEntry);
				populateClimateVector = false;
			}
	} 

	unsigned int tempSize = 0;
	unsigned int tempSize2 = 0;


	tempSize = IndexDataNew_1.size();
	tempSize2 = tempSize;

	// for debug

	//strcpy(temStrng,ClimateData_1[0].locationName);
	//temp = ClimateData_1[0].Jan1;
	//temp = ClimateData_1[0].Dec1;

	//strcpy(temStrng, ClimateData_1[1].locationName);
	//temp = ClimateData_1[1].Jan1;
	//temp = ClimateData_1[1].Dec1;

	//strcpy(temStrng,ClimateData_1[2].locationName);
	//temp = ClimateData_1[2].Jan1;

	//strcpy(temStrng,ClimateData_1[3].locationName);
	//temp = ClimateData_1[3].Jan1;

	fclose(fptrSAPandClimateFile);
}

void CSAPP1Dlg::OnClose()
{
	// TODO: Add your message handler code here and/or call default

	//SendMessage(WM_CLOSE);
	CDialog::OnClose();
}

void CSAPP1Dlg::OnFileExit()
{
	OnCancel();
}

void CSAPP1Dlg::OnFileSaveas()
{
	//--------------------------------------------------------------------
	// Save dialog to save the project name
	// Warn user not to change the directory
	CFileDialog m_idFile( false, "proj", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, // false to save
		"Project files (*.csv)|*.csv|*.csv|", AfxGetMainWnd());
	m_idFile.m_ofn.lpstrInitialDir = "..\\projects"; // default directory os one step up the executable

	// If user choses to Save File..
	if (m_idFile.DoModal()==IDOK)
	{
		CString strPathName = m_idFile.GetPathName();
		projectFileName     = m_idFile.GetPathName();// GetFileName();
		projectFileNameNoPath = m_idFile.GetFileName();

		AfxExtractSubString(projectFileNameNoExt, projectFileNameNoPath, 0, '.');

		//------------------------------------------------
		// If opened tab is untitled, delete it
		//------------------------------------------------
		// Read title of selected tab
		//------------------------------------------------
		is_save_dialg_called = true;
		DeleteUntitledTab();		
		SaveProjectFile_2();

		//-------------------------------------------------------------------
		// Copy file name to vector
		//-------------------------------------------------------------------
		OpenProjectInfo tempEntry;
		tempEntry.projectFileName       = projectFileName;
		tempEntry.projectFileNameNoPath = projectFileNameNoPath;		
		tempEntry.projectFileNameNoExt  = projectFileNameNoExt;
		projectInfo.push_back(tempEntry);
	}
	else
	{
		return;
	}	

	titleBarText = versionText + " " + "-" + " " + projectFileNameNoExt;
	SetWindowText(titleBarText);

	//-------------------------------------------------------------------
	// This flag ia added to ensure that estate can only display
	// saved projects
	chk_if_project_saved     = true;
}

void CSAPP1Dlg::OnHelpAbout()
{
	CAboutDlg dlgAbout;
	dlgAbout.DoModal();
}

void CAboutDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	OnOK();
}



void CSAPP1Dlg::OnFileAddToEstate()
{
	DisplayAddToEstateDialog();
}

void CSAPP1Dlg::DisplayAddToEstateDialog()
{
	if(chk_if_project_saved == true)
	{
		CDlg_AddToEstate Dlg_AddToEstate;
		Dlg_AddToEstate.DoModal();

		if(add_dwelling_to_estate == true)
		{
			add_dwelling_to_estate = false;
			AddPropertyToEstate();
		}
	}
	else
	{
		MessageBox("Only saved projects can be added to estate. Please save project.", "Help", MB_OK);
	}

}

void CSAPP1Dlg::OnFileOpenEstate()
{
	CDlg_Estate Dlg_Estate;
	Dlg_Estate.DoModal();
}

void CSAPP1Dlg::OnTcnSelchangeTab3(NMHDR *pNMHDR, LRESULT *pResult)
{
	CDlg_Estate Dlg_Estate;
	Dlg_Estate.DoModal();

	*pResult = 0;
}

void CSAPP1Dlg::OnNMClickTab3(NMHDR *pNMHDR, LRESULT *pResult)
{
	CDlg_Estate Dlg_Estate;
	Dlg_Estate.DoModal();

	*pResult = 0;
}

//void CSAPP1Dlg::OnFileOpenEstate()
//{
//	CDlg_Estate Dlg_Estate;
//	Dlg_Estate.DoModal();
//}
//
//void CSAPP1Dlg::OnTcnSelchangeTab3(NMHDR *pNMHDR, LRESULT *pResult)
//{
//	CDlg_Estate Dlg_Estate;
//	Dlg_Estate.DoModal();
//
//	*pResult = 0;
//}
//
//void CSAPP1Dlg::OnNMClickTab3(NMHDR *pNMHDR, LRESULT *pResult)
//{
//	CDlg_Estate Dlg_Estate;
//	Dlg_Estate.DoModal();
//
//	*pResult = 0;
//}
void CSAPP1Dlg::OnEstateAddToEstate()
{
	DisplayAddToEstateDialog();
}

void CSAPP1Dlg::OnEstateViewEstate()
{
	CDlg_Estate Dlg_Estate;
	Dlg_Estate.DoModal();
}

void CSAPP1Dlg::OnExportToEspr()
{
	char buffer[1000];

	// Create text for message boz, also add TC id
	sprintf ( buffer, "This is modelQualifier %s of HUE 1.8 suite of models. Download from https://espr.svn.cvsdude.com/esp-r/trunk", XIACSOL_string1 );
	
	// Display message box
	MessageBox( buffer, "Help", MB_OK);
}

void CSAPP1Dlg::OnExportExporttosapinformation()
{
	OnFileSave();
}

BOOL CSAPP1Dlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message==WM_KEYDOWN)
	{
		if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE)
			pMsg->wParam=NULL ;
	} 

	return CDialog::PreTranslateMessage(pMsg);
}


void CSAPP1Dlg::OnFileReadFromSHCS()
{
	WriteSHCSDataToDialogs();
}





