XI-E / LHospital

A basic management system for a general hospital
0 stars 0 forks source link

Problem with hide() in box class #7

Open chiru9670 opened 6 years ago

chiru9670 commented 6 years ago

This is the declaration of my box object:

box menu2(c, window.getwidth() * 0.6, window.getheight() - 6 );
//some code in between(unimportant)//
menu2.clear();
menu2.setheight(menu.getheight());
menu2.settcolor(GREEN);
menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
menu2.settcolor(WHITE);
menu2 << "Employee Details: " << ui::endl;
menu2.settcolor(ui::tcolor);

At this point, the output is: 1 as expected. Now when I hide this box, this is the output: 2 as expected. After this, the following code is run:

menu2.display();
menu2 << "ID: " << e->get_id() << ui::endl;

The output here is: 3 as expected. Now when I hide this box, this is the output: 4 which is highly unexpected. Is there something wrong with my code, or is it something else?

chiru9670 commented 6 years ago

Ok, I was trying to debug this a little, and I can't figure out anything from this point: I commented out the main function of hosp.cpp, and made another main function in ui/test.cpp, which is as follows:

void main()
{
    ui::clrscr();
    box menu2(coord(2, 4), 40, 10 );
    menu2.settcolor(GREEN);
    menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
    menu2.settcolor(WHITE);
    int menu2_height;
    menu2_height = 10;
//  menu2.setheight(menu2_height);
    menu2 << "View employee data" << ui::endl;
    menu2.settcolor(ui::tcolor);
//  menu2 << "Enter employee's id: ";
    unsigned long id;
    menu2 >> id;
    menu2 << ui::endl;
    menu2.setexit_button("Submit");
    menu2.loop();

    menu2.clear();
    menu2.setheight(15);
    menu2.settcolor(GREEN);
    menu2 << ui::centeralign << "Employee Management" << ui::endl << ui::endl;
    menu2.settcolor(WHITE);
    menu2 << "Employee Details: " << ui::endl;
    menu2.settcolor(ui::tcolor);
        getch();
        menu2.hide();
        getch();
        menu2.display();
        getch();
    menu2 << "ID: " << id << ui::endl;
        getch();
        menu2.hide();
        getch();
        menu2.display();
        getch();
}

The same problem as mentioned in the issue came up here. Now I commented out the line menu2 << "View employee data" << ui::endl;. Here, another problem came up; menu2 << "ID: " << id << ui::endl; doesn't print the line ID: (whatever id is) at all...

arpit-saxena commented 6 years ago

This is quite weird. I'll have to look into it. Your code is alright

arpit-saxena commented 6 years ago

Something very, very weird is going on. It seems like Turbo is running out of memory here. I narrowed it down to a place where I figured the problem has to lie. The problem was in a statement that just used new to allocate heap memory, and that statement resulted in another memory space being modified, which I guess is turbo running out of memory and reallocating stuff.

arpit-saxena commented 6 years ago

SOMEONE NEEDS TO FIX THIS!! ANY CLUE REGARDING WHAT'S GOING ON WOULD BE HELPFUL

chiru9670 commented 6 years ago

You guys wanna ask some prof at IITD/IITB about this??!!

arpit-saxena commented 6 years ago

Asking a prof would be overkill. Let's ask some of the genius coders here. Do you know any?

I asked some people in some groups. Let's see what happens.

And... do you know where can we run turbo c++ here?

chiru9670 commented 6 years ago

Well, I can run it on my roommate's laptop here...

sankalpgambhir commented 5 years ago

Oioioioioioi