Losetta 0.9.23

There is a newer version of this package available.
See the version list below for details.
dotnet add package Losetta --version 0.9.23                
NuGet\Install-Package Losetta -Version 0.9.23                
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.9.23" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Losetta --version 0.9.23                
#r "nuget: Losetta, 0.9.23"                
#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.9.23

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

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.

NameSpaceManerger.Add(typeof(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.
  • net6.0

    • No dependencies.

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 145 3/28/2024
0.10.4 203 12/31/2023
0.10.2 149 12/23/2023
0.10.1 154 12/10/2023
0.9.24 173 9/10/2023
0.9.23 139 9/3/2023
0.9.22 161 8/27/2023
0.9.21 164 8/11/2023
0.9.20 248 3/18/2023
0.9.19 254 3/5/2023
0.9.18 302 2/13/2023
0.9.17 337 1/28/2023
0.9.16 353 1/19/2023
0.9.15 349 1/8/2023
0.9.13 358 1/2/2023
0.9.11 344 12/27/2022
0.9.10 329 12/18/2022