How to use construct:Void.ctor(Char,Char,Char,Char)

Using (or providing) Microsoft.NET Classes

How to use construct:Void.ctor(Char,Char,Char,Char)

Postby PGilbert on Wed Feb 03, 2016 3:58 am

Suppose that you have a dll with a constructor like this:

      Void.ctor(Char,Char,Char,Char)


How do you specify the four (4) Char in APL ? I have tried the obvious and it does not work.

Thanks in advance.
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use construct:Void.ctor(Char,Char,Char,Char)

Postby Vince|Dyalog on Wed Feb 03, 2016 1:36 pm

Hi Pierre,

I think that you need to use a 4 char character vector to call the constructor.

To try this out, I brewed my own class constructor which takes four chars:

c#:
Code: Select all
public class FourCharsCls
{
    public bool isInitialized;
    public char mya='x';
    public char myb='x';
    public char myc='x';
    public char myd='x';
    public FourCharsCls(char a, char b, char c, char d)
    {
        isInitialized = true;
   mya = a;
   myb = b;
    }
   public static void Main()
   {
   }

}


APL:
      ⎕USING←',C:\Program Files (x86)\Dyalog\Dyalog APL 14.1 Unicode\Samples\aplclasses\fourchars.dll'
myf←⎕NEW FourCharsCls 'abcd'

Then, when I ask for:
myf.mya
myf.myb
myf.myc

I get a, b, and x as I expected.


Regards,

Vince
Vince|Dyalog
 
Posts: 412
Joined: Wed Oct 01, 2008 9:39 am

Re: How to use construct:Void.ctor(Char,Char,Char,Char)

Postby PGilbert on Wed Feb 03, 2016 4:13 pm

Thanks Vince, I think I need to give more details so that you know what I am trying to do. I want to use the dll called LumenWorks.Framework.IO.dll (see copy attached) that can be obtained here on the Github. It is about a fast CSV parser that will parse a CSV file to a DataTable without transiting the data into the Apl workspace (useful on large file to prevent WS full while using .Net).

The constructors are as follow:
Code: Select all
Void .ctor(System.IO.TextReader, Boolean)
Void .ctor(System.IO.TextReader, Boolean, Int32)
Void .ctor(System.IO.TextReader, Boolean, Char)
Void .ctor(System.IO.TextReader, Boolean, Char, Int32)
Void .ctor(System.IO.TextReader, Boolean, Char, Char, Char, Char, LumenWorks.Framework.IO.Csv.ValueTrimmingOptions, System.String)
Void .ctor(System.IO.TextReader, Boolean, Char, Char, Char, Char, LumenWorks.Framework.IO.Csv.ValueTrimmingOptions, Int32, System.String)


If I drop a copy of the dll next to the Dyalog.exe file and try to use this function it does not work when creating the 'CsvReader' (I get a DOMAIN ERROR).
Code: Select all
 FastCSV fileName;bufferSize;cols;comment;delimiter;escape;hasHeaders;nullValue;quote;streamReader;trimmingOptions;⎕USING

 ⍝ Based on: http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader
 ⍝ and https://github.com/phatcher/CsvReader

 ⎕USING←'System.IO,mscorlib.dll' 'LumenWorks.Framework.IO.Csv,LumenWorks.Framework.IO.dll' 'System.Data,System.Data.dll' 'System,mscorlib.dll'

 hasHeaders←1
 delimiter←','
 quote←'"'
 escape←'"'
 comment←'#'
 trimmingOptions←1  ⍝ 0=None, 1=Unquoted Only, 2=Quoted Only, 3=All
 bufferSize←4096
 nullValue←0

 streamReader←⎕NEW StreamReader(⊂,fileName)
 csv←⎕NEW CsvReader(streamReader,hasHeaders,delimiter,quote,escape,comment,trimmingOptions,bufferSize,nullValue)
⍝ csv←⎕NEW CsvReader(streamReader,hasHeaders,delimiter)  ⍝ This is working


and to try the code it is just:
      FastCSV 'd:\Book1.csv'


Question: What would be the proper way to build the constructor statement in Apl for a 'CsvReader' ?

Thanks in advance,
Attachments
Book1.zip
(216 Bytes) Downloaded 3038 times
LumenWorks.Framework.IO.zip
(18.89 KiB) Downloaded 3132 times
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use construct:Void.ctor(Char,Char,Char,Char)

Postby Vince|Dyalog on Thu Feb 04, 2016 2:31 pm

Hi Pierre,

I've asked JD about this and he points out that:

We don’t map 0 to null, so it’s invalid as the value for the last parameter (the System.String).

In future versions of Dyalog, we will allow you to use ⎕NULL here, but 14.1 doesn’t.

JD suggests that you use ''.

So, the constructor works if you set nullValue to this:
nullValue←⊂''

Regards,

Vince
Vince|Dyalog
 
Posts: 412
Joined: Wed Oct 01, 2008 9:39 am

Re: How to use construct:Void.ctor(Char,Char,Char,Char)

Postby PGilbert on Thu Feb 04, 2016 3:03 pm

Hello Vince (and JD), many thanks its working !
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest