With many thanks to the J programming forum, here is my solution to the
problems of (1) finding my script's path and (2) loading libraries
relative to that path:

NB. Load this file with "load 'Z:\blah\J-experiments\getpathsample.ijs'
NB. Then call the following as "pth =. getpath ''".  
getpath =: 3 : 0
        dirname=: #~  '/\' +./\...@e.~ ]
        sourcepath=: dirname (4!:4<'dirname') {:: 4!:3''
        sourcepath
)

NB. Now you can do the following in a J session
NB.   pth =. getpath ''
NB.   scriptpth =. pth,'..\J-experiments\loadable.ijs'
NB.   load scriptpth
NB.   x =. foobar ''  NB. this function is defined in loadable.ijs

Thanks again for everyone's help (and forgive me if I am offending any
sensibilities...)!
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to