ahhh
Type: Posts; User: Terran
ahhh
Ok it almost works;
write:
void fincal2Frame::OnClose(wxCloseEvent &event)
{
theBar->RemoveIcon();
fout.open("list.txt");
fout << m_TheList->getSize() << "\n"; // write the...
ok so i have..
fin.open("list.txt"); //Load the list of bills.
if (fin && fin.peek()){ // if the file was found.
while (!fin.eof() ){
std::string TempName, TempCost;...
so somthing like this? I'm confused on how getline works?
fin.open("list.txt"); //Load the list of bills.
if (fin && fin.peek()){ // if the file was found.
while (!fin.eof()...
Ok so my write function works!
void fincal2Frame::OnClose(wxCloseEvent &event)
{
theBar->RemoveIcon();
fout.open("list.txt");
for (int i = 0; i < m_TheList->getSize();i++){
...
Why does this tell me i'm missing ")"'s?
p.s. Will it work? I'm not sure how to use ofstream great?
void fincal2Frame::OnClose(wxCloseEvent &event)
{
theBar->RemoveIcon();
...
er. sorry, i meant that i was trying to write out whole objects instead of explicitly writing out each value held by the objects.
Because i am writing BillData Objects to the file an not the info they hold, so it made sense to use binary.
ok, so i have this as the read from file:
if (fin){ // if the file was found.
BillData temp("","",wxDateTime::Now());
fin.read((char *)&temp, sizeof temp);
...
so i've got my write function to work that saves the file.
...
fout.open("list.bin", std::ios::binary);
for (int i = 0; i < m_TheList->getSize();i++){
BillData billdat =...
anybody?
I added some code, and i got
C:\Users\Matt\Desktop\Projects\fincal2\fincal2Main.cpp|219|error: stray '\127' in program|
so i commented it all out, but i still get it, what's going on? What does...
Well it would see that the main error was that i overlooked initializing m_TheList in the GUIFrame constructor.
also, i don't actually use "getData" because it seemed like a bad way to do things....
fair enough, here's all the relevant code,
Ok then i will post code, attempt to bear with me,
GUIFrame has a protected variable and an acesscor;
...
protected:
More detective work seems to show that it's crashing when deque, (or vector) tries to access their internal iterators. Which i can't understand? I hope i havn't stumped the panal on this one!
For some reason, accessing the deque is causing segfaults, and i really need to figure out why
It doesn't, it derives from GUIFrame which has a protected member of BillList.
Edit: i see what you're getting at, Fincal2Frame has a handler (of the same name) that passes the info to the...
if(theString != "" && theCost > 0 && goodValue){
((BillDia*)GetParent())->AddBill(theString, theCost);
((fincal2Frame*)GetParent())->insertBill(theString, theCost, theDate);
...
This is also causing a segfault
int getSize() {if( theList.empty()){ return 0;} else { int temp = theList.size(); return temp;}};
ok so i have,
class BillData
{
private:
wxString Name;
wxString Cost;
wxDateTime DueDate;
Ahh then that's ok, cause i was thinking i'd get an error if tried to read from a non-existent file. So really i can just try to read the data and it's no big deal if it doesn't read it.
So in the constructor for my class, i want it to check to see if the list file is there list.bin if so i want it to open it, else wise, i'd like it to create it. I also want it to ignore it if it's...
i wasn't sure about the destructor. But i was using deques because of their random insertion ability. but you may be right about using a struct.
Interesting idea, although a bit much for this application.
Well i'm storing it as an int because i'm sorting it by date. e.g. 612 > 610, so it goes before it in the list. So i'd be making life hard if i used it as a string. Unless i make a temporary string,...