GRID Class (WAS:RE: [Jprogramming] Grid Input)
Alex Rufon
alex_rufon at ist-systems.com
Wed Sep 10 09:11:47 HKT 2008
I was playing around with the grid class when I realize that It was
created by Chris Burke and later edited by Rick Sherlock.
What surprised me was the linked grid and plot example was the
reinforcement of my assumption that J is a really-really good language
for the not so new buzzword "Business Intelligence" or BI.
Oh how I wish I can just work on stuff like this. :)
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of Alex Rufon
Sent: Wednesday, September 10, 2008 8:56 AM
To: Programming forum
Subject: RE: [Jprogramming] Grid Input
Hi Leigh,
What I would suggest is to look at this site:
http://www.jsoftware.com/jwiki/Grid/Class
That page has an example of a grid that will allow you to data.
Specifically, try the topic "Display numeric matrix given the data name"
which can be found here:
http://www.jsoftware.com/jwiki/Grid/Class#head-05665bc9021837af50d87ac82
210d5219793ef67
Unfortunately, this sample code use the J object oriented frame work. It
basically created the "myform" class which inherited it from the
"jzgrid" class. So when running it, you can play around with the data
but if you check the source CELLDATA_myform_ class property, the data
was not being updated with your changes to the grid.
One way to get the updated data is to use referencing. If you would read
the myform class, there is a line there that says:
gdemo_run=: 3 : 0
wd GDEMO
grid=: '' conew 'jzgrid'
show__grid 'celldata'
wd 'pshow'
)
What you should be interested in is the code where the grid_myform_ is
initialize with a new instance of the jzgrid class:
grid=: '' conew 'jzgrid'
Actually the author of the page, I believe Rick Sherlock, is being
helpful here by providing you with access to the inherited class. So to
access the changed data or the actual grid data, you need to do the
following:
NB. Get a reference of the inherited jzgrid class
gridInstance=: grid_myform_
NB. Inside the jzgrid class, there is the CellData property which
actuall holds the grid data
CellData__gridInstance
42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19
0 2 2 6 4 10 6 14 8 18 10 22 12 26 14 30 16 34 18
38
0 3 6 3 12 15 6 21 24 9 30 33 12 39 42 15 48 51 18
57
0 4 4 12 4 20 12 28 8 36 20 44 12 52 28 60 16 68 36
76
0 5 10 15 20 5 30 35 40 45 10 55 60 65 70 15 80 85 90
95
0 6 6 6 12 30 6 42 24 18 30 66 12 78 42 30 48 102 18
114
0 7 14 21 28 35 42 7 56 63 70 77 84 91 14 105 112 119 126
133
0 8 8 24 8 40 24 56 8 72 40 88 24 104 56 120 16 136 72
152
0 9 18 9 36 45 18 63 72 9 90 99 36 117 126 45 144 153 18
171
0 10 10 30 20 10 30 70 40 90 10 110 60 130 70 30 80 170 90
190
0 11 22 33 44 55 66 77 88 99 110 11 132 143 154 165 176 187 198
209
0 12 12 12 12 60 12 84 24 36 60 132 12 156 84 60 48 204 36
228
0 13 26 39 52 65 78 91 104 117 130 143 156 13 182 195 208 221 234
247
0 14 14 42 28 70 42 14 56 126 70 154 84 182 14 210 112 238 126
266
0 15 30 15 60 15 30 105 120 45 30 165 60 195 210 15 240 255 90
285
0 16 16 48 16 80 48 112 16 144 80 176 48 208 112 240 16 272 144
304
0 17 34 51 68 85 102 119 136 153 170 187 204 221 238 255 272 17 306
323
0 18 18 18 36 90 18 126 72 18 90 198 36 234 126 90 144 306 18
342
0 19 38 57 76 95 114 133 152 171 190 209 228 247 266 285 304 323 342
19
As you can see from the data above, I replaced the value at (0,0) to 42
in the displayed form with a grid. Also notice how I used underscores to
access the referenced class.
Another thing is that you may wonder how I know that CellData is a
global property of the jzgrid class. Actually, when I started answering
this question, I didn't really know. What I did was opened the Project
Manager, went to the Library Tab and in the Select From list box, I
highlighted jzgrid then selected the Tools->Global Assignments In File
menu item. This gave me a rather long list of global names and selected
CellData as the most likely candidate. :)
Good luck and don't hesitate to ask question.
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of Leigh J.
Halliwell
Sent: Wednesday, September 10, 2008 12:07 AM
To: 'Programming forum'
Subject: [Jprogramming] Grid Input
Dear J Forum:
Thank you for the help with the Grid class. However, I'm still stumped.
Can someone write up some J code that allows a user to input data via a
grid
into J? For example, set mat equal to the values that someone puts into
a
3x3 grid. Thanks.
Sincerely,
Leigh
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of Sherlock, Ric
Sent: Monday, September 01, 2008 3:21 AM
To: Programming forum
Subject: RE: [Jprogramming] Grid
---Leigh J. Halliwell wrote:
> I've been passing data between Excel and J with the clipboard. But I
> know that J has excellent input and reporting features. I might
> use J for some spreadsheet work, if I could only understand grids.
> I've looked in the labs and demos, as well as on Wiki, but they are
> all to complicated or condensed.
> I like the pace of the old "User Manual," but that was for Release 3.
>
> Is there something like that for teaching me about arrays and grids?
The old User Manual was before my time but I suspect that the answer to
your
question is "no".
I found the best solution for trying to understand grid, was to study
examples of use.
The demo gave me a good idea of available functionality and what some of
the
options did, but I found the way it is implemented obscured how to
actually
use the grid in an application.
The best simple examples of using the Grid that I know of are on this
wiki
page:
<http://www.jsoftware.com/jwiki/Grid/Class>
Other examples that I found useful were the browser.ijs script in the
SQLite
addon, and the csvedit addon.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list