OK .. my reply took so long because nobody wanted to lend me a  64-bit windows 
dev machine so I had to create a VM using VirtualBox on my MacBook. Installed 
Windows 7 64-bit and Visual Studio .NET 2005 Professional.

So after installing J602 64-bit and compiling his sample code I did the 
following (all the while listening to Regina Spektor and Ani DiFranco):
1. Tried his base code. Data returned is OK but data in J was mangled as his 
description.
2. Slightly modified the code by running jSession.Eval("IntArray=: 10 + 
IntArray"). The returned value to C# was as follows:
Expected result: 14 18 25 26 33 52
Actual result: 14 8 25 16 33 42
3. Reverted code and added a C# overriding function as follows:
public  void Variable(string name, int[] value)
{
  StringBuilder temp = new StringBuilder("[" + name + " =: ");
  foreach (int data in value)
 {
    temp.AppendFormat(" {0}", data);
  }
  this.Eval(temp.ToString());
}

The code above essentially converts an array of INT to a command string in J 
like so:
[IntArray =: 4 8 15 16 23 42

So what happened was in J, the data was correct but C# would get the data as:
4 0 8 0 15 0

My next step was uninstalled J602 64bit and installed J602-32bit. Fixed the COM 
registry entries (because they still point to the 64-bit version) to point to 
the 32-bit version. I then reverted the code and recompiled and executed 
Martins base code and everything was OK. Data in J and in C# was the same.

In summary - there is something wrong with SetB and GetB functions in 64-bit 
but everything works as expected if using 32-bit.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of David Mitchell
Sent: Wednesday, October 13, 2010 7:30 PM
To: Programming forum
Subject: Re: [Jprogramming] JEXEServerLib - 64 bit problem

No, it failed on the SetB with domain error when using Int64.  Set fails with 
the domain error also.

On 10/12/2010 22:26, bill lam wrote:
> Does it work if passing as int64[] ?
>
> Втр, 12 Окт 2010, David Mitchell писал(а):
>> Some random notes:
>>
>> Function Get(jname As String, v) As Long
>>       Member of JDLLServerLib.JDLLServer
>>       Get variant value from J variable.
>>
>> Function GetB(jname As String, v) As Long
>>       Member of JDLLServerLib.JDLLServer
>>       Get variant value from J variable (BSTR).
>>
>> Function GetM(jname As String, jtype As Long, jrank As Long, jshape 
>> As Long, jdata As Long) As Long
>>       Member of JDLLServerLib.JDLLServer
>>       Get J variable description and memory addresses of shape and data.
>>
>> ===
>>
>> http://www.jsoftware.com/jwiki/Guides/.NET%20Interop
>>
>> ===
>>
>> I think
>>
>>               Console.WriteLine("Orriginal int array value  : " + 
>> (IntArrayToString(intArray)));
>>               Console.WriteLine("J returned int array value : " + 
>> (IntArrayToString((int[])intArray)));
>>
>> should be
>>
>>               Console.WriteLine("Orriginal int array value  : " + 
>> (IntArrayToString(intArray)));
>>               Console.WriteLine("J returned int array value : " + 
>> (IntArrayToString((int[])intArrayObj)));
>>
>> ===
>>
>> Here is what I get with C# 2010 Express and J602-64:
>>
>> IntArray
>> 34359738372 68719476751 180388626455 111164048 113747712 111035888
>>
>>      hfd IntArray
>> 0800000004
>> 100000000F
>> 2A00000017
>> 0006A03A90
>> 0006C7A700
>> 00069E45F0
>>
>> The 32 bit C# int values look like they have been packed into 64 bit 
>> J integers (with garbage fill at the end.)
>>
>> --
>> David Mitchell
>>
>>
>> On 9/29/2010 16:43, Martin Pelletier wrote:
>>> Here, I made a little Visual Studio project to demonstrate the 
>>> issue. If the forwarding list allows attachments, then it's 
>>> TestJApp.rar. If not, I will follow up with a link.
>>>
>>> Those who have a 64-bit machine will be able to run it and see what I mean.
>>> Essentially, follow the Main function in Program.cs. Insert a 
>>> breakpoint on the last line (Console.ReadLine), where you will be 
>>> able to test the resulting value in J, declared as "IntArray".
>>>
>>> Thanks for looking into this!
>>>
>>> Martin Pelletier
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> -- For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>> ---------------------------------------------------------------------
>> - For information about J forums see 
>> http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to