Ronan Reilly wrote:
> I've created a file of binary encoded data (using 3!:1) written out using
> the fappend function.
> 
> When I read the file contents back in and try to decode them using 3!:2, I
> notice that 3!:2 only translates the first item appended and that I have to
> use }. to step through the file contents to obtain additional items.
> 
> I was wondering if there is any way of using 3!:2 to decode the binary data
> in one go.

Pack or jfiles may do what you want. Here are examples:

load 'files jfiles pack'

A=: 10 20 30;'test'
B=: i.5
C=: 'hello'
FL=: jpath '~temp/t1.dat'

NB. Using pack:
   (3!:1 pack 'A B C') fwrite FL
276
   3!:2 fread FL
+-+---------------+
|A|+--------+----+|
| ||10 20 30|test||
| |+--------+----+|
+-+---------------+
|B|0 1 2 3 4      |
+-+---------------+
|C|hello          |
+-+---------------+

NB. using j files:
   jcreate FL
1
   (A;B;C) jappend FL  NB. or append one at a time
0 1 2
   jread FL;0 1 2
+---------------+---------+-----+
|+--------+----+|0 1 2 3 4|hello|
||10 20 30|test||         |     |
|+--------+----+|         |     |
+---------------+---------+-----+

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to