1 Reply Latest reply: Oct 8, 2010 7:12 AM by 800537 RSS

    My program be run once !

    800537
      Hi guys.
      My program be run once,I am using rms database and I put number of execute in the first record.
      Program run successfully in first time.but menu doesn't work when the program was closed and be run it again.( exit key works only! ). this is a part of my progam:

      Display display;
      Form addserver,formeditserver;
      SMSFunction sms;
      DataBaseFunction db;
      private Lang string;
      Alert alr;
      public List l1,l2,editserver,removeserver;
      Pic pic;
      Address addr;
      Command ok,okOnOption,Exit,ExitOnMap,ExitOnOption,okOnRemove,BackOnRemove,RemoveOk,RemoveCancel;
      Command saveOnAdd,backOnAdd,okOnEdit,BackOnEdit,backOnEditFrom,saveOnEditFrom;
      Canvas fullmap;
      boolean fr=true;
      TextField addname,editname;
      TextField addnumber,editnumber;
      TextField addport,editport;
      public void startApp() {

      init();

      if(db.GetData("MsbaData", 1).equalsIgnoreCase("-1") || Integer.parseInt(db.GetData("MsbaData",1))==0){ //First tun
      alr=new Alert(string.TitleFirstRun,string.FirstRun,null,AlertType.INFO);
      alr.setTimeout(Alert.FOREVER);

      fr=false;
      db.SetData("0", "MsbaData", true); //MsbaData is my db, true for create and "0" is data


      }


      if(!fr)display.setCurrent(alr,l1);
      else display.setCurrent(l1);


      }

      public void init(){
      display=Display.getDisplay(this);
      l1=new List(string.ListTitle,Choice.IMPLICIT);
      l2=new List(string.l2,Choice.IMPLICIT);
      sms=new SMSFunction();
      pic=new Pic();
      db=new DataBaseFunction();
      addserver=new Form(string.FormTitle) ;
      ok=new Command(string.cmd_ok,Command.OK,1);
      okOnOption=new Command(string.cmd_ok,Command.OK,1);
      ExitOnMap=new Command(string.cmd_back,Command.BACK,2);
      Exit=new Command(string.cmd_exit,Command.EXIT,2);
      ExitOnOption=new Command(string.cmd_back,Command.BACK,2);
      BackOnEdit=new Command(string.cmd_back,Command.BACK,2);
      okOnEdit=new Command(string.cmd_ok,Command.OK,1);
      BackOnRemove=new Command(string.cmd_back,Command.BACK,2);
      okOnRemove=new Command(string.cmd_ok,Command.OK,1);
      RemoveOk=new Command(string.remove_ok,Command.OK,1);
      RemoveCancel=new Command(string.remove_cancel,Command.BACK,2);
      fullmap=new gcanvas();
      //Main Menu

      l1.append(string.L1_0,pic.PictureLoader(addr.L1_0));
      l1.append(string.L1_1,pic.PictureLoader(addr.L1_1));
      l1.append(string.L1_2,pic.PictureLoader(addr.L1_2));
      l1.append(string.L1_3,pic.PictureLoader(addr.L1_3));
      l1.append(string.L1_4,pic.PictureLoader(addr.L1_4));
      l1.addCommand(ok);
      l1.addCommand(Exit);
      l1.setCommandListener(this);
      //Option Menu

      l2.append(string.l2_1,pic.PictureLoader(addr.L2_1));
      l2.append(string.l2_2, pic.PictureLoader(addr.L2_2));
      l2.append(string.l2_3, pic.PictureLoader(addr.L2_3));
      l2.addCommand(okOnOption);
      l2.addCommand(ExitOnOption);

      //mapset
      fullmap.setFullScreenMode(true);
      fullmap.addCommand(ExitOnMap);
      // add server form
      addname=new TextField(string.Form_name,null,20,TextField.ANY);
      addnumber=new TextField(string.Form_number,null,20,TextField.PHONENUMBER);
      addport=new TextField(string.Form_port,null,4,TextField.NUMERIC);
      saveOnAdd=new Command(string.cmd_save,Command.OK,1);
      backOnAdd=new Command(string.cmd_back,Command.BACK,2);
      addport.setString("145");
      addserver.append(addname);
      addserver.append(addnumber);
      addserver.append(addport);
      addserver.addCommand(saveOnAdd);
      addserver.addCommand(backOnAdd);
      //edit server list and form
      editserver=new List(string.edit_server_title,Choice.IMPLICIT);
      editserver.addCommand(okOnEdit);
      editserver.addCommand(BackOnEdit);

      formeditserver=new Form(string.form_edit_server);
      editname=new TextField(string.Form_name,null,20,TextField.ANY);
      editnumber=new TextField(string.Form_number,null,20,TextField.PHONENUMBER);
      editport=new TextField(string.Form_port,null,4,TextField.NUMERIC);
      saveOnEditFrom=new Command(string.cmd_save,Command.OK,1);
      backOnEditFrom=new Command(string.cmd_back,Command.BACK,2);
      formeditserver.addCommand(saveOnEditFrom);
      formeditserver.addCommand(backOnEditFrom);
      formeditserver.append(editname);
      formeditserver.append(editnumber);
      formeditserver.append(editport);
      //remove server list
      removeserver=new List(string.remove_server_title,Choice.IMPLICIT);
      removeserver.addCommand(okOnRemove);
      removeserver.addCommand(BackOnRemove);


      //==================================================

      }
        • 1. Re: My program be run once !
          800537
          After 3days....,
          everything must be define even never used.
          My alert never be used but must be defined and program not work again!
          in first time it was defined but in the second,... time was not defined.

          check my program and first "if".