Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dotnet-interface-guide/docs/apl-source-files/apl-source-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# APL Source Files

APL Source files contain definitions (the “source”) of one or more named APL objects, that is, functions, operators, namespaces, classes, interfaces and arrays. They cannot contain anything else. They are not workspace-oriented (although you can call workspaces from them) but are simply character files containing function bodies and expressions. This means that they would be valid right arguments to `2 ⎕FIX`.

APL Source files employ Unicode encoding, so you need a Unicode font with APL symbols, such as APL385 Unicode, to create or view them. They can be viewed and edited using any character-based editor that supports Unicode text files.

To enter Dyalog APL symbols into an APL Source file, you need the Dyalog Input Method Editor (IME) or other APL compatible keyboard. The Dyalog IME can be configured from the Dyalog Configuration dialog box. You can change the associated **.DIN** file or there are various other options. APL Source files can also be edited using Microsoft Word, although they must be saved as text files without any Word formatting. For more information, see the Dyalog for Microsoft Windows Installation and Configuration Guide.

APL Source files can be identified by the **.apl** file extension. This can either specify .NET classes or represent an APL application in a text source format (as opposed to a workspace format). Such applications do not necessarily require .NET. The **.apl** file extension can, optionally, be further categorised, for example:

- **.apla** files contain array definitions
- **.aplc** files contain class definitions
- **.aplf** files contain function definitions
- **.apli** files contain interface definitions
- **.apln** files contain namespace definitions
- **.aplo** files contain operator definitions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copying Code from the Dyalog Session

You might find it easy to write APL code using the Dyalog Session's function/class editor, or you might already have code in a workspace that you want to copy into an APL Source file. In either case, you can transfer code from the Session into an appropriate text editor using the clipboard.

When pasting APL code from the Session into a text editor, line numbers can be included; although this is allowed, it is not recommended in APL Source files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Creating an APL Source File

Conceptually, the simplest way to create an APL Source file is with a text editor, although you can use many other tools, for example, Microsoft Visual Studio. It is important to ensure that the file is saved with the appropriate file extension (see [Section ](apl-source-files.md)).
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Creating Programs (.exe) with APL Source Files

This section is specific to the Microsoft Windows operating system only.

The following examples, which illustrate how you can create an executable program (**.exe**) directly from an APL Source file, can be found in the **[DYALOG]/Samples/bound_exe** directory. The examples require write access to successfully build the samples, therefore Dyalog Ltd recommends copying the **[DYALOG]/Samples/bound_exe** directory to somewhere you have write access.

Example: Simple GUI

The **eg1.apln** APL Source file illustrates the simplest possible GUI application that displays a message box containing the string "Hello World":
```apl
:Namespace N
⎕LX←'N.RUN'
∇RUN;M
'M'⎕WC'MsgBox' 'A GUI exe' 'Hello World'
⎕DQ'M'
:EndNamespace
```

The code must be contained within `:NameSpace` and `:EndNamespace` statements, and must define a `⎕LX` either within the APL Source file itself or as a parameter to the `dyalogc` command. In this example, `⎕LX` is defined within the APL Source file.

This is compiled to a Windows executable (**.exe**) using **make.bat** and run from the same command window.

![s_aplsource_eg1](../../img/s-aplsource-eg1.png)

Compiling and running APL Source file **eg1.apln**

![s_aplsource_eg1_output](../../img/s-aplsource-eg1-output.png)

"Hello World" Message Box (**eg1.exe**)

The resulting executable can be associated with a desktop icon, and will run without a command prompt window. Any default APL output that would normally be displayed in the session window will be ignored.

Example: Simple Console

The **eg2.apln** APL Source file illustrates the simplest possible application that displays the text "Hello World".:
```apl
:Namespace N
⎕LX←'N.RUN'
∇RUN
'Hello World'
:EndNamespace
```

The code must be contained within `:NameSpace` and `:EndNamespace` statements, and must define a `⎕LX` either in the APL Source file itself or as a parameter to the `dyalogc` command. In this example, `⎕LX` is defined within the APL Source file.

This is compiled to a Windows executable (**.exe**) using **make.bat** and run from the same command window. The `/console` flag in **make.bat** instructs the Dyalog .NET Compiler to create a console application that runs from a command prompt. In this case, default APL output that would normally be displayed in the Session window is instead displayed in the command window from which the program was run.

![s_aplsource_eg2_output](../../img/s-aplsource-eg2-output.png)

Compiling and running APL Source file **eg2.apln**
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Defining Namespaces

At least one namespace must be specified in an APL Source file. Namespaces are specified in an APL Source file using the `:Namespace` and `:EndNamespace` statements. Although you can use `⎕NS` and `⎕CS` within functions inside an APL Source file, you should not use these system functions outside function bodies; such use is not prevented, but the results will be unpredictable.

`:Namespace Name` introduces a new namespace relative to the current namespace called `Name`.

`:EndNamespace` terminates the definition of the current namespace. Subsequent statements and function bodies are processed in the context of the original space.

All functions specified between the `:Namespace` and `:EndNamespace` statements are fixed within that namespace. Similarly, all assignments define variables inside that namespace.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# General Principles of APL Source Files

The layout of an APL Source file differs according to what it defines. However, within the APL Source file, the code layout rules are basically the same.

An APL Source file contains a sequence of function bodies and executable statements that assign values to variables. In addition, the file typically contains statements that are directives to the Dyalog .NET Compiler. These all start with a colon symbol (`:`) in the manner of control structures. For example, the `:Namespace` statement tells the Dyalog .NET Compiler to create, and change into, a new namespace. The `:EndNamespace` statement terminates the definition of the contents of a namespace and changes back from whence it came.

Assignment statements are used to configure system variables, such as `⎕ML`, `⎕IO`, `⎕USING` and arbitrary APL variables. For example:
```apl
⎕ML←2
⎕IO←0
⎕USING∪←⊂'System.Data'
```
```apl
A←88
B←'Hello World'
```
```apl
⎕CY'MYWS'
```

These statements are extracted from the APL Source file and executed by the Dyalog .NET Compiler in the order in which they appear.

The statements are executed at compile time, and not at run-time, and can, therefore, only be used for initialisation.

It is acceptable to execute `⎕CY` to bring functions and variables that are to be incorporated into the code in from a workspace. This is especially useful to import a set of utilities. It is also possible to export these functions as methods of .NET classes if the functions contain the appropriate colon statements.

The Dyalog .NET Compiler will execute any valid APL expression that you include. However, the results might not be useful and could terminate the compiler. For example, it is not sensible to execute statements such as `⎕LOAD` or `⎕OFF`.

Function bodies are defined between opening and closing del (`∇`) characters. These are fixed by the Dyalog .NET Compiler using `⎕FX`. Line numbers and white space formatting are ignored.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# The Dyalog .NET Compiler

APL Source files are compiled into executable code by the Dyalog .NET Compiler, which is called **dyalogc.exe**.

By default, **dyalogc.exe** compiles to .NET. If the `-framework` option is set, it will instead compile to .NET Framework.
For backwards compatibility, the Dyalog .NET Compiler is also distributed on Microsoft Windows with the names identified in the table below.

| |Unicode Edition |Classic Edition|
|------|---------------------|---------------|
|32-Bit|dyalogc_unicode.exe |dyalogc.exe |
|64-Bit|dyalogc64_unicode.exe|dyalogc64.exe |

The Dyalog .NET Compiler can be used to:

- compile APL Source files into a workspace (**.dws**) – this can subsequently be run using **dyalog.exe** or **dyalogrt.exe**.
- compile APL Source files into a .NET class (**.dll**) – this can subsequently be used by any other .NET-compatible host language, such as C#.

