The attached pdf document and .zip project illustrate the creation of .Net string[,] and object[,] arrays using VisualAPL. The project also illustrates that .Net does not provide a direct cast of object[,] to string[,] even when every element of the object[,] array is a string.

These examples do clear up a lot of questions I had, but they do not allow me to do what I need.

In this example, S1 is really an array of characters, rather than an array of strings. Variables O4 and S4 are similar to what I need, which is equivalent to a .Net string[,] type.

I need to be able to do one of the following:

(1) Create a .Net string[,] type where each element is a string, rather than a character. I need to be able to put strings, not individual characters, into each element of this array. Specifically, I need to be able to do something of the form:

I'm still a little confused on what uses []io indexing, and what uses 0 indexing. I was under the impression that .Net variables used 0 indexing, but APL/Cielo variables used []io indexing, however ...

If I set []io to be one in the examples here, I find that S1, which I would consider a .Net variable is sensitive to []io indexing.

This is a relatively minor point, and more of an inconvenience than anything else. It's easily solved by getting used to programming with a []io of 0, which I'm not used to. I'm just a little curious.

This statement is true when the operation is attempted in a single (C#) statement. Each element of the multidimensional object array needs to be coerced into the required data type individually i.e element by element.

Loop through n= 0 to obj1.Rank-1 (gives the number of dimensions) and query obj1.GetUpperBound(n) to get each dimension of the object, create the string array of the same dimension and loop through each plane, convert each element & store in the string array. I agree it is tortuous but if you already know the rank of your arrays, you might be able to code a generic class.

(I'm not sure which version of the framework you are using!)
-------------------------------------
[b]"I need to be able to put strings, not individual characters, into each element of this array. Specifically, I need to be able to do something of the form:

Chris,
I don't think I have the complete picture of what you are trying to do. In general:

- use double quotes to enclose your literals if you want C# to treat them as string, use single quotes when you want C# to treat your literals as char or char[], use the prefix @ (verbatim string) with double quotes if necessary i.e when your string has C# escape characters.
- when passing strings from Visual APL to C#, the strings must be nested i.e enclose (each of the) string element(s); C# will see the arguments as object or object[,] etc. You can cast each element of object to string (can't do it for the whole object[,] etc) in C#. Visual APL does not understand char, if I recall.
- avoid casting or strong typing in Visual APL anything that you want to pass to C#; use strong typing only when you want to call C# functionality from within Visual APL or Cielo. Strong typing is not necessary in Visual APL.
- string or string[,] coming to Visual APL from C# comes across as nested; use disclose where necessary.

I had related issues when I wrote a C# DLL for use with APL+Win and overcame them using the guidelines above and was able to get all the 101 Microsoft samples to work with APL.

It might be easier to resolve issues with your project to hand. If you can, perhaps you can send me your project in a private message together with a note on the issues you are encountering?

OK, I've read your reply again more carefully, and I think the key to my problem is your statement here - "- avoid casting or strong typing in Visual APL anything that you want to pass to C#"

If I don't strongly type an APL variable I want to pass to C#, how do I declare it in the receiving C# program? As object[,] in C#? Or could I reference it as string[,] in C#? If you can tell me that, I suspect my problems might be solved.

I think one of the changes in the latest release of Visual APL is to include handling for data type decimal - if you can demonstrate where the latest release breaks compatibility with another version, I am sure Joe will be willing to investigate.

I will shortly be looking at your requirement. In reply to your specific questions:

For literal arguments between C# and Visual APL:
- Do not use strong typing in Visual APL.
- Enclose each literal or element if using arrays.
- In C#, use object or object[,]. Cast each element to string, if/where necessary.
- In Visual APL, use disclose, if/where necessary.

The attached project contains working code; you should be able to get a few answers (including that to your specific question, above) from here.

- There is a lot of subtleties involved here i.e. in going from an implicitly typed environment (Visual APL) to a strongly typed environment (C#) and back. Unfortunately, I do not have time to write the prose to explain all of it but most of it should be self explanatory.

The project contains a C# console application that uses a Visual APL .NET class. Step through the console application using F11 and examine the variable created on each line (using right-click & QuickWatch in Visual Studio).

The project illustrates

- how to pass values/variables to/from each environment to the other.

- how to use casting and (function) signatures to move from C# to Visual APL and vice versa.

I discovered that the APL+Win COM interface does a lot of (wonderful) stuff in the background when talking to C#. With Visual APL (all managed code environment and no COM interface), you have to do a lot of the stuff yourself.

- The project is for exploration only & not meant to be any kind of prototype or template for a real application. However, some of the techniques will be useful when constructing a (managed code) Visual APL .NET DLL for consumption by C# or another native .NET language.

- For a real application, I would expect that you will be using Visual APL to deliver the business tier from a C# front end. Here, I assume that a simple call to a startup/initial function in the Visual APL class will be all that you will need to start the processes delivered within the Visual APL class. That is, there won't be a lot of C# to Visual APL (and vice versa) switches albeit this is easily possible (as the project demonstrates).

Please confirm that you are able to open the project (I have used the latest version of Visual APL & Visual Studio 2008 Team Edition) and, in due course, that it all makes sense.

By all means, ask if any aspect of the code is unclear/mysterious.

PS. In a real application, there would be times when you would need to convert variables from one type to another in C# (e.g. from long to int or object to string etc): as Joe has pointed out, there are limits to what can be done but as ALWAYS there are workarounds - I have not covered this in the project.

Sorry for my delay in replying. I've been down with the flu the last couple of days.

I've taken a look at this, and it is very helpful. It didn't do exactly what I wanted, which was take in an array, modify it, and return a modified array. But with what you sent it was trivial for me to figure this out. Code is below.

I did mention that you need to treat the project as a series of tips not a prototype for an application!

Let me summarise as follows:

1. C# and Visual APL communicate with objects.
2. C# objects track the type of value it holds (string, int etc)
3. By default, Visual APL objects track the type of value it holds (numeric, literal) as cvar: C# does not understand cvar.
4. To interchange data, when creating objects with Visual APL, use either casting, or function signatures to track values such that C# can understand them as string, int etc.

Chris, I hope you feel better!

Question for Joe: Is there a reference that can be added to a C# project whereby C# can understand cvar? That is, allow C# to map cvar type to a C# type?