J does have the PUBLIC_j_ variable which allows keywords to be associated
with paths:
$PUBLIC_j_
118 2
_2{.PUBLIC_j_
+---------+-------------------------------+
|semaphore|~User\code\semaphore.ijs |
+---------+-------------------------------+
|photos |~User\code\savePhotoDirInfo.ijs|
+---------+-------------------------------+
load 'photos'
info,<6!:2 'info=: getFrom1Drive ''E:\''' NB. or
info,<6!:2 'info=: getFrom1Drive ''C:\amisc\'''
6!:2 'regflipphotos ''"''-.~>0{info' NB. Single-thread or
2 parcelOutFlipping dd=. endSlash '"'-.~>0{info NB. 2 parallel flippers
fsize dd,'time.out'
ratioKept >0{info
The "~User" part is evaluated according to another global:
$USERFOLDERS_j_
12 3
2{.USERFOLDERS_j_
+--------+---------------------------+-+
|Projects|c:\amisc\JSys\user\projects|0|
+--------+---------------------------+-+
|User |c:\amisc\JSys\user |0|
+--------+---------------------------+-+
So this lets you easily change the root of the path.
On Sun, Apr 18, 2010 at 1:51 PM, Sprague, Webb (OFM) <
[email protected]> wrote:
> Well, I am disappointed by the lack of a PATH variable approach in J. (And
> if Raul says it, I believe it ;) )
>
> The bigger problem is that I want to share scripts and not have them depend
> on being in a certain location in the filesystem. So I want to push the
> location of the dependencies to a single place and do all my magic there.
>
> It might be there are all sorts of good ways to solve this, but a PATH
> variable approach seems very common outside of J, so I went to it first
> mentally.
>
> Tx!
>
>
> -----Original Message-----
> From: [email protected] on behalf of Raul Miller
> Sent: Sun 4/18/2010 7:08 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Setting the path in J?
>
> On Sat, Apr 17, 2010 at 8:20 PM, Sprague, Webb (OFM)
> <[email protected]> wrote:
> > Thanks for the answer, but it isn't quite what I am after -- I am hoping
> to set the *search path* for files which are loaded or required by a script.
> >
> > In a shell script, I would do this:
> >
> > PATH="/my/special/path:$PATH"
>
> I am pretty sure that J does not have a PATH in the
> sense you are asking for.
>
> If you look at the source code for open:
>
> open
> open_j_
> open_j_
> 3 :0
> f=. ,getscripts y
> ...
>
> And if you start walking through what happens at each step
> getscripts_j_ 'strings'
> ...
>
> getscripts_j_
> ...
>
> jpath each <'strings'
> fullname_j_ jpath 'strings'
> ...
> jcwdpath 'strings'
>
> jcwdpath looks like the workhorse function here, and it's
> concept of a "path" looks like a "pathname" which is to
> say the path followed through the file system to find
> the file. But it's just one location (and 1!:43 gives the
> current working directory, and jhostpath looks like it
> might have a system specific definition to deal with
> ambiguities in the characters used to separate directories
> -- but I think this is not needed in windows, since windows
> is supposed to treat '/' and '\' the same way at the file
> system interface level -- its only the command line level
> that distinguishes between them).
>
> Anyways... perhaps it is time to take a step back and ask:
> why do you need this?
>
> If we focus on the problem you are trying to solve, perhaps
> some better alternatives will suggest themselves.
>
> Thanks,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm