When I had made little progress with my application, I decided to try
a toy app to see if I could duplicate the problem.
Here is my code, created largely from scratch in the Form Editor and
then modified to contain a bit of code from my app:
========================================================================
require 'grid'
MYAPP=: 0 : 0
pc myapp;
menupop "File";
menu new "&New" "" "" "";
menu open "&Open" "" "" "";
menusep;
menu exit "&Exit" "" "" "";
menupopz;
xywh 136 8 44 12;cc ok button;cn "OK";
xywh 136 23 44 12;cc cancel button;cn "Cancel";
xywh 0 0 48 12;cc test button;cn "Test";
pas 6 6;pcenter;
sbar 1;
rem form end;
)
datasheet =: ? 5 10 ? 50
myapp_run=: 3 : 0
wd MYAPP
NB. initialize form here
wd 'pshow;'
)
myapp_close=: 3 : 0
wd'pclose'
)
myapp_cancel_button=: 3 : 0
myapp_close''
)
DEBUG =: 1
viewdata =: 3 : 0
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01a'
if.
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01b'
# 'datasheet' names 0
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01c'
do.
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01d'
grid datasheet
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01e'
else.
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01f'
wdinfo 'Alert';'Please read legacy data first.'
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01g'
end.
)
myapp_test_button=: 3 : 0
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 01'
viewdata''
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 02'
wd'psel myapp;'
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 03'
wd 'sbarset idstatusrdy 50 Ready'
(<'c:/temp/myapp.log') 1!:3~^:DEBUG CRLF, 'check point 04'
)
myapp_run''
========================================================================
I then set up a shortcut (I'm on XP) to launch it. The target is
"C:\Program Files\j602\bin\j.exe" -jijx
"B:\MyOrg\MyDept\MyName\j602-user\projects\appdev\app.ijs"
and it starts in
"B:\MyOrg\MyDept\MyName\j602-user\projects\appdev"
I run the app from the shortcut, I press Test, and I press Cancel.
That works. The log file is
======================================
check point 01
check point 01a
check point 01b
check point 01c
check point 01d
check point 01e
check point 02
check point 03
check point 04
======================================
and the grid control pops up. An ijx window is open, too.
If I add -jijx in the shortcut target, run the app, and press Test, I
get
======================================
check point 01
check point 01a
check point 01b
======================================
in the logfile, and I get
======================================
error in: myapp_test_button
index error: pick
wd'psel',1 pick,p#~(<'jijx')=3{"1 p
======================================
in a wdhandler message box. I get no grid nor (of course) ijx window.
That seems to confirm that it's the
# 'datasheet' names 0
sentence that gives the problem. It still makes no sense to me,
though, for it seems that stdlib is failing when it's trying to run
wcsize, and I don't yet see why names or # should want to run wcsize.
A bit of grepping turned up that wcsize is used in stdlib, misc, and
format. The call in misc looked suspicious:
========================================================================
NB. =========================================================
NB.*show v show names using a linear representation
NB. show names using a linear representation to screen width
NB. syntax:
NB. show namelist (e.g. show 'deb edit list')
NB. show numbers (from 0 1 2 3=nouns, adverbs etc)
NB. show '' (equivalent to show 0 1 2 3)
NB. useful for a quick summary of object definitions
show=: 3 : 0
y=. y,(0=#y)#0 1 2 3
if. (3!:0 y) e. 2 32 do. y=. cutopen y
else. y=. (4!:1 y) -. (,'y');,'y.' end.
wid=. {.wcsize ''
sub=. (1{a.)&(I. @(e.&(9 10 12 13{a.))@]})
j=. '((1<#$t)#(":$t),''$''),":,t'
j=. 'if. L. t=. ".y do. 5!:5 <y return. end.';j
j=. 'if. 0~:4!:0 <y do. 5!:5 <y return. end.';j
(wid&{. @ (,&'=: ',sub @ (3 : j))) &> y
)
========================================================================
There's also
========================================================================
NB. =========================================================
NB.*list v list data formatted in columns
NB. syntax: {width} list data
NB. accepts data as one of:
NB. boxed list
NB. character vector, delimited by CR, LF or CRLF; or by ' '
NB. character matrix
NB. formats in given width, default screenwidth
list=: 3 : 0
w=. {.wcsize''
w list y
:
if. 0=#y do. i.0 0 return. end.
if. 2>#$y=. >y do.
d=. (' ',LF) {~ LF e. y=. toJ ": y
y=. [;._2 y, d #~ d ~: {: y
end.
y=. y-. ' '{.~ c=. {:$ y=. (": y),.' '
(- 1>. <. x % c) ;\ <"1 y
)
========================================================================
in stdlib.
Is any of this code called by 'names' perhaps? Is this behavior
correct?
I'm trying to verify that datasheet exists before trying to do
anything with it. Assuming this is the problem, is there a good,
robust way to test for the existence of datasheet other than
# 'datasheet' names 0
that's recommended?
Thanks,
Bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm