Björn is right about "fread" and "fwrite" - they are from
~system\main\files.ijs .

However, it looks like Steven is using my "mutex" code (at
http://www.jsoftware.com/jwiki/DevonMcCormick/mutex.ijs) which I now notice
uses "fwrix" assumed to be from my "fldir" namespace which is not loaded by
this module, where

   fwrix=: 1!:12       NB. Write to position (1{y) for file-id 0{y.

I just fixed "mutex.ijs" to remedy this.

Some utilities I often find handy are "v2f" (vector to file) and "f2v" (file
to vector), e.g.

   ('Buffalo Bill''s';'defunct') v2f 'poem.txt'
   fread 'poem.txt'
Buffalo Bill's
defunct

   $lns=. f2v jpath '~system\main\conlib.ijs'
29
   >3{.lns
NB. console library
NB.
NB. this script is loaded when J is run from the console,

where these are defined thusly:

v2f=: 4 : 0
NB.* v2f: Vector to File: write vector of lines to file as lines.
   if. -.nameExists 'EOL' do. EOL=. LF end.
   (;x,&.><EOL) 1!:2 <y
NB.EG ('line 1';'line 2';<'line 3') v2f 'C:/test.tmp'
)

f2v=: 3 : 0
NB.* f2v: File to Vector: read file -> vector of lines.
   vec=. l2v 1!:1 <y
)

l2v=: 3 : 0
NB.* l2v: Lines to Vec: convert lines terminated by LF to vector elements.
   <;._2 y-.CR
)

nameExists=: 0:"_ <: [: 4!:0 <^:(L. = 0:)


2010/12/23 Björn Helgason <[email protected]>

> fread and fwrite are part of J
>   ...
>

-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to