Given that, when executed, (4!:4@< bind 'lcd' { 4!:3 bind '') gives
you the location of the script that defined the name lcd, why would
you expect the same result when defining the name from two completely
different sources?-- Raul On Mon, Oct 31, 2011 at 2:18 PM, Andrew Pennebaker <[email protected]> wrote: > This snippet behaves differently in the interpreter vs a J code file: > > $ jconsole > lcd =: 3 : ' (4!:4<''lcd'') { 4!:3 $0 ' > COMMON_SCRIPT_PATH =: ;}:}:;:>lcd'' > > COMMON_SCRIPT > /Applications/j64-701/system/main/ > > $ cat jlib.j > #!/usr/bin/env jconsole > > lcd =: 3 : ' (4!:4<''lcd'') { 4!:3 $0 ' > COMMON_SCRIPT_PATH =: ;}:}:;:>lcd'' > > echo COMMON_SCRIPT_PATH > > exit '' > > $ ./jlib.j > /Users/andrew/Desktop/src/mcandre/j/./ > > This is unfortunate because I was planning to use the snippet as part of a > Makefile that would install my J package when a user enters "make install". > > Cheers, > > Andrew Pennebaker > www.yellosoft.us > > On Mon, Oct 31, 2011 at 10:29 AM, Tracy Harms <[email protected]> wrote: > >> I have found the following code helpful in loading J scripts: >> >> lcd =: 3 : ' (4!:4<''lcd'') { 4!:3 $0 ' >> COMMON_SCRIPT_PATH=: ;}:}:;:>lcd'' >> NB. path of directory from which this script is being run. >> >> This allows me to put associated scripts in any directory, launch the root >> script of that set (via jconsole.exe) and have that script load the other >> scripts by determining its own path. The load sentences are like this: >> >> load COMMON_SCRIPT_PATH, 'somescript.ijs' >> >> Thanks goes to Dan Bron for directing me to this useful code. >> >> --Tracy >> >> >> On Sun, Oct 30, 2011 at 5:03 PM, Andrew Pennebaker < >> [email protected]> wrote: >> >> > If I have a local file coolstuff.j, where do I put coolstuff.j so that I >> > can do load 'coolstuff.j' from anywhere? If possible I'd like to put all >> my >> > J code in ~/.j or a similar directory and have J know to look there when >> > loading code. >> > >> > In other words, where does J search for code? >> > >> > Does J have an environment variable similar to Java's $CLASSPATH? >> > >> > Cheers, >> > >> > Andrew Pennebaker >> > www.yellosoft.us >> > ---------------------------------------------------------------------- >> > 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
