Accessing .Net DataSet data from VisualAPL

General discussions related to APLNext's VisualAPL.

Moderators: Tech Support, phpbb_admin

Accessing .Net DataSet data from VisualAPL

Postby Chris McIntosh » January 14th, 2011, 4:45 pm

I'm having trouble accessing data in a .Net DataSet from VisualAPL. I can't seem to find any documentation on this in the Help file. Was this covered in the video tutorials? Are they still available?

I keep getting Index Out of Range errors when I try things like:

Object Var1;
Object Var2 = new Object()
String VarString = ""
String VarString2 = String.Empty

Var1 (assign) myds.Tables[0].Rows[0].ItemArray[0]
Var1 = myds.Tables[0].Rows[0].ItemArray[0]

Var2 (same lines)

VarString = myds.Tables[0].Rows[0].ItemArray[0].ToString()
VarString (assign) myds.Tables[0].Rows[0].ItemArray[0].ToString()

As a workaround, I'm converting the dataset to a 2D object, which I can reference from VisualAPL, but this situation isn't ideal.

Any help on this would be appreciated.

Thanks. Chris.

P.S. Is anyone using VisualAPL? I'm starting to. I'm looking forward to it. I've had some early successes, but also, as this points out, some challenges. I'm wondering what sort of community there is using VisualAPL.
Chris McIntosh
 

Chris' Questions

Postby joe_blaze » January 15th, 2011, 2:05 am

There is no specific documentation on using DataSets in the VisualAPL pdf-format help file. .Net is vast and it is not possible to illustrate every feature in the VisualAPL help file. Check this new topic on the APL2000 VisualAPL forum for an example of using a .Net DataSet in VisualAPL: http://forum.apl2000.com/viewtopic.php?p=2616#2616. Try this project out in your environment to see if you can successfully duplicate the example.

The .Net DataSet was not covered in the VisualAPL video tutorials, however the video tutorials are still available at: http://forum.apl2000.com/viewforum.php?f=12.

Also try a web search for C# DataSet. Often C# programmers will post viable tutorials and examples which can be directly used in VisualAPL because it accepts both traditional APL and C# program statements.

With the information provided in your forum post, the 'Index out of range' error you experienced cannot be duplicated. If you have a VisualAPL project which illustrates your concern, please consider responding to this forum thread with a note and a zip-format attachment of the project files.
joe_blaze
 
Posts: 381
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Postby Chris McIntosh » January 17th, 2011, 7:31 pm

Hi, Joe,

Thanks very much for your quick response.

A very minor detail, but I think there are errors in lines 16 and 17 of your example. I believe these statements should be declarations, not assignments, but they are trivial to fix.

My problem was that your documentation states that .Net variables use 0 indexing, while VisualAPL variables use []io indexing.

With []io set to 1, and with a test dataset of MyTestDS, things like MyTestDS.Tables[0].Rows[0] work fine, but when you get to MyTestDS.Tables[0].Rows[0].ItemArray[x], for some reason VisualAPL thinks ItemArray is an APL variable, not a .NET variable, so an index of 0 gave an error.

I've got past this problem, but am having a problem converting APL data into any type of array, string[,], or object[,] to return to a non-APL language. If I strongly type variables, I get cast problems.

Just so you know, I just updated to the latest release of VisualAPL (v1.5.8117). This may have made problems worse. Prior to this upgrade, I could do things like:

string[,] MyOutput
MyOutput = (string[,])2 3 <reshape>"Hi" "There"

and it would work. Now, this no longer works.

Here's the code.

public static Object[,] WantToReturn2DObject(DataSet testDS)
{
// Declare and initialize variables.
⎕ioâ†
Attachments
AplTests.zip
(1.18 MiB) Downloaded 250 times
Chris McIntosh
 

Initial Reply

Postby joe_blaze » January 18th, 2011, 3:46 am

(1) Yes Lines [16] & [17] should not have "=' assignment operations in them. Good observation! I will modify the example.

(2) Generally when assignment by value (Traditional APL assignment) is used in VisualAPL the result with be a Cielo dynamic variable type. This is because, outside of VisualAPL, .Net only has assignment by reference (.Net "=" operator) and most VisualAPL programmers do not use strong datatyping. When strong datatyping is used, assignment by value will preserve the strong type whenever possible. See this forum topic for an illustration of this: http://forum.apl2000.com/viewtopic.php?t=704

(3) Traditional APL operations in VisualAPL which have no inherent analogue in .Net will result in Cielo variable types. Analogously, traditional APL operations cannot necesarily be applied to any .Net datatype instance.

(4) Not all casts between .Net datatypes are directly possible using the "(myCast)myVar" syntax. This is true not only for the Cielo datatype. In the latest version of VisualAPL there was a significant tighting up of the internal representation of a Cielo variable data type instance, so your experience trying to convert from a Cielo variable to string[,] is expected.

To see an example of this refer to the Forum topic: http://forum.apl2000.com/viewtopic.php?t=705

(5) It will take me a few days to review your other examples. Thanks for posting them. They look interesting.
Last edited by joe_blaze on January 18th, 2011, 7:15 am, edited 1 time in total.
joe_blaze
 
Posts: 381
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Additional reply to Chris

Postby joe_blaze » January 18th, 2011, 7:13 am

Chris:

T1 â†
joe_blaze
 
Posts: 381
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Postby Chris McIntosh » January 18th, 2011, 11:35 am

Hi, Joe,

Thanks again for your really quick responses.

I expect that as I work in VisualAPL, I'll rarely use strong typing. However, as I work with developers that are (so far!) non-APL programmers, I have to interact with other languages.

I haven't had many problems taking in .Net types and using them in VisualAPL, the only exception being ItemArray indexing.

I have had problems returning strongly typed variables to other languages, so I appreciate your help.

Thanks for letting me know that assignment by value (traditional APL assignment) preserves strong typing where possible. This may help, and I'll look at your example and explore this further.

I can appreciate you may need to tighten up VisualAPL internals from time to time, and I suspect most of them might be "transparent to the user". I would hope not too many changes would affect working code. When you say my experience trying to convert from a Cielo variable to string[,] was expected, it may have been expected by you, but it wasn't by me! :-)

I am really looking forward to using VisualAPL in substantial ways in the very near future. The quick taste I've had of it illustrates how much faster and easier I can accomplish almost all tasks, compared to using C# and VB. Being able to return .Net types from VisualAPL is necessary for this to happen. Again, thanks very much for your quick help.

Chris
Chris McIntosh
 

Follow-up

Postby joe_blaze » January 18th, 2011, 9:51 pm

Hi Chris,

Please keep the questions coming. Others surely have questions, but are not ready to participate in the forum, so seeing your questions and our discussion will help the community.

Joe
joe_blaze
 
Posts: 381
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361


Return to VisualAPL

Who is online

Users browsing this forum: No registered users and 1 guest