

int charges_tag=('C'<<24)|('H'<<16)|('R'<<8);


// return 0 if OK to turn on

int charges_on(int file)
{
 if(tagexists(file,charges_tag,0))
 {
  if(tagread(file,charges_tag,0)) return(0);
 }

 return(1);
}



int charges_entry(int entry, int subcode)
{
 string s;
 int    bits;
 int    file;

 file=currentfile();

 bits=fileinfo(file,s);

 if(tagexists(file,charges_tag,0))
 {
  if(tagread(file,charges_tag,0))
  {
   tagwrite(file,charges_tag,0,0);
   if((bits & 0x3)==0x3); chargesstopmessage(file);
   return(0);
  }
 }

 if(!(bits & 0x1))
 {
  s="{CHARGES_01}";
  translate(s);
  messagebox(s);
 }
 else
 {
  tagwrite(file,charges_tag,1,0);
  if(bits & 0x2); chargesstartmessage(file);
 }
 return(0);
}



int charges_flags(int entry, string &text)
{
 if(tagexists(currentfile(),charges_tag,0))
 {
  if(tagread(currentfile(),charges_tag,0)) return(TICKED);
 }
 return(0);
}



void main(void)
{
 script_menu_initialise();

 addentry_menu(script_handle,"charges_entry","charges_flags","","","{CHARGES_00}");

}
