Losetta 0.10.5

dotnet add package Losetta --version 0.10.5
NuGet\Install-Package Losetta -Version 0.10.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Losetta" Version="0.10.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Losetta --version 0.10.5
#r "nuget: Losetta, 0.10.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Losetta as a Cake Addin
#addin nuget:?package=Losetta&version=0.10.5

// Install Losetta as a Cake Tool
#tool nuget:?package=Losetta&version=0.10.5

Losetta

English Japanese

AliceScript

Build state LICENCE Commit Activity Nuget

AliceScript is a scripting language callable and customizable from C# and other CLR languages. Losetta is the official language processor for AliceScript and is compatible with AliceScript and AliceSister.

Losetta is published under the MIT License and can be used in proprietary and free/open source applications. Losetta is based on CSCS.

See LICENCE for more information.

How to use

Initialization

From NuGet, install both Losetta and the Losetta.Runtime package in your project.

Applications that load AliceScript must initialize their APIs before running AliceScript. To initialize all APIs available in Alice.Runtime, write

AliceScript.Runtime.Init();

Some applications may want to use only the basic AliceScript functions (if and print). To initialize only the basic API, write as follows

AliceScript.Runtime.InitBasicAPI();

It is also possible to initialize by namespace. For example, if you want to initialize only the file processing API after initializing the basic API, write

AliceScript.NameSpaces.Alice_IO.Initer();

Execute

To execute a script, use the methods of the Alice class in the AliceScript namespace.

To execute a script in string form, call Alice.Execute. Here is an example

var result = Alice.Execute("1+2");
Console.WriteLine(result);//ε‡ΊεŠ›:3

To execute a script from a file, call Alice.ExecuteFile. Here is an example

var result = Alice.ExecuteFile("myScript.txt");

The return value of the Execute and ExecuteFile methods is a Variable class, representing some value in AliceScript; you can convert this to use the value result in C# code or use a generic method. For example, the following example calculates 2+3 in AliceScript and stores it in a C# int type.

int result = Alice.Execute<int>("2+3");

Usage for Custom Functions

In AliceScript, you can bind a C# function as is if it has only one function overload. The following example defines an AliceScript namespace called MyFunctions and a Pow method that returns a number squared when a single number is entered into it.

[AliceNameSpace]
public static class MyFunctions
{
    public static double Pow(double x)
    {
        return x * x;
    }
}

In order to actually call the defined namespace and functions from AliceScript, a bind registration is required. The following example registers MyFunctions defined earlier.

Alice.RegisterFunctions<MyFunctions>();

Another way to define custom functions in AliceScript is to define a class that extends the FunctionBase class. The following example shows how to define a MyFunction function that has one argument and returns the first argument when called.

 public class MyFunction : FunctionBase
    {
        public MyFunction()
        {
            //The name of this function
            this.Name = "MyFunction";
            //Minimum number of arguments required to call this function
            this.MinimumArgCounts = 1;
            this.Run += MyFunction_Run;
        }

        private void MyFunction_Run(object sender, FunctionBaseEventArgs e)
        {
            //Statement to be executed when the function is called
            e.Return = e.Args[0];
        }
    }

In order to actually call the defined function from AliceScript, it must be registered. In the following example, register MyFunction defined earlier.

FunctionBaseManerger.Add(new MyFunction());

Available APIs can be found in the API browser.

For detailed usage instructions, please refer to AliceScriptDocs (Japanese). For those seeking information on earlier versions, AliceScriptWiki may be useful.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Losetta:

Package Downloads
Losetta.Runtime

Package of basic functions and APIs available in AliceScript

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.10.5 106 3/28/2024
0.10.4 185 12/31/2023
0.10.2 112 12/23/2023
0.10.1 117 12/10/2023
0.9.24 121 9/10/2023
0.9.23 102 9/3/2023
0.9.22 125 8/27/2023
0.9.21 128 8/11/2023
0.9.20 220 3/18/2023
0.9.19 224 3/5/2023
0.9.18 262 2/13/2023
0.9.17 307 1/28/2023
0.9.16 318 1/19/2023
0.9.15 318 1/8/2023
0.9.13 326 1/2/2023
0.9.11 311 12/27/2022
0.9.10 304 12/18/2022