[Jprogramming] J path syntax for the current file's folder
Raul Miller
rauldmiller at gmail.com
Mon May 30 16:37:50 UTC 2022
Well... you could use the approach used here (lines 11 through 17):
https://github.com/zerowords/tgsjo/blob/master/tgsjo.ijs#L11
I hope this helps,
--
Raul
On Mon, May 30, 2022 at 11:58 AM Jinwoo Lee <jinwoo68 at gmail.com> wrote:
>
> When my script file loads other files that I write, it would be very
> convenient if we had a special jpath syntax for the folder that contains
> the current file. For example, let's say my script is at /my/path/foo.ijs,
> and it loads bar.ijs from the same folder.
>
> load 'bar.ijs'
> ...
>
> Or it loads baz.ijs from a subfolder.
>
> load 'libs/baz.ijs'
> ...
>
> But this works only when I run the script from the /my/path folder. If I
> run it from, say, my home directory, load would fail to locate bar.ijs.
>
> If J provides a special path syntax, say, '~filefolder', I'll be able to do
>
> load '~filefolder/bar.ijs'
> ...
>
> or
>
> load '~filefolder/libs/baz.ijs'
> ...
>
> I'll be able to use ARGV_z_ to extract it but that would work only for the
> main script file.
>
> Does this make sense? Or am I missing something obvious?
>
> Cheers,
> Jinwoo
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list