public void IOLibraryTest() { var ioTestString = @" (0:0) when the script starts, (5:100) set variable %file to {test.txt}. (5:102) print {%file} to the console. (0:0) when the script starts, (1:200) and the file {%file} exist, (5:202) delete file {%file}. (5:203) create file {%file}. (0:0) when the script starts, (1:200) and the file {%file} exists, (1:203) and the file {%file} can be written to, (5:200) append {Hello World from Monkeyspeak!} to file {%file}. (0:0) when the script starts, (5:150) take variable %test and add 2 to it. (5:102) print {%test} to the console. "; Monkeyspeak.MonkeyspeakEngine engine = GetMonkeySpeakEngine(); Monkeyspeak.Page page = engine.LoadFromString(ioTestString); page.Error += DebugAllErrors; page.LoadSysLibrary(); page.LoadIOLibrary(); page.SetTriggerHandler(Monkeyspeak.TriggerCategory.Cause, 0, HandleAllCauses); page.Execute(0); }
public void TestLoadCompiledFile(string FileName) { Monkeyspeak.MonkeyspeakEngine engine = new Monkeyspeak.MonkeyspeakEngine(); engine.Options.TriggerLimit = int.MaxValue; Monkeyspeak.Page page = engine.LoadCompiledFile(FileName); page.LoadSysLibrary(); page.LoadIOLibrary(); page.LoadMathLibrary(); page.LoadTimerLibrary(); page.Execute(0); Console.WriteLine("Page Trigger Count: " + page.Size); }
public void TimerLibraryTest() { var timerLibTestScript = @" (0:0) when the script starts, (5:101) set variable %timer to 1. (5:300) create timer %timer to go off every 2 second(s). (0:300) when timer %timer goes off, (5:102) print {Timer %timer went off.} to the console. "; Monkeyspeak.MonkeyspeakEngine engine = GetMonkeySpeakEngine(); Monkeyspeak.Page page = engine.LoadFromString(timerLibTestScript); page.Error += DebugAllErrors; page.LoadSysLibrary(); page.LoadTimerLibrary(); page.SetTriggerHandler(Monkeyspeak.TriggerCategory.Cause, 0, HandleAllCauses); page.Execute(0); System.Threading.Thread.Sleep(4000); }