#include <stdarg.h>

#include <mask.h>
#include <urldefid.h>

#include "sc0100.h"

bool TSaldaconto_app::create()
{                         
  open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);  
  _msk = new TMask("sc0100a");
  dispatch_e_menu(MENU_ITEM(1));
  return TRUE;
}

bool TSaldaconto_app::destroy()
{
  delete _msk;
  close_files();
  return TRUE;
}

void TSaldaconto_app::open_files(int logicnum, ...)  
{  
  va_list marker;
  va_start(marker, logicnum);
  while (logicnum > 0)
  {
    CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
    _file.add(new TLocalisamfile(logicnum), logicnum);
    logicnum = va_arg(marker, int);
  }
}

void TSaldaconto_app::on_config_change()
{
  TPartita::carica_allineamento();
}

bool TSaldaconto_app::menu(MENU_TAG)
{          
  TMask& m = curr_mask();
  while (m.run() == K_ENTER)
    edit_partite(m);
  return 0;
}

int sc0100(int argc, char* argv[])
{
  TSaldaconto_app app;
  app.run(argc, argv, "Gestione Saldaconto");
  return 0;
}
