public static void consoleMode()
    {
        Scanner scan = new Scanner(System.in);
        
        String command = "";
        boolean reading = false;
        Script script;
        Stack<StackFrame> stack = new Stack<StackFrame>();
        Map<String,StackFrame> context = new HashMap<String,StackFrame>();
        
        while(true)
        {
            if(reading)
            {
                String tmp = scan.nextLine();
                if(Pattern.matches(END_READ,tmp.trim()))
                {
                    script = new Script(command);
                    try
                    {
                        script.execute(stack, context);
                    }catch(Exception e)
                    {
                        System.err.println(
                            "The script had an error. It may not have\n" +
                            "finished and so you may get bad results after this.\n" +
                            "All I know is: " + e.getMessage() 
                        );
                    }
                    reading = false;
                }else
                {
                    command += tmp + "\n";
                }
            }else
            {
                command = scan.nextLine();
                if(Pattern.matches(START_READ,command.trim()))
                {
                    // read in a multiline command
                    command = "";
                    reading = true;
                }else if(Pattern.matches(EXIT_STRING,command.trim()))
                {
                    // exit the program
                    break;
                }else // try to execute straight away!
                {
                    script = new Script(command);
                    try
                    {
                        script.execute(stack,context);
                    }catch(Exception e)
                    {
                        System.err.println(
                            "The script had an error. It may not have\n" +
                            "finished and so you may get bad results after this.\n" +
                            "All I know is: " + e.getMessage() 
                        );
                    }
                }
            }
        }
    }