Thanks everybody.

For the present I'm using a variant of Don's method to enable my script to
load "sister" scripts residing in the same folder.
I put this near the top of the script, just under coclass 'uu' …

   CREATOR=: ;(4!:4<'zx'){4!:3''[zx=.''

then in my start verb I can load (say) manifest.ijs to fetch VERSION, like
so…

   load CREATOR rplc 'uu.ijs' ; 'manifest.ijs'

plus any other ancillary scripts it needs to load.

It all seems to work just fine. Now I must wait to rediscover why I
abandoned this technique wayback.

Ian Clark


On Wed, 10 Apr 2019 at 05:04, Devon McCormick <devon...@gmail.com> wrote:

> Yeah - "programmatically" was a stretch - my spell-check rejected it.
> Years ago, a C programmer told me the best thing they'd ever done with a C
> system was to put a general function (a macro?) at the start of each
> function definition: you could make whatever was defined do nothing or
> anything else you could think of.
>
> On Tue, Apr 9, 2019 at 10:45 PM Ian Clark <earthspo...@gmail.com> wrote:
>
> > @Devon - yours is a solution that's growing on me. Omitting the word
> > "programmatically". As a developer I rely so much on symbolic folder
> names
> > that I'm flying by instruments most of the time, and I don't like it.
> Sure
> > it works 99.9% of the time, but that remaining one-in-a-thousand wastes
> me
> > hours, typically when I've got a deadline to meet. Or else it chagrins
> > users.
> >
> > So I want something that works 100%, if it works at all. Here's something
> > so simple-stupid it has the ring of dependability about it:
> >
> > Suppose I insert at the head of each script that needs it:
> >    CREATORSCRIPT=: 'UNSET'
> > then have a simple daemon that periodically scans my entire user folder
> > looking for scripts containing that word, and replacing it with the full
> > pathname of the said script, if that's not the case already. No "jpath".
> > Plus it will report infringements, which will make interesting reading.
> >
> > @Don - yes, that's neater than my (former) solution (below). Which I
> didn't
> > code tightly because I was correctly anticipating debugging it a year or
> > two hence…
> >
> > whereami=: 3 : 0 ''
> > NB. returns directory containing this script
> > NB. also assigns global: WHEREAMI -the folder in question
> > NB. plus SEP -the platform-dependent path-separator.
> > ws=. [: 'Not from script'"_`({ 4!:3@(0&$))@.(0&<:) [: 4!:4 [: < >
> > WHEREAMI=: '<UNSET>' NB. needed for ws to work with
> > z=. >ws 'WHEREAMI'
> > SEP=: '/\' {~ '\' e. z
> > WHEREAMI=: (>: z i: SEP) {.z
> > )
> >
> > This problem is like The Alien… it keeps mutating and coming back to bite
> > you.
> >
> > On Wed, 10 Apr 2019 at 02:50, Don Guinn <dongu...@gmail.com> wrote:
> >
> > > I put this in the starts of my scripts where I need to load other
> scripts
> > > from the same directory. Easily modified to keep the full file name.
> > >
> > > NB. Find directory for this app.
> > >
> > > maindir=:''
> > >
> > > maindir=:z{.~>:1 i:~'/\' e.~z=.;(4!:4 <'maindir'){4!:3 ''
> > >
> > > On Tue, Apr 9, 2019 at 7:39 PM Devon McCormick <devon...@gmail.com>
> > wrote:
> > >
> > > > Could you programmatically insert a line into the start of each
> script
> > so
> > > > it would tell you who it is?
> > > >
> > > > On Tue, Apr 9, 2019 at 9:07 PM Ian Clark <earthspo...@gmail.com>
> > wrote:
> > > >
> > > > > Bill wrote
> > > > > > J interpreter only knows the last script that it started to load.
> > > > >
> > > > > That's the key to the whole thing.
> > > > >
> > > > > I'm convinced nothing can go wrong (with 4!:3/4!:4) when there are
> no
> > > > > scripts involved which load other scripts. But they do. All too
> > often.
> > > > >
> > > > > On top of that, if you use the scheme a lot, as I did, then another
> > > > script
> > > > > can be loaded later and overwrite the pronoun: MYSCRIPT. Maybe I
> need
> > > to
> > > > be
> > > > > more paranoid and not go using the name 'MYSCRIPT' for every script
> > > that
> > > > > wants to badge the locale it creates, but instead…
> > > > >
> > > > > ++ randomise the name - and be able to recognise the one you want
> > when
> > > > > there's more than one (which in itself would be highly diagnostic),
> > > > > ++ create the global if absent, and subsequently catenate entries
> to
> > > it,
> > > > > ++ look at the 4!:4 of every name in 4!:1[0 and take a majority
> vote
> > > > (…but
> > > > > that's no good for a stock phrase to be executed at load-time at
> the
> > > top
> > > > of
> > > > > the script.)
> > > > >
> > > > > On Wed, 10 Apr 2019 at 01:42, bill lam <bbill....@gmail.com>
> wrote:
> > > > >
> > > > > > I think J interpreter only knows the last script that it started
> to
> > > > load.
> > > > > > It doesn't know from which scripts that the current sentence
> being
> > > > > executed
> > > > > > came because all are inside RAM. The identity of script file name
> > are
> > > > > lost.
> > > > > >
> > > > > > On Wed, Apr 10, 2019, 8:27 AM Ian Clark <earthspo...@gmail.com>
> > > wrote:
> > > > > >
> > > > > > > @Don - that's the scheme I've been using. Basically: create a
> > > global
> > > > > noun
> > > > > > > and look at its 4!:4. For a couple of years I used it in all
> the
> > > code
> > > > > > that
> > > > > > > needed it. Then it let me down a year ago, and unfortunately I
> > > never
> > > > > > > tracked down why. But the upshot was so grave that I tore the
> > > > facility
> > > > > > out
> > > > > > > of all my code and looked for alternative ways of registering
> the
> > > > path
> > > > > > > about to be loaded, where this was under my control.
> > > > > > >
> > > > > > > It all became very hit-and-miss, and recently I've come to the
> > > > > conclusion
> > > > > > > that if anyone reading this list had a tested and guaranteed
> > > solution
> > > > > to
> > > > > > > this problem, or there was a magic Foreign I didn't know
> about, I
> > > > > needed
> > > > > > to
> > > > > > > know it.
> > > > > > >
> > > > > > > People like me who use whichscript a lot (it uses 4!:4 and
> > resides
> > > in
> > > > > > > ~addons/misc/miscutils/utils.ijs) know that all too often it
> can
> > > > return
> > > > > > > 'Not from script'. Generally when you really want to know:
> where
> > > did
> > > > > > *that*
> > > > > > > blessed (noun/verb) come from??! Well, the question I want to
> > > answer
> > > > in
> > > > > > > this thread is: what script does such-and-such a locale imagine
> > has
> > > > > > created
> > > > > > > it? (Or last pooped-on it.)
> > > > > > >
> > > > > > > Why do I want to know?
> > > > > > > (1) for forensic reasons (i.e. bug-hunting in conditions of
> > > > > > > code-regression). I keep a lot of versions of suites of scripts
> > I'm
> > > > > > > developing, and I can't be sure I've always purged *all* the
> old
> > > > > > versions.
> > > > > > > Particularly from unfinished jobs gathering dust.
> > > > > > > (2) to enable a script to execute: "load the version of script
> > XYZ
> > > > > which
> > > > > > is
> > > > > > > meant to reside in the folder I find myself in". (Surely
> > > > addon-writers
> > > > > > and
> > > > > > > heavy GutHub cloners have this requirement?
> > > > > > >
> > > > > > > I shall carry on looking for more and more reliable techniques…
> > but
> > > > > > surely
> > > > > > > the J interpreter, in its heart-of-hearts, knows the path to
> the
> > > file
> > > > > it
> > > > > > is
> > > > > > > currently loading, so why is this such a big deal?
> > > > > > >
> > > > > > > Ian
> > > > > > >
> > > > > > > On Wed, 10 Apr 2019 at 00:38, Ian Clark <earthspo...@gmail.com
> >
> > > > wrote:
> > > > > > >
> > > > > > > > @Eric - tried that too.
> > > > > > > >
> > > > > > > > The "load" verb contains the line:   Loaded_j_=: ~.
> > Loaded_j_,fl
> > > > > > > >
> > > > > > > > so although I know the path I need is in Loaded_j_
> somewhere, I
> > > > can't
> > > > > > > tell
> > > > > > > > which one it is.
> > > > > > > >
> > > > > > > > I've also tried modifying load, assigning the local: (fl)
> to a
> > > > > > > > guaranteed-unique _z_ or _j_ pronoun before it gets lost.
> That
> > > > > doesn't
> > > > > > > > always work either, except with non-nested loads. I admit I
> > don't
> > > > > know
> > > > > > > why
> > > > > > > > (it looks as if it can't fail!) and I've been too busy to go
> > > > looking.
> > > > > > > >
> > > > > > > > Unless someone knows a *guaranteed* way, I'm going to book it
> > at
> > > > > > > > https://code.jsoftware.com/wiki/System/Interpreter/Requests
> > > > > > > >
> > > > > > > >
> > > > > > > > On Tue, 9 Apr 2019 at 14:22, Eric Iverson <
> > > > eric.b.iver...@gmail.com>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > >> Ian,
> > > > > > > >> I don't think 4!:3 meets your needs (duplicates). The load
> > verb
> > > > > > > maintains
> > > > > > > >> Loaded_j_ and this might meet your needs.
> > > > > > > >>
> > > > > > > >> On Tue, Apr 9, 2019 at 8:49 AM bill lam <
> bbill....@gmail.com>
> > > > > wrote:
> > > > > > > >>
> > > > > > > >> > Does this work?
> > > > > > > >> >
> > > > > > > >> > MYSCRIPT=: >{:4!:3''
> > > > > > > >> >
> > > > > > > >> > On Tue, Apr 9, 2019, 8:29 PM Ian Clark <
> > earthspo...@gmail.com
> > > >
> > > > > > wrote:
> > > > > > > >> >
> > > > > > > >> > > How can I *reliably* fetch the path of the script being
> > > > loaded,
> > > > > > > >> whilst it
> > > > > > > >> > > is being loaded?
> > > > > > > >> > >
> > > > > > > >> > > Everything I've tried either fails or fingers the wrong
> > > script
> > > > > on
> > > > > > > >> > > occasions. Especially if my script is the subject of
> > "load"
> > > or
> > > > > > > >> "require"
> > > > > > > >> > by
> > > > > > > >> > > another script.
> > > > > > > >> > >
> > > > > > > >> > > I want to be able to write at the top of my script, say
> > > > > > > >> > >
> > > > > > > >> > > cocurrent 'myloc'
> > > > > > > >> > > MYSCRIPT=: theScriptCurrentlyBeingLoaded''
> > > > > > > >> > >
> > > > > > >
> > > >
> ----------------------------------------------------------------------
> > > > > > > >> > > 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
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > Devon McCormick, CFA
> > > >
> > > > Quantitative Consultant
> > > >
> ----------------------------------------------------------------------
> > > > 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
>
>
>
> --
>
> Devon McCormick, CFA
>
> Quantitative Consultant
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to