Exemplo n.º 1
0
  public static void main(String argv[]) {
    // basically, if a command-line parameter is supplied
    // then assume it is a file name and execute it as
    // a simpular program without using the GUI at all.
    if (argv.length == 0) {
      // no command-line parameters, so use GUI.
      InterpreterFrame f = new InterpreterFrame();
    } else if (argv[0].equals("-no-gui")) {
      // run interpreter without GUI!

      // setup new argument list for original
      // Main method
      String[] newargv = new String[argv.length - 1];
      for (int i = 1; i != argv.length; ++i) {
        newargv[i - 1] = argv[i];
      }
      Interpreter.main(newargv);
    } else {
      // run interpreter with GUI, but
      // load requested file.

      InterpreterFrame f = new InterpreterFrame();
      // load file into text view
      f.textView.setText(f.physReadTextFile(new File(argv[0])));
      // update status
      f.statusView.setText(" Loaded file \"" + argv[0] + "\".");
      // reset dirty bit
      f.dirty = false;
    }
  }