The script is designed to be run from a command prompt. Navigate to the appropriate directory and type `dyalogc /?` to query its usage; the following output is displayed (the output displayed here is for Microsoft Windows; the command line options are not all applicable on other platforms):
```
c:/Program Files/Dyalog/Dyalog APL-64 19.0 Unicode>dyalogc /?
Dyalog .NET Compiler 64 bit. Unicode Mode. Version 19.0.48745.0
Copyright Dyalog Ltd 2000-2024

dyalogc.exe command line options:

-? Usage
-r:<file> Add reference to assembly
-o[ut]:<file> Output file name
-res:<file> Add resource to output file
-icon:<file> File containing main program icon
-q Operate quietly
-v Verbose
-v2 More verbose
-s Treat warnings as errors
-nonet Creates a binary that does not use Microsoft .NET
-net Creates a binary that targets .NET Version >=5
-framework Creates a binary that targets .NET Framework
-runtime Build a non-debuggable binary
-t:library Build .NET library (.dll)
-t:workspace Build dyalog workspace (.dws)
-t:nativeexe (Windows only) Build native executable (.exe). Default
-t:standalonenativeexe (Windows only) Build native executable (.exe). Default
-lx:<text> (Windows only) Specify entry point (Latent Expression)
-cmdline:<text> Specify a command line to pass to the interpreter
-nomessages (.NET Framework only) Process does not use windows messages. Use when creating a process to run under IIS
-console|c Creates a console application
-multihost Support multi-hosted interpreters
-unicode Creates an application that runs in a Unicode interpreter
-wx:[0|1|3] Sets ⎕WX for default code
-a:file (.NET Framework only) Specifies a JSON file containing attributes to be attached to the binary
-i:Process (.NET Framework only) Set the isolation mode of a .NET Assembly
-i:Assembly (.NET Framework only) Set the isolation mode of a .NET Assembly
-i:AppDomain (.NET Framework only) Set the isolation mode of a .NET Assembly
-i:Local (.NET Framework only) Set the isolation mode of a .NET Assembly
```

The `-a` option specifies the name of a JSON file that contains assembly information. For example:
```
dyalogc.exe -t:library j:/ws/attributetest.dws -a:c:/tmp/atts.json
```

