Below are 2 versions of j's calendar script. (Far below is a sample output
chosen so that it fits without line wrap, I hope). First is the
unadulterated script version in the standard j distribution. Second is a
crude attempt of mine to make the display a little bigger so that I could
fit 2 months on one 8 1/2 by 11 page. I added 5 spaces to the width of each
column of the readout and 4 rows to each date's readout. In the original
readout, each month's cell was 21 characters wide; the revision produces 56
characters.

You can see the important changes by comparing the last lines of the 2
scripts (beware of line wrap in the email). A 3 becomes an 8 to accommodate
the 5 spaces. The 56's in the new last line adjust for the widened cells,
and the 4 adds four rows. Also, the second line defining "h" physically
adds the 5 spaces; a definite improvement would be to revise it to move the
first 2 or 3 spaces to the end of the line, because as it is, the day names
are in a confusing position. Similarly moving the day numbers to the left
in each line to center them on the date instead of right justifying them,
as they are now. I have not pondered how to do this last change completely.

For my usage, I think it would be better to parameterize these changes and
incorporate the parameters as the x input value, because I never use the
current x value which I believe allows for non-Sunday week beginnings.



calendar =: 3 : 0
0 calendar y
:
a=. ((j<100)*(-100&|){.6!:0'')+j=. {.y
b=. (a-x)+-/<.4 100 400%~<:a
r=. 28+3,(~:/0=4 100 400|a),10$5$3 2
r=. (-7|b+0,+/\}:r)|."0 1 r(]&:>:*"1>/)i.42
m=. (<:}.y),i.12*1=#y
h=. 'JanFebMarAprMayJunJulAugSepOctNovDec'
h=. ((x*3)|.' Su Mo Tu We Th Fr Sa'),:"1~_3(_12&{.)\h
<"2 m{h,"2[12 6 21 ($,) r{' ',3":1+i.31 1
)
calendar =: 3 : 0
0 calendar y
:
a=. ((j<100)*(-100&|){.6!:0'')+j=. {.y
b=. (a-x)+-/<.4 100 400%~<:a
r=. 28+3,(~:/0=4 100 400|a),10$5$3 2
r=. (-7|b+0,+/\}:r)|."0 1 r(]&:>:*"1>/)i.42
m=. (<:}.y),i.12*1=#y
h=. 'JanFebMarAprMayJunJulAugSepOctNovDec'
h=. ('      Su      Mo      Tu      We      Th      Fr
 Sa'),:"1~_3(_12&{.)\h
<"2 m{h,"2[,/"_1]   _56]\"1((56*4)$' '),"1~[12 6 56 ($,) r{' ',8":1+i.31 1
)

   calendar 2016 9
┌────────────────────────────────────────────────────────┐
│         Sep                                            │
│      Su      Mo      Tu      We      Th      Fr      Sa│
│                                       1       2       3│
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│       4       5       6       7       8       9      10│
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│      11      12      13      14      15      16      17│
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│      18      19      20      21      22      23      24│
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│      25      26      27      28      29      30        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
│                                                        │
└────────────────────────────────────────────────────────┘



-- 
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to