I got it. The boxed arrays needed to be boxed before the jappend and unboxed 
after the jread.

 The modified script follows:

NB.%scorecard2.ijs - saves & recalls globals FLAG and OWNED
NB. the globals are currently boxed shape 350 5 and each contains
NB. literal data
NB. Created 2017-02-07
NB. =========================================================

require 'jfiles'

NB.*savethem v Converts to binary and save in a J component file
savethem=: verb define
  f=. CPATH,'flag-owned.ijf'
  jcreate f
  (< FLAG) jappend f
  (< OWNED) jappend f
  jsize f
)

NB.*recallthem v Reads from component file
recallthem=: verb define
  f=. CPATH,'flag-owned.ijf'
  FLAG0=: > jread f;0
  OWNED0=: > jread f;1
  0
)

NB. =========================================================
NB. test run follows:

savethem''
recallthem''
   FLAG0-:FLAG
1
   OWNED0-:OWNED
1



-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Tom Arneson
Sent: Tuesday, February 7, 2017 21:21
To: [email protected]
Cc: [email protected]
Subject: [Jprogramming] Boxed tables in j component files

I'm trying to save 2 boxed tables of literal data in a component file, and then 
read them back into J.

 

I've tried converting the tables to binary with 3!:1  and then creating a 
component file with jcreate

and using jappend  to write to the jfile. This process seems to work OK.
When I try to read the data, I get the error shown below in my sample run.

 

 

My script file follows

 

NB.%scorecard2.ijs - saves & recalls globals FLAG and OWNED

NB. the globals are currently boxed shape 350 5 and each contains

NB. literal data

NB. Created 2017-02-07

NB. =========================================================

 

require 'jfiles'

 

NB.*savethem v Converts to binary and save in a J component file

savethem=: verb define

f=. CPATH,'flag-owned.jf'

jcreate f

(3!:1 FLAG) jappend f

(3!:1 OWNED) jappend f

jsize f

)

 

NB.*recallthem v Reads from component file

recallthem=: verb define

f=. CPATH,'flag-owned.jf'

FLAG0=: 3!:2 jread f;0

OWNED0=: 3!:2 jread f;1

)

 

NB. =========================================================

NB. Sample run follows:

Note''

 

JVERSION

Engine: j805/j64/windows

Release: commercial/2016-12-11T08:02:16

Library: 8.05.11

Qt IDE: 1.5.3s/5.6.2

Platform: Win 64

Installer: J805 install

InstallPath: c:/program files/j64-805

Contact: www.jsoftware.com

 

savethem''

0 2 263936 0

recallthem''

|domain error: recallthem

| FLAG0=: 3!:2 jread f;0

 

)

----------------------------------------------------------------------
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