-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathChapter9.cs
More file actions
38 lines (31 loc) · 993 Bytes
/
Chapter9.cs
File metadata and controls
38 lines (31 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WattleScript.Interpreter;
using WattleScript.Interpreter.Loaders;
using WattleScript.Interpreter.Platforms;
namespace Tutorials.Chapters
{
[Tutorial]
static class Chapter09
{
[Tutorial]
static void ChangePlatform()
{
// This prints "function"
Console.WriteLine(Script.RunString("return type(os.exit);").ToPrintString());
// Save the old platform
var oldplatform = Script.GlobalOptions.Platform;
// Changing platform after a script has been created is not recommended.. do not do it.
// We are doing it for the purpose of the walkthrough..
Script.GlobalOptions.Platform = new LimitedPlatformAccessor();
// This time, this prints "nil"
Console.WriteLine(Script.RunString("return type(os.exit);").ToPrintString());
// Restore the old platform
Script.GlobalOptions.Platform = oldplatform;
}
}
}