void savefile()
      {
//        FrontEnd.statuswindow.append("Saving File...\n");
        FrontEnd.appendToPane(FrontEnd.statuswindow,"Saving File...\n",Color.BLACK);
        //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
        int id = FrontEnd.EditorPane.getSelectedIndex();
        if (FrontEnd.EditorPane.getToolTipTextAt(id) == null)
        {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.addChoosableFileFilter(new MyCustomFilter());
            int returnVal = fileChooser.showSaveDialog(new javax.swing.JFrame());
            if (returnVal == JFileChooser.APPROVE_OPTION)
            {
                try
                {

                    FrontEnd.filepath = fileChooser.getSelectedFile().getPath() + ".s";
                    File n = new File(FrontEnd.filepath);
                    BufferedWriter out = new BufferedWriter(new FileWriter(FrontEnd.filepath));
                    out.write(FrontEnd.activepane.getText());
                    String fname = fileChooser.getSelectedFile().getName();
                    JOptionPane.showMessageDialog(null, "Saved " + ((fileChooser.getSelectedFile() != null) ? fname : "nothing"));
                    FrontEnd.EditorPane.setTitleAt(id, fname);
                    FrontEnd.EditorPane.setToolTipTextAt(id, FrontEnd.filepath);
                    out.close();
                    backend.Register.resetRegisters();
                    clean_branchtable();
                    clean_memtable();

                } catch (Exception e)
                {
                    //FrontEnd.statuswindow.append("Error occured while saving file...\n");
                    FrontEnd.appendToPane(FrontEnd.statuswindow,"Error Occured While Saving File\n",Color.BLACK);
                    //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
                   // FrontEnd.statuswindow.append(e.getStackTrace().toString());
                    FrontEnd.appendToPane(FrontEnd.statuswindow,e.getStackTrace().toString(),Color.BLACK);
                    //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
                    JOptionPane.showMessageDialog(null, "Saving File cancelled.");
                    frontend.FrontEnd.exceptionraised++;
                }
            } else
            {
//                FrontEnd.statuswindow.append("Saving cancelled by user.\n");
                FrontEnd.appendToPane(FrontEnd.statuswindow,"Saving Cancelled By User\n",Color.BLACK);
                //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
            }
        } else
        {
            BufferedWriter out = null;
            try
            {
                FrontEnd.filepath = FrontEnd.EditorPane.getToolTipTextAt(id);
                out = new BufferedWriter(new FileWriter(FrontEnd.filepath));
                out.write(FrontEnd.activepane.getText());
            } catch (IOException ex)
            {
               // FrontEnd.statuswindow.append("Error occured while saving file...\n");
                FrontEnd.appendToPane(FrontEnd.statuswindow,"Error Occured While Saving File\n",Color.BLACK);
                //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
             //   FrontEnd.statuswindow.append(ex.getStackTrace().toString());
                FrontEnd.appendToPane(FrontEnd.statuswindow,ex.getStackTrace().toString(),Color.BLACK);
                //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
            } finally
            {
                try
                {
                    out.close();
                } catch (IOException ex)
                {
                    //FrontEnd.statuswindow.append("Error occured while saving file...\n");
                    FrontEnd.appendToPane(FrontEnd.statuswindow,"Error Occured While Saving File/n",Color.BLACK);
                    //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
                    //FrontEnd.statuswindow.append(ex.getStackTrace().toString());
                    FrontEnd.appendToPane(FrontEnd.statuswindow,ex.getMessage(),Color.BLACK);
                    //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
                    //frontend.FrontEnd.exceptionraised++;
                }
            }

        }
      }