where `c:/tmp/atts.json` contains:
```
{
"AssemblyVersion":"1.2.2.2",
"AssemblyFileVersion":"2.1.1.4",
"AssemblyProduct":"My Application",
"AssemblyCompany":"My Company",
"AssemblyCopyright":"Copyright 2020",
"AssemblyDescription":"Provides a text description for an assembly.",
"AssemblyTitle":"My Assembly Title",
"AssemblyTrademark":"Your Legal Trademarks",
}
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions dotnet-interface-guide/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# About This Document

## Audience

## Conventions

Unless explicitly stated otherwise, all examples in Dyalog documentation assume that `⎕IO` and `⎕ML` are both 1.
12 changes: 12 additions & 0 deletions dotnet-interface-guide/docs/installation/enabling-net-interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Enabling the .NET Interface

The .NET interface is enabled when the DYALOG_NETCORE configuration parameter is set to 1; this is the default setting on Linux (including the Raspberry Pi) and macOS. On Microsoft Windows the default setting is 0 for backwards compatibility (a setting of 0 enables the .NET Framework interface).

The .NET interface and .NET Framework interface cannot be enabled simultaneously.

For information on how to set configuration parameters, see the appropriate Dyalog for <operating system> Installation and Configuration Guide. To check the value of DYALOG_NETCORE, enter the following when in a Session:
```apl
+2 ⎕NQ'.' 'GetEnvironment' 'DYALOG_NETCORE'
```

If the result is `1` (or empty on Linux/macOS), then the .NET interface is enabled.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files Installed with Dyalog

The components used to support the .NET interface are summarised below. Different versions of each component are supplied according to the target platform.

- **Dyalog.Net.Bridge.dll** – the interface library through which all calls between Dyalog and .NET are processed.
- **Dyalog.Net.Bridge.Host.<operating system>.dll** – auxiliary file
- **nethost.dll** – auxiliary file
- **Dyalog.Net.Bridge.deps.json** – auxiliary file
- **Dyalog.Net.Bridge.runtimeconfig.json** – auxiliary file
1 change: 1 addition & 0 deletions dotnet-interface-guide/docs/installation/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Installation
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Installing .NET

.NET can be downloaded from [https://dotnet.microsoft.com/download](https://dotnet.microsoft.com/download) – download the appropriate .NET SDK and install it according to Microsoft's instructions.

The default installation directory depends on the platform and installation method. Dyalog Ltd recommends that .NET is installed in the following platform-dependent directories:

- /usr/local/share/dotnet on macOS
- /usr/share/dotnet on Linux and Raspberry Pi
- C:\Program Files\dotnet on 64-bit Microsoft Windows
- C:\Program Files (x86)\dotnet on 32-bit Microsoft Windows

If you decide not to install .NET in the default directory, then you need to set the DOTNET_ROOT environment variable to point to your installation location before you start Dyalog. This is a Microsoft variable, not a Dyalog-specific one, so cannot be set in Dyalog's configuration files. See Microsoft's documentation for instructions on how to do this ([https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables)).

On Raspberry Pi Bookworm, do not use the Microsoft-supplied `dotnet-install.sh` script as the resulting .NET installation cannot be used.

Example

This example shows the steps taken on Linux to download the runtime to **/tmp/dotnet-runtime-8.0.0-linux-x64.tar.gz** – following these instructions it should not be necessary to define DOTNET_ROOT.
```
sudo mkdir -p /usr/share/dotnet
cd /usr/share/dotnet
sudo tar -zxvf /tmp/dotnet-runtime-8.0.0-linux-x64.tar.gz
sudo /usr/share/dotnet/dotnet /usr/bin/dotnet
```

This is only an example of code that worked on a specific configuration in our tests; the latest instructions in Microsoft's .NET documentation should always be followed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Upgrading .NET Support

Dyalog v20.0 supports .NET v8.0 and later, but is configured to support .NET v8.0 by default. To support a later version of .NET, the following files need to be amended (this requires administrator rights) – in each case, the reference to "8.0" or "8.0.0" should be updated to the correct major version number:

- **[DYALOG]/Dyalog.Net.Bridge.deps.json**

`"runtimeTarget": { "name": ".NETCoreApp,Version=v8.0",`

`"targets": { ".NETCoreApp,Version=v8.0": {`

- `"runtimeTarget": { "name": ".NETCoreApp,Version=v8.0",`

- `"targets": { ".NETCoreApp,Version=v8.0": {`

- **[DYALOG]/Dyalog.Net.Bridge.runtimeconfig.json**

`"runtimeOptions": { "tfm": "net8.0", "framework": { "name": "Microsoft.NETCore.App", "version": "8.0.0"`

- `"runtimeOptions": { "tfm": "net8.0", "framework": { "name": "Microsoft.NETCore.App", "version": "8.0.0"`

The replacement version number can also be that of a .NET Release Candidate. For example, if you have downloaded .NET 10.0.0-rc.2, the version number in the aforementioned locations should be set to:

- 10.0 instead of 8.0 (three occurrences)

- 10.0.0-rc.2.25502.107 instead of 8.0.0 (one occurrence).
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Pre-requisites

See Microsoft's .NET webpages ([https://dotnet.microsoft.com/](https://dotnet.microsoft.com/)) for information on whether the version of macOS/Linux/Microsoft Windows that you are running supports .NET.

.NET is not available for IBM AIX and is not supported on the Raspberry Pi models Zero, 1 or 2.

The Dyalog version .NET interface requires .NET version 8.0 or later – it does not work with earlier versions of .NET.

The .NET interface only works with the Unicode edition of Dyalog; the Classic edition is not supported.

Once .NET has been successfully installed (see [Section 1.0.1](installing-dotnet.md)) no further installation is required to use the Dyalog .NET interface.

Exporting APL code to .NET assemblies is only supported on 64-bit versions of Dyalog.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Verifying the Installation

Dyalog Ltd recommends that the following command is run at the start of any application that will use .NET:
```apl
r←2250⌶⍬
```

This command identifies the state of the .NET interface while attempting to suppress all associated error messages (for more information on `2250⌶`, see the Dyalog APL Language Reference Guide):

- If `r≡1 1 ''` then the .NET interface should work
- If `r≡2 1 ''` then the .NET Framework interface should work (for more information see the Dyalog for Microsoft Windows .NET Framework Interface Guide)

For any other value of `r`, the interface will not work. An indication of why the interface is not working might be given in error messages in the status/Session window or `r[3]`.

If the interface is not working correctly, then:

- ensure that .NET has been installed according to Microsoft's .NET documentation ([https://docs.microsoft.com/en-gb/dotnet/](https://docs.microsoft.com/en-gb/dotnet/)).
- check that DOTNET_ROOT is correctly set
- check that DYALOG_NETCORE is correctly set (that is, not set to 0)

If everything has been installed and enabled correctly, then the version of .NET in use will be returned by the following statement:
```apl
⎕USING←'System' ⋄ Environment.Version
```
19 changes: 19 additions & 0 deletions dotnet-interface-guide/docs/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.startup.output.clearCache()
MathJax.typesetClear()
MathJax.texReset()
MathJax.typesetPromise()
})
Loading