Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace CustomScriptingLanguage.Code_Management
  9. {
  10.  
  11.     class ReadCode
  12.     {
  13.         public static string scriptpath;
  14.         public static int counter = 0;
  15.         public static string line;
  16.         public static bool showlines = false;
  17.         public static bool skipline = false;
  18.         public static string skipto = null;
  19.         public static string getspaces = null;
  20.         public static bool skipblock = false;
  21.  
  22.         public static void ReadScript()
  23.         {
  24.             try
  25.             {
  26.                 if (File.ReadAllText(scriptpath).StartsWith("::LIONSCRIPT") &&
  27.                     File.ReadAllText(scriptpath).EndsWith("LIONSCRIPT::"))
  28.                 {
  29.                     //You can run this!
  30.                     Console.Clear();
  31.                     Console.WriteLine("Running Script...");
  32.                     Console.WriteLine();
  33.  
  34.                     //Read Lines
  35.                     StreamReader file =
  36.                        new StreamReader(scriptpath);
  37.                     while ((line = file.ReadLine()) != null)
  38.                     {
  39.  
  40.                             if(skipblock)
  41.                             {
  42.  
  43.                                 if(line == $"{getspaces}{skipto}::")
  44.                                 {
  45.                                     skipblock = false;
  46.                                 }
  47.  
  48.                                 else
  49.                                 {
  50.                                     continue;
  51.                                 }
  52.  
  53.                             }
  54.  
  55.                             if (skipline)
  56.                             {
  57.                                 skipline = false;
  58.                                 continue;
  59.                             }
  60.  
  61.                             //Check lines and see if they contain keywords
  62.                             Code_Management.CodeReact.ReactToCode(line);
  63.  
  64.                         //Get Line
  65.                         counter++;
  66.  
  67.                     }
  68.  
  69.                     file.Close();
  70.  
  71.                 }
  72.                 else
  73.                 {
  74.                     //Whoops! you cant run this!
  75.                     Console.WriteLine(); Console.WriteLine("Cant run this script...");
  76.                 }
  77.             }
  78.             catch (Exception e){ Console.WriteLine(); Console.WriteLine($"Error at line {counter + 1}");}
  79.  
  80.             //Finish Up
  81.             Console.WriteLine();
  82.             Console.WriteLine("Press 'Enter' to quit...");
  83.             Console.ReadLine();
  84.         }
  85.  
  86.       }
  87.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement