|
using System;
using System.IO;
class PreproTest {
static void Test(string s) {
Console.WriteLine(ms.Substitute(s));
}
static string Input() {
Console.Write(">> ");
return Console.In.ReadLine();
}
class MyMacroSubstitutor : MacroSubstitutor {
public override string CustomReplacement(string s) {
switch(s) {
case "DATE": return DateTime.Now.ToString();
case "USER": return Environment.GetEnvironmentVariable("USERNAME");
}
return "";
}
}
static MacroSubstitutor ms = new MyMacroSubstitutor();
static void Main(string[] args) {
string line;
ms.AddMacro("DATE",MacroEntry.Custom,null);
ms.AddMacro("USER",MacroEntry.Custom,null);
while((line = Input()) != null) {
line = ms.ProcessLine(line);
if (line != "")
Console.WriteLine(line);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.