The clue is here: JGetM i x *c *x *x *x *x''e p n t r s d'=. cmd cd pJ,(,y);4#<,0
Read up on this: http://www.jsoftware.com/help/user/call_procedure.htm Try running the jdll.ijs and playing with it (adding smoutput in various places) to understand what it's doing The string i x *c *x *x *x *x tells us i = JGetM takes returns an integer x = the J instances (jt) *c = the string to evaluate *x *x *x *x are 4 integers, which we can see are passed by 4#<,0 So you should be able to do a =j.JGetM(jt,"a", 0, 0, 0, 0) [untested] On Fri, Jul 18, 2014 at 11:05 AM, Jon Hough <[email protected]> wrote: > Thanks, > My test script, so far, is > > from ctypes import * > > cdll.LoadLibrary("j801/bin/libj.so") > j = CDLL("j801/bin/libj.so") > jt = j.JInit() > > j.JDo(jt, "a =: 1") > > a =j.JGetM( "a") > > print a > > This returns 4, even though I set a to be 1. I'm assuming 4 is the number > of bytes returned (i.e. an int)??(By the way, if I do j.JGetM(jt, "a") I > get a seg fault.Regarding jdll.ijs, unfortunately my J-skills are not > powerful enough yet to make much sense of it: > jget=: 3 : 0cmd=. libj,' JGetM i x *c *x *x *x *x''e p n t r s d'=. cmd cd > pJ,(,y);4#<,0if. e do. smoutput 'error code: ',":e return.end.(t,r,s) > jfix d) > In particular > JGetM i x *c *x *x *x *x > is confusing. > > Date: Fri, 18 Jul 2014 10:53:44 -0400 > > From: [email protected] > > To: [email protected] > > Subject: Re: [Jprogramming] Calling j.dll from python > > > > JGetM is what you need, but I strongly suggest reviewing > > http://jsoftware.com/wsvn/addons/trunk/general/misc/jdll.ijs (or your > local > > version) to get a better understanding of how things work > > > > This part addresses your question: > > > > jget=: 3 : 0 > > cmd=. libj,' JGetM i x *c *x *x *x *x' > > 'e p n t r s d'=. cmd cd pJ,(,y);4#<,0 > > if. e do. > > smoutput 'error code: ',":e > > return. > > end. > > (t,r,s) jfix d > > ) > > > > > > On Fri, Jul 18, 2014 at 10:51 AM, Jon Hough <[email protected]> wrote: > > > > > Please ignore the last sentence from my previous email. Copied and > pasted > > > by accident. > > > > > > > From: [email protected] > > > > To: [email protected] > > > > Date: Fri, 18 Jul 2014 15:50:41 +0100 > > > > Subject: Re: [Jprogramming] Calling j.dll from python > > > > > > > > Joe, thanks. Your suggestion seems to work. > > > > However JGets seems to not exist.How do I then get the variable, once > > > assigned? > > > > I tried to search through the .so/.dll for "get" functions: > > > > > > > > nm -g libj.so | grep Get > > > > Although jdll.ijs seems to contain jget, when I tried to call this > (in > > > Python) I get " undefined symbol: jget" (with variations on upper and > > > lower cases) > > > > > > > > > > > > > > > > > > > > and couldn't find a function that seemed to get the variables.Also > I'm > > > having trouble finding libj.dll > > > > > Date: Fri, 18 Jul 2014 10:36:06 -0400 > > > > > From: [email protected] > > > > > To: [email protected] > > > > > Subject: Re: [Jprogramming] Calling j.dll from python > > > > > > > > > > JInit() returns the instance that you need to invoke against > > > > > > > > > > see addons/general/misc/jdll.ijs > > > > > > > > > > jdo is defined as: > > > > > > > > > > jdo=: 3 : 0 > > > > > > > > > > (libj,' JDo i x *c') cd pJ, boxopen y > > > > > > > > > > ) > > > > > > > > > > > > > > > so I suspect you need to be passing that pointer address with > python > > > too... > > > > > > > > > > > > > > > jt = j.JInit() > > > > > > > > > > j.JDo(jt, "x =: 3") > > > > > > > > > > > > > > > [untested] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, Jul 18, 2014 at 10:33 AM, Thomas Costigliola < > > > [email protected]> > > > > > wrote: > > > > > > > > > > > Bill, Jon, sorry if that suggestion did not apply. I remembered > it > > > was a > > > > > > common pitfall when calling from C. Maybe that is not the case > now. > > > > > > > > > > > > > > > > > > On Fri, Jul 18, 2014 at 10:29 AM, Jon Hough <[email protected] > > > > > wrote: > > > > > > > > > > > > > My previous email was regarding Windows (7 with J801) > > > > > > > I just tried to do the same in Ubuntu (J801) > > > > > > > cdll.LoadLibrary("j801/bin/libj.so") > > > > > > > j = CDLL("j801/bin/libj.so")>>> j.JInit()158010848 > > > > > > > No idea what the above output means. Is that the pointer > address of > > > > > > > something? > > > > > > > And then: > > > > > > > >>> j.JDo("x =: 3")Segmentation fault (core dumped) > > > > > > > And Python (2.7) crashed. > > > > > > > > > > > > > > > Date: Fri, 18 Jul 2014 22:09:28 +0800 > > > > > > > > From: [email protected] > > > > > > > > To: [email protected] > > > > > > > > Subject: Re: [Jprogramming] Calling j.dll from python > > > > > > > > > > > > > > > > From which resource did you learn that(not python)? It > should be > > > very > > > > > > out > > > > > > > > dated. > > > > > > > > On Jul 18, 2014 6:00 PM, "Jon Hough" <[email protected]> > > > wrote: > > > > > > > > > > > > > > > > > I am trying to call jdll.JDo from python but I get the > error > > > message, > > > > > > > > > access violation. > > > > > > > > > > > > > > > > > > Here is my python. > > > > > > > > > > > > > > > > > > Cdll.LoadLibrary(path to j.dll) > > > > > > > > > J =CDLL(path to j.dll) > > > > > > > > > > > > > > > > > > J.JDo("x =: i. 3") > > > > > > > > > > > > > > > > > > This gives am error. In fact any string gives the error. > > > > > > > > > > > > > > > > > > J.JGet doesnt seem to give errors, but since I cannot set > any j > > > > > > > variables, > > > > > > > > > it is not easy to test. > > > > > > > > > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > > > > > > > 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 > > > > > > > > > > > > ---------------------------------------------------------------------- > > > > > 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 > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
