diff --git a/Upsilon/ScriptOptions.cs b/Upsilon/ScriptOptions.cs index ab7ec83..0f3b77f 100644 --- a/Upsilon/ScriptOptions.cs +++ b/Upsilon/ScriptOptions.cs @@ -1,3 +1,4 @@ +using System; using Upsilon.Binder; using Upsilon.Evaluator; @@ -22,5 +23,6 @@ namespace Upsilon public EvaluationScope OverrideStaticScope { get; set; } = null; public ScriptLoader ScriptLoader { get; set; } = new ScriptLoader(); public ModuleHandler ModuleHandler { get; set; } = new ModuleHandler(); + public Action PrintResult { get; set; } = Console.WriteLine; } } \ No newline at end of file diff --git a/Upsilon/StandardLibraries/BasicFunctions.cs b/Upsilon/StandardLibraries/BasicFunctions.cs index 82437d1..3eff75a 100644 --- a/Upsilon/StandardLibraries/BasicFunctions.cs +++ b/Upsilon/StandardLibraries/BasicFunctions.cs @@ -52,6 +52,13 @@ namespace Upsilon.StandardLibraries return new PairsScriptIterator(table); } + [ScriptFunction("print", "Prints a message to the action given in the script options", passScriptReference: true, + directScriptManipulation: true)] + public void Print(Script script, ScriptType message) + { + script.Options.PrintResult.Invoke(message.ToCSharpObject().ToString()); + } + [ScriptFunction("require", "Loads a module from the module path, using the given script loader.", true, true)] public ScriptType Require(Script script, ScriptString fileName)