/// <summary> /// Executes the NEW command. /// </summary> public void Execute() { _variableRepository.Clear(); _runEnvironment.Clear(); _dataStatementReader.RestoreToLineNumber(null); _programRepository.Clear(); }
/// <summary> /// Executes the LOAD comand. /// </summary> /// <param name="tokeniser">Tokeniser to use.</param> public void Execute(ITokeniser tokeniser) { var fileName = _expressionEvaluator.GetExpression().ValueAsString(); int lastProgramLine = 0; try { var program = _fileSystem.File.ReadAllLines(fileName, System.Text.Encoding.UTF8); _programRepository.Clear(); foreach (var line in program) { var programLine = tokeniser.Tokenise(line); if (!programLine.LineNumber.HasValue) { throw new Exception("MISSING LINE NUMBER"); } lastProgramLine = programLine.LineNumber.Value; _programRepository.SetProgramLine(programLine); } } catch (Exception ex) { throw new Exceptions.BasicException($"BAD LOAD {ex.Message}, LAST GOOD LINE WAS {lastProgramLine}", 100); } }