Ok, i guess i have to two problems here and took the more expensive route to solve it i guess, but it doesnt matter cause it is only done once at start up. I have these string arrays that keep commands in them, but i used vector strings to store the data cause i dont know how many commands for each thing there are. So i send al lthis off to a function that stores the values, but unfortunatly, i dont know how to convert vector data into a string array, so i did this
std::string *commandclick = new std::string[CommandDown.size()];
std::string *commanddown = new std::string[CommandDown.size()];
std::string *commandup = new std::string[CommandUp.size()];
std::string *commandover = new std::string[CommandOver.size()];
for (i = 0; i < CommandClick.size(); i++)
{
commandclick = CommandClick;
}
for (i = 0; i < CommandDown.size(); i++)
{
commanddown = CommandDown;
}
for (i = 0; i < CommandUp.size(); i++)
{
commandup = CommandUp;
}
for (i = 0; i < CommandClick.size(); i++)
{
commandover = CommandOver;
}
button->SetCommands(commandclick, CommandClick.size(),commanddown, CommandDown.size(),commandup,
CommandUp.size(),commandover, CommandOver.size());
delete commandclick;
delete commanddown;
delete commandup;
delete commandover;
Incase you need to see the whole function here it is...
int cWindow :: AddButton(cButtonA atr, std::string Filename)
{
if (c_button.size() > MAXBUTTONS)
{
return LIMITEXCEEDED;
}
std::ostringstream oss;
int i = 0;
cButton *button = new cButton();
oss << Filename << atr.Name << ".dat";
std::fstream File(oss.str().c_str(), std::ios::in);
std::string Input = "";
std::vector<std::string> CommandClick;
std::vector<std::string> CommandUp;
std::vector<std::string> CommandDown;
std::vector<std::string> CommandOver;
std::string CommandNone = "none";
if (File.is_open())
{
while(std::getline(File, Input))
{
if (Input == "::Click")
{
while (std::getline(File, Input))
{
if (Input == "::EndClick")
{
break;
}
CommandClick.push_back(Input);
}
}
else if (Input == "::Up")
{
while (std::getline(File, Input))
{
if (Input == "::EndUp")
{
break;
}
CommandUp.push_back(Input);
}
}
else if (Input == "::Down")
{
while (std::getline(File, Input))
{
if (Input == "::EndDown")
{
break;
}
CommandDown.push_back(Input);
}
}
else if (Input == "::Over")
{
while (std::getline(File, Input))
{
if (Input == "::EndOver")
{
break;
}
CommandOver.push_back(Input);
}
}
}
if (CommandClick.size() == 0)
{
CommandClick.push_back(CommandNone);
}
if (CommandDown.size() == 0)
{
CommandDown.push_back(CommandNone);
}
if (CommandUp.size() == 0)
{
CommandUp.push_back(CommandNone);
}
if (CommandOver.size() == 0)
{
CommandOver.push_back(CommandNone);
}
}
std::string *commandclick = new std::string[CommandDown.size()];
std::string *commanddown = new std::string[CommandDown.size()];
std::string *commandup = new std::string[CommandUp.size()];
std::string *commandover = new std::string[CommandOver.size()];
for (i = 0; i < CommandClick.size(); i++)
{
commandclick = CommandClick;
}
for (i = 0; i < CommandDown.size(); i++)
{
commanddown = CommandDown;
}
for (i = 0; i < CommandUp.size(); i++)
{
commandup = CommandUp;
}
for (i = 0; i < CommandClick.size(); i++)
{
commandover = CommandOver;
}
button->SetCommands(commandclick, CommandClick.size(),commanddown, CommandDown.size(),commandup,
CommandUp.size(),commandover, CommandOver.size());
delete commandclick;
delete commanddown;
delete commandup;
delete commandover;
button->SetName(atr.Name);
button->SetCaption(atr.Caption);
button->SetX(atr.X);
button->SetY(atr.Y);
button->SetWidth(atr.Width);
button->SetHeight(atr.Height);
if (!button->SetUp(atr.ButtonUp))
{
return FAILURE;
}
if (!button->SetDown(atr.ButtonDown))
{
return FAILURE;
}
if (!button->SetHighlight(atr.ButtonHighlight))
{
return FAILURE;
}
if (!button->SetExtraA(atr.ButtonExtraA))
{
return FAILURE;
}
if (!button->SetExtraB(atr.ButtonExtraB))
{
return FAILURE;
}
if (!button->SetDisabledT(atr.ButtonDisabled))
{
return FAILURE;
}
button->SetDisabled(atr.Disabled);
button->SetVisible(atr.Visible);
button->SetFontSize(atr.FontSize);
button->SetFontColour(atr.FontColour);
c_button.push_back(button);
Write(c_button[0]->GetName());
return SUCCESS;
}
heres the SetCommands function
void cButton :: SetCommands(std::string CommandClick[], int NumCommandClick, std::string CommandDown[], int NumCommandDown,
std::string CommandUp[], int NumCommandUp, std::string CommandOver[], int NumCommandOver)
{
int i = 0;
cprs_CommandClick_I = new std::string[NumCommandClick];
for (i = 0; i < NumCommandClick; i++)
{
cprs_CommandClick_I = CommandClick;
}
cprs_CommandDown_I = new std::string[NumCommandDown];
for (i = 0; i < NumCommandDown; i++)
{
cprs_CommandDown_I = CommandDown;
}
cprs_CommandUp_I = new std::string[NumCommandUp];
for (i = 0; i < NumCommandUp; i++)
{
cprs_CommandUp_I = CommandUp;
}
cprs_CommandOver_I = new std::string[NumCommandOver];
for (i = 0; i < NumCommandOver; i++)
{
cprs_CommandOver_I = CommandOver;
}
}
This is there error i get...
Debug assertoin failed!
File: dbgdel.cpp
line 51
expression: _BLOCK_TYPE_IS_VALID(pHead->nblockUse)
Thanks in advance
Jake