load 'jmf'
NB. Loads jmf facilities.

     testfile =: {2,\?50#75

     fn =: jpath 'C:\Users\skip\J904-user\temp\foo\testfile_name.jmf'
NB. Links a covername to the file path.
     createjmf_jmf_ fn;(([:(*&8)#);testfile)
NB. Create the container for your file.
NB. -fn is your reference name
NB. -(([:(*&8)#);testfile) allocates the size of yor fike in bytes

     map_jmf_ 'testfile_disk';fn
NB. Maps the file to a noun 'testfile_disk'
     ] testfile_disk_jmf_ =: testfile

     unmap_jmf 'testfile_disk_jmf_'
NB. Release mappings
Or
Exit 0
Close session.


New session.

     load 'jmf'
     fn =:  jpath 'C:\Users\skip\J904-user\temp\foo\testfile_name.jmf'
     map_jmf_ 'testfile1';fn
NB. Map file
     ] testfile1_jmf_
NB. File loaded as noun 'testfile1_jmf_'

Some potential benefits of the .jmf datatype:
-Preserves header and shape information.
-If you want to map you file as read only, use the following syntax
map_jmf_ 'testfile1';fn;'';1
-If you would like it to be copy-on-write use the following syntax
map_jmf_ 'testfile1';fn;'';2


Ak

On Wed., Feb. 1, 2023, 21:48 'Skip Cave' via Programming, <
programm...@jsoftware.com> wrote:

> I have a boxed noun:
>
> ] testfile =: {2,\?15#50
>
>
> ┌────┬─────┬─────┬─────┬─────┬─────┬────┬────┬────┬────┬─────┬────┬───┬────┐
>
> │9 21│21 47│47 37│37 13│13 33│33 20│20 4│4 49│49 6│6 25│25 33│33 9│9 6│6
> 43│
>
>
> └────┴─────┴─────┴─────┴─────┴─────┴────┴────┴────┴────┴─────┴────┴───┴────┘
>
>
> I want to store it in the following location on my machine:
>
>
> ]fn =. < 'C:\Users\skip\J904-user\temp'
>
> ┌────────────────────────────┐
>
> │C:\Users\skip\J904-user\temp│
>
> └────────────────────────────┘
>
> Then I will close that J session.
>
>
> Later, I will start a new J session, and I want to read that saved file
> into a noun called 'test1'
>
>
> What is the J code for writing the noun into a file in the first session?
>
> What is the J code to read the file into a noun in the second session?
>
> Should I use 1!2 & 1!:1, or fwrite & fread, or something else?
>
>
> Where in the J doc are these file operations and their tradeoffs described?
>
>
> Skip
>
>
> Skip Cave
> Cave Consulting LLC
> ----------------------------------------------------------------------
> 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