--- Raul Miller <[EMAIL PROTECTED]> wrote: > Playing around with SetB/GetB, it looks like they do not deal > with nested arrays. However for many cases you can treat > a data table as N*3 flat arrays, instead.
Actually, SetB/GetB can understand nested boxed and plain arrays very well. See samples below. The only quirk is treating SAFEARRAY of BSTR. Instead, strings need to be wrapped in Variants (object boxes). But direct string array would be much nicer. See also http://www.jsoftware.com/pipermail/general/2007-February/029111.html ============================================================[Program.cs]== using System; public class MyClass { public static void Main() { try { object[] obj; obj = new object[] { "one", "two", "three" }; SetB("Test", obj); Console.WriteLine("\n {0}\n{1} ", "Test", DoR("Test")); obj = new object[] { new object[3,1] {{1},{2},{new bool[] {true,true,false}}}, "two", new object[] { 123, new byte[2,3] { {(byte)'*',(byte)' ',(byte)'.'}, {(byte)' ',(byte)'*',(byte)'.'}}, new double[3,2]{{5.1,6.2},{7,8},{9,10}} } }; SetB("Test", obj); Console.WriteLine(" {0}\n{1} ", "Test", DoR("Test")); string[] astr = new string[] { // this will cause error "one", "two", "three" }; SetB("Test", astr); Console.WriteLine(" {0}\n{1} ", "Test", DoR("Test")); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } Console.WriteLine("all done."); } // J interface static JDLLServerLib.JDLLServerClass J = new JDLLServerLib.JDLLServerClass(); static void SetB(string name, object value) { assert(J.SetB(name, ref value)); } static object GetB(string name) { object result; assert(J.GetB(name, out result)); return result; } static object DoR(string expr) { object res; assert(J.DoR(expr, out res)); return res; } static void assert(int status) { if (status == 0) return; object result; J.ErrorTextB(status, out result); throw new ApplicationException(result as string); } } ======================================================================== Sample output: Test +---+---+-----+ |one|two|three| +---+---+-----+ Test +-------+---+-----------------+ |+-----+|two|+---+---+-------+| ||1 || ||123|* .|5.1 6.2|| |+-----+| || | *.| 7 8|| ||2 || || | | 9 10|| |+-----+| |+---+---+-------+| ||1 1 0|| | | |+-----+| | | +-------+---+-----------------+ domain error at MyClass.assert(Int32 status) in 09_Nested\Program.cs:line 63 at MyClass.SetB(String name, Object value) ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
