Need to pass Integer-value in .net

Using (or providing) Microsoft.NET Classes

Need to pass Integer-value in .net

Postby MBaas on Mon Feb 15, 2010 10:53 am

I am trying to use a .net-Tool that requires Integer-Values in some params. When trying to assign an integer, I get a DOMAIN ERROR (in 10.1). That is because the argument is a small number ([]DR is 83). How can I make sure this gets passed as a 323-int?
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: Need to pass Integer-value in .net

Postby MBaas on Mon Feb 15, 2010 5:38 pm

dotnet.Function.IntVal <- System.Convert.ToInt32 var
:)
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: Need to pass Integer-value in .net

Postby Azal on Mon Feb 15, 2010 5:45 pm

System.Convert.ToInt32 var will return APL numeric.

⎕DR Convert.ToInt32 0
83

But ToInt64 will return an instance. But Dyalog casting between APL and CLR for numeric values normally work OK for me. Can you provide with example?
Azal
 
Posts: 11
Joined: Tue Jan 12, 2010 3:22 pm

Re: Need to pass Integer-value in .net

Postby harsman on Tue Feb 16, 2010 8:29 am

We had similar issues with .NET in 10.1 and solved it by using
Code: Select all
(Int64.Parse,'123')
as the argument to a .NET method. I grepped through our code base and we have a couple of instances of Int64.Parse and one Int32.Parse, probably to work around issues like these.

I didn't write the code, but I vaguely remember the person that did talking about how the behaviour varied between different versions of Dyalog. It might not be necessary with newer versions.
harsman
 
Posts: 27
Joined: Thu Nov 26, 2009 12:21 pm

Re: Need to pass Integer-value in .net

Postby MBaas on Tue Feb 16, 2010 11:02 am

My variable happened to be zero and the ToInt32-call fixed this. According to Azal this wouldn't be expected, but hey - after all, I'm happy enough that it did the job ;)

Joakim's code also looks good, thanks - if the homemade solution should fail once I work with numbers > 0, I will try that route ;)

Thanks

Michael
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: Need to pass Integer-value in .net

Postby jGoff on Wed Feb 17, 2010 2:29 pm

What about using dyadic ⎕dr?

0
0
⎕dr 0
83
to16 0
0
⎕dr to16 0
163
to32 0
0
⎕dr to32 0
323
⎕cr 'to16'
to16←{163=a←⎕DR ⍵:⍵
z b←(a 163)⎕DR ⍵
∧/b:z}

⎕cr 'to32'
to32←{323=a←⎕DR ⍵:⍵
z b←(a 323)⎕DR ⍵
∧/b:z}


-J. Goff
jGoff
 
Posts: 26
Joined: Fri Jun 19, 2009 12:25 pm

Re: Need to pass Integer-value in .net

Postby MBaas on Thu Feb 18, 2010 6:20 am

Yes.....looks feasible too ;)

(embarrassing) truth to be told: I've never used dyadic DR. I actually tried to do so when looking at this prob, but didn't fully understand the doc, so the last thing I did was 323 DR 0 causing ERROR, and I then gave up on it, as I felt a certain pressure to get a result... :(
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: Need to pass Integer-value in .net

Postby Azal on Thu Feb 18, 2010 2:35 pm

MBaas wrote:Yes.....looks feasible too ;)

Your .Net class is accept naive []DR conversion? Can you check it please?
Azal
 
Posts: 11
Joined: Tue Jan 12, 2010 3:22 pm

Re: Need to pass Integer-value in .net

Postby MBaas on Fri Feb 19, 2010 6:41 pm

Yes, I just did a quick test with
t.IntegerValue←1⊃(83 323)⎕DR lmng
(after checking the ⎕DR of lmng was 83) and that was accepted...
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany


Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest