I can only guess what your code suppose to perform. With some
modification, it show animation but mapping seem upside down. Hope this help.
Втр, 21 Фев 2012, Linda Alvord писал(а):
> I tried to attach and .ijs file and it didn't work, so here it is:
>
> NB. WhimsyCalculus(WhimsyTOT98) 2/20/2001
> require 'gui/gtkwd'
> Debugwd_gtkwd_=:1
> require 'gl2 trig'
>
> NB.bind=: [. @ ("_)
> each=: (&.>)
>
> range=: 3 : '(>./y)-<./y'
> lint=: 13 : '(range y) % x'
> ap=: 13 :'(<./y)+0,+/\x#x lint y'
> rot=:2 2"_ $ 1 _1 1 1"_ * 2 1 1 2"_ o. ]
>
> boat=:_2+0.5*4 2 3 5 6 4 4 6 4,:3 3 2 2 3 3 7 4 4
> Fred=:_1.6+0.4*(18 9 9 6 0 3 0 6 12 18,:12 18 15 12 18 12 6 9 6 12)%3
> ladybug=:0.2*0 _6 _5 _4 _2 0 2 3 3 2 6 2 2 6 2 3 3 2 0 _2 _4 _5 _6 0,:0 _1 _2
> _3 _4 _4 _3 _2 _1 0 _1 0 0 1 0 1 2 3 4 4 3 2 1 0
> dragonfly=:0.1* 0 6 10 6 0 2 6 0 _6 _6 0 _24 0 _6 _6 0 6 2 0 6 10 6 0,:0 0 4
> 0 0 8 12 0 12 6 0 0 0 _6 _12 0 _12 _8 0 0 _4 0 0
> turtle=:0.3*6 5 4 2 3 2 3 2 0 _2 _3 _5 _3 _2 _3 _5 _5 _3 _2 _3 _5 _3 _2 0 2 3
> 2 3 2 4 5 6,:0 1 0 2 4 6 4 2 3 2 4 3 4 2 1 0 0 _1 _2 _4 _3 _4 _2 _3 _2 _4 _6
> _4 _2 0 _1 0
>
> sline=: 3 : 0"1 2
> 0 0 0 sline y
> :
> glrgb x
> glpen 1 0
> gllines ,y
> glshow ''
> )
>
> sfill=: 3 : 0
> if. _1 e. y do. glbrushnull ''
> else. glrgb y
> glbrush ''
> end.
> )
>
> spoly=: 3 : 0"1 2
> glpolygon ,y
> glshow ''
> :
> sfill x
> spoly y
> )
>
> spixel=: 3 : 0"1
> glpixel y
> glshow ''
> :
> glrgb x
> spixel y
> )
>
> size=: 3 : '500+50*|: y'
>
> see=: 3 : 0
> 0 0 0 see y
> :
> xx=:0
> yy=:0
> d=:0
> )
>
> swim=: 3 : 0
> 0 0 0 swim y
> :
> t=:24 ap _2p1 2p1
> xx=: t
> yy=: 1 o. t
> d=: 2 o. t
> p=:xx,:y
> )
>
> dance=: 3 : 0
> 0 0 0 dance y
> :
> t=:24 ap _3p1 3p1
> xx=:t - 2 * 1 o. t
> yy=:1 - 2 * 2 o. t
> d=:(2 * 1 o. t) % 1 - 2 * 2 o. t
> )
>
> x3=: 3 : '8 * (r=. 1 o. 2 * y) * 2 o. y'
> y3=: 3 : '8 * (r=. 1 o. 2 * y) * 1 o.y'
>
> loop=: 3 : 0
> 0 0 0 loop y
> :
> t=:48 ap 0 2p1
> xx=:x3 t
> yy=:y3 t
> dy=:((1 o. 2*t)*2 o.t)+(1 o.t)*2*2 o. 2*t
> dx=:(-(1 o. 2*t)*1 o.t)+(2 o.t)*2*2 o. 2*t
> 1E_5(<1)}dx
> d=:dy%dx
> )
>
> fade=: 3 : 0
> 200 330 100 fade y
> :
> t=:120 ap _2p1 2p1
> xx=:4 * 2 o. t
> y=:t + 1 o. 3 * t
> d=:(-1+3 * 2 o.3* t,0)%4* 1 o. 0,t
> kk=:1.5
> )
>
> TOT98=: 0 : 0
> pc tot98;picon fred\fred.ico 0;pn "Tool of Thought X, A Whimsyware Product
> from Stochastic Services";
> xywh 245 10 65 40;cc lis0 listbox ws_vscroll;
> xywh 245 55 65 40;cc lis1 listbox ws_vscroll;
> xywh 245 100 65 40;cc lis2 listbox ws_vscroll;
> xywh 245 150 30 30;cc show button bs_ownerdraw;cn "fred\ss.ico";
> xywh 280 150 30 30;cc pain button bs_ownerdraw;cn "fred\ssg.ico";
> xywh 245 185 65 15;cc clear button;cn "Clear";
> xywh 245 205 65 15;cc cancel button;cn "Close";
> xywh 3 3 220 220;cc g isigraph;
> pas 6 6;pcenter;
> )
>
> tot98_run=: 3 : 0
> forms=:;:'boat Fred ladybug dragonfly turtle '
> paths=:;:'see swim dance loop fade '
> colors=:;:'red green blue yellow orange '
> red=:255 0 0
> green=:0 255 0
> blue=:0 0 255
> yellow=:255 255 0
> orange=:255 126 0
> wd TOT98
> wd 'set lis0 ',;forms, each LF
> wd 'setfont lis0 "MS Sans Serif" 11 bold'
> wd 'set lis1 ',;paths, each LF
> wd 'setfont lis1 "MS Sans Serif" 11 bold'
> wd 'set lis2 ',;colors, each LF
> wd 'setfont lis2 "MS Sans Serif" 11 bold'
> wd 'setfont clear "MS Sans Serif" 11'
> wd 'setfont cancel "MS Sans Serif" 11'
> smoutput 'a0'
> label_there.
> smoutput 'a1'
> while. 1 do.
> smoutput 'a2'
> wd 'wait'
> k=:wd 'q'
> smoutput 'a3'
> if.
> smoutput 'a4'
> (*/'show' = 4{.>9{{:"1 k) +. */'pain' = 4{.>9{{:"1 k
> do.
> if.
> */'pain' = 4{.>9{{:"1 k
> do.
> wd ".'glrgb ',":?3#255
> glbrush ''
> glflood 100 120 0 127 255
> end.
> if.
> */'see' = 3{.>14{{:"1 k
> do.
> xx=:0
> yy=:0
> d=:0
> s=:2*".>16{{:"1 k
> 0 0 0 sline size s
> (".uuu=:>12{{:"1 k) spoly size s
> glshow ''
> goto_there.
> end.
> ".(col=:>12{{:"1 k),' ',(path=:>14{{:"1 k),' ',who=:>16{{:"1 k
> p=:xx,:yy
> cc=:0
> while. cc<$,yy do. r=:rot _3 o. cc{d
> if. */'loop'=4{.iii=:>14{{:"1 k do.
> s=:((r +/ . *".who)*cc{*dx)+ (_1 {.$".who)#"1,.cc{"1 p
> end.
> if. (*/'swim'=4{.>14{{:"1 k) +. (*/'danc'=4{.>14{{:"1 k) do.
> s=:(r +/ . *".who)+(_1 {.$".who)#"1,.cc{"1 p
> end.
> if. */'fade'=4{.>14{{:"1 k do.
> s=:(r +/ .* kk *
> (".who)*(_1{.$".who)#"1,.*2#cc{(-*t)*_1+2*(|t)<1p1)+ (_1 {.$".who)#"1,.cc{"1 p
> kk =:0.97*kk
> end.
> 0 0 0 sline size s
> (".col) spoly size s
> glshow ''
> 255 255 255 sline size s
> 255 255 255 spoly size s
> glshow ''
> cc=:cc+1
> end.
> kk=:1.5
> goto_there.
> end.
> if. */'clea'= 4{.>9{{:"1 k do. glclear '' end.
> if. */'canc' = 4{.>9{{:"1 k do. goto_here. end.
> end.
> wd 'pshow;'
> label_here.
> tot98_close ''
> )
>
> tot98_cancel_button=:tot98_close
>
> tot98_close=: wd bind 'pclose'
>
> tot98_run''
>
> Maybe the problem will jump out for you.
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Linda Alvord
> Sent: Tuesday, February 21, 2012 5:51 AM
> To: 'Programming forum'
> Subject: Re: [Jprogramming] Control error when loading script into ijx window
> (J602)
>
> All my code is really ancient code and it worked. I was frustrated that I
> could not make things work anymore when changes were made. Maybe you can find
> my problem in the attached script.
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of bill lam
> Sent: Tuesday, February 21, 2012 5:17 AM
> To: [email protected]
> Subject: Re: [Jprogramming] Control error when loading script into ijx window
> (J602)
>
> I guess these are really ancient codes. the wd'wait' is rarely used in
> modern J base libary or addons code, and the gtkwd does not support it. And
> wd'q' will raise domain error if there is no event after the previous wd'q'
>
> You code fragment is incomplete so that I cannot know what it is suppose to
> do. You should put event-driven code inside either form_default or
> form_child_button. eg, if there is a button with an id 'foo'
>
> form_foo_button=: 3 :0
> k=. wdq
> if. (*/'show' = 4{.>9{{:"1 k) +. */'pain' = 4{.>9{{:"1 k do.
> if. */'pain' = 4{.>9{{:"1 k
> .....
> )
>
> Often wdq need not used, because the value of child will be automatically
> assigned. Please read the chapter on 'window driver'
> in "j user manual" accessible from j602 help for some background.
>
> Втр, 21 Фев 2012, Linda Alvord писал(а):
> > Here is the code that causes my trouble. I have Debugwd_gtkwd_=:1 way at
> > the beginning.
> >
> > wd 'setfont clear "MS Sans Serif" 11'
> > wd 'setfont cancel "MS Sans Serif" 11'
> > smoutput 'a0'
> > label_there.
> > smoutput 'a1'
> > while. 1 do.
> > smoutput 'a2'
> > wd 'wait'
> > k=:wd 'q'
> > smoutput 'a3'
> > if.
> > smoutput 'a4'
> > (*/'show' = 4{.>9{{:"1 k) +. */'pain' = 4{.>9{{:"1 k
> > do.
> > if.
> > */'pain' = 4{.>9{{:"1 k
> >
> > here's where I go astray:
> >
> > wd 'setfont clear "MS Sans Serif" 11'
> > wd 'setfont cancel "MS Sans Serif" 11'
> > smoutput 'a0'
> > label_there.
> > smoutput 'a1'
> > while. 1 do.
> > smoutput 'a2'
> > wd 'wait'
> > k=:wd 'q'
> > smoutput 'a3'
> > if.
> > smoutput 'a4'
> >
> > since I haven't used this code since J4 I can't remember what I would get
> > in 'q' but I must have been able to collect some data I wanted but I don't
> > know what it was back then.
> >
> > Any ideas?
> >
> > Linda
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of bill lam
> > Sent: Tuesday, February 21, 2012 1:49 AM
> > To: [email protected]
> > Subject: Re: [Jprogramming] Control error when loading script into ijx
> > window (J602)
> >
> > I would suspect H L C are undefined. My general approach is to insert
> > smoutput before and after every control switch, eg
> >
> > smoutput 'a1'
> > for_i. i.(#a) do.
> > smoutput 'a2'
> >
> > currHi=. ". > (i { H)
> > currLo=. ". > (i { L)
> > currCl=. ". > (i { C)
> >
> > if. (0=i) do.
> > smoutput 'a3'
> > diffHi=. 0
> > diffLo=. 0
> > else. <-------- control error here
> > smoutput 'a4'
> > prevHi=. ". > ((i-1) { H)
> > prevLo=. ". > ((i-1) { L)
> > diffHi=. currHi - prevHi
> > if. 0<:diffHi do. pivotHi=. currHi end.
> > smoutput 'a5'
> > diffLo=. prevLo - currLo
> > if. 0<:diffLo do. pivotLo=. currLo end.
> > smoutput 'a6'
> > end.
> >
> > smoutput 'a7'
> > if. diffLo>diffHi do.
> > smoutput 'a8'
> > if. currLo <: ( pivotHi * (1-swing) ) do.
> > smoutput 'a9'
> > xx=. xx , currLo
> >
> > Втр, 21 Фев 2012, PackRat писал(а):
> > > When loading a script to test, I get an immediate "control error"
> > > when I give the command to load it. The following is the portion of
> > > the script that has all of the control structures. I've drawn an
> > > arrow pointing to the line where the error is supposed to have
> > > occurred. I'm probably "blind" to the error because I'm just not seeing
> > > the problem.
> > >
> > > ================================================================
> > >
> > > for_i. i.(#a) do.
> > >
> > > currHi=. ". > (i { H)
> > > currLo=. ". > (i { L)
> > > currCl=. ". > (i { C)
> > >
> > > if. (0=i) do.
> > > diffHi=. 0
> > > diffLo=. 0
> > > else. <-------- control error here
> > > prevHi=. ". > ((i-1) { H)
> > > prevLo=. ". > ((i-1) { L)
> > > diffHi=. currHi - prevHi
> > > if. 0<:diffHi do. pivotHi=. currHi end.
> > > diffLo=. prevLo - currLo
> > > if. 0<:diffLo do. pivotLo=. currLo end.
> > > end.
> > >
> > > if. diffLo>diffHi do.
> > > if. currLo <: ( pivotHi * (1-swing) ) do.
> > > xx=. xx , currLo
> > > else.
> > > xx=. xx , ( {: xx ) NB. repeat previous value
> > > end.
> > > else.
> > > if. currHi >: ( pivotLo * (1+swing) )
> > > xx=. xx , currHi
> > > else.
> > > xx=. xx , ( {: xx ) NB. repeat previous value
> > > end.
> > > end.
> > >
> > > end.
> > >
> > > ================================================================
> > >
> > > The same error (at the same line) occurs if the following lines:
> > >
> > > if. 0<:diffHi do. pivotHi=. currHi end.
> > > . . .
> > > if. 0<:diffLo do. pivotLo=. currLo end.
> > >
> > > are instead expanded to:
> > >
> > > if. 0<:diffHi do.
> > > pivotHi=. currHi
> > > end.
> > > . . .
> > > if. 0<:diffLo do.
> > > pivotLo=. currLo
> > > end.
> > >
> > >
> > > I would appreciate any assistance in "opening my eyes"--thanks in
> > > advance!
> > >
> > >
> > > Harvey
> > >
> > > --------------------------------------------------------------------
> > > -- For information about J forums see
> > > http://www.jsoftware.com/forums.htm
> >
> > --
> > regards,
> > ====================================================
> > GPG key 1024D/4434BAB3 2008-08-24
> > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
NB. WhimsyCalculus(WhimsyTOT98) 2/20/2001
require 'gui/gtkwd'
require 'gl2 trig'
coclass 'tot98'
coinsert 'jgl2'
NB.bind=: [. @ ("_)
each=: (&.>)
range=: 3 : '(>./y)-<./y'
lint=: 13 : '(range y) % x'
ap=: 13 :'(<./y)+0,+/\x#x lint y'
rot=: 2 2"_ $ 1 _1 1 1"_ * 2 1 1 2"_ o. ]
boat=: _2+0.5*4 2 3 5 6 4 4 6 4,:3 3 2 2 3 3 7 4 4
Fred=: _1.6+0.4*(18 9 9 6 0 3 0 6 12 18,:12 18 15 12 18 12 6 9 6 12)%3
ladybug=: 0.2*0 _6 _5 _4 _2 0 2 3 3 2 6 2 2 6 2 3 3 2 0 _2 _4 _5 _6 0,:0 _1 _2
_3 _4 _4 _3 _2 _1 0 _1 0 0 1 0 1 2 3 4 4 3 2 1 0
dragonfly=: 0.1* 0 6 10 6 0 2 6 0 _6 _6 0 _24 0 _6 _6 0 6 2 0 6 10 6 0,:0 0 4 0
0 8 12 0 12 6 0 0 0 _6 _12 0 _12 _8 0 0 _4 0 0
turtle=: 0.3*6 5 4 2 3 2 3 2 0 _2 _3 _5 _3 _2 _3 _5 _5 _3 _2 _3 _5 _3 _2 0 2 3
2 3 2 4 5 6,:0 1 0 2 4 6 4 2 3 2 4 3 4 2 1 0 0 _1 _2 _4 _3 _4 _2 _3 _2 _4 _6 _4
_2 0 _1 0
sline=: 3 : 0"1 2
0 0 0 sline y
:
glrgb x
glpen 1 0
gllines ,y
glpaintx''
)
sfill=: 3 : 0
if. _1 e. y do. glbrushnull ''
else. glrgb y
glbrush ''
end.
)
spoly=: 3 : 0"1 2
glpolygon ,y
glpaintx''
:
sfill x
spoly y
)
spixel=: 3 : 0"1
glpixel y
glpaintx''
:
:
glrgb x
spixel y
)
NB. 500 seems too large
NB. size=: 3 : '500+50*|: y'
size=: 3 : '100+50*|: y'
see=: 3 : 0
0 0 0 see y
:
xx=: 0
yy=: 0
d=: 0
)
swim=: 3 : 0
0 0 0 swim y
:
t=: 24 ap _2p1 2p1
xx=: t
yy=: 1 o. t
d=: 2 o. t
p=: xx,:y
)
dance=: 3 : 0
0 0 0 dance y
:
t=: 24 ap _3p1 3p1
xx=: t - 2 * 1 o. t
yy=: 1 - 2 * 2 o. t
d=: (2 * 1 o. t) % 1 - 2 * 2 o. t
)
x3=: 3 : '8 * (r=. 1 o. 2 * y) * 2 o. y'
y3=: 3 : '8 * (r=. 1 o. 2 * y) * 1 o.y'
loop=: 3 : 0
0 0 0 loop y
:
t=: 48 ap 0 2p1
xx=: x3 t
yy=: y3 t
dy=: ((1 o. 2*t)*2 o.t)+(1 o.t)*2*2 o. 2*t
dx=: (-(1 o. 2*t)*1 o.t)+(2 o.t)*2*2 o. 2*t
1E_5(<1)}dx
d=: dy%dx
)
fade=: 3 : 0
200 330 100 fade y
:
t=: 120 ap _2p1 2p1
xx=: 4 * 2 o. t
yy=: t + 1 o. 3 * t
d=: (-1+3 * 2 o.3* t,0)%4* 1 o. 0,t
kk=: 1.5
)
TOT98=: 0 : 0
pc tot98;picon fred\fred.ico 0;pn "Tool of Thought X, A Whimsyware Product from
Stochastic Services";
xywh 245 10 65 40;cc lis0 listbox ws_vscroll;
xywh 245 55 65 40;cc lis1 listbox ws_vscroll;
xywh 245 100 65 40;cc lis2 listbox ws_vscroll;
xywh 245 150 30 30;cc show button bs_ownerdraw;cn "fred\ss.ico";
xywh 280 150 30 30;cc pain button bs_ownerdraw;cn "fred\ssg.ico";
xywh 245 185 65 15;cc clear button;cn "Clear";
xywh 245 205 65 15;cc cancel button;cn "Close";
xywh 3 3 220 220;cc g isigraph;
pas 6 6;pcenter;
)
tot98_run=: 3 : 0
forms=: ;:'boat Fred ladybug dragonfly turtle '
paths=: ;:'see swim dance loop fade '
colors=: ;:'red green blue yellow orange '
red=: 255 0 0
green=: 0 255 0
blue=: 0 0 255
yellow=: 255 255 0
orange=: 255 126 0
wd TOT98
wd 'set lis0 ',;forms, each LF
wd 'setfont lis0 "MS Sans Serif" 11 bold'
wd 'set lis1 ',;paths, each LF
wd 'setfont lis1 "MS Sans Serif" 11 bold'
wd 'set lis2 ',;colors, each LF
wd 'setfont lis2 "MS Sans Serif" 11 bold'
wd 'setfont clear "MS Sans Serif" 11'
wd 'setfont cancel "MS Sans Serif" 11'
wd 'pshow'
)
NB. y: 1=pain
showpain=: 3 : 0
if. y do.
glrgb ?3#255
glbrush ''
NB. what is glflood ?
NB. glflood 100 120 0 127 255
end.
if. lis1 -: 'see' do.
xx=: 0
yy=: 0
d=: 0
s=: 2*".lis0
0 0 0 sline size s
(".uuu=: lis2) spoly size s
return.
end.
xx=: 0
".(col=: lis2),' ',(path=: lis1),' ',who=: lis0
p=: xx,:yy
cc=: 0
while. cc<$,yy do. r=: rot _3 o. cc{d
xx=: 0
if. 'loop'-:iii=: lis1 do.
s=: ((r +/ . *".lis0)*cc{*dx)+ (_1 {.$".lis0)#"1,.cc{"1 p
end.
if. ('swim'-:lis1) +. ('dance'-:lis1) do.
s=: (r +/ . *".lis0)+(_1 {.$".lis0)#"1,.cc{"1 p
end.
if. 'fade'-:lis1 do.
s=: (r +/ .* kk * (".lis0)*(_1{.$".lis0)#"1,.*2#cc{(-*t)*_1+2*(|t)<1p1)+
(_1 {.$".lis0)#"1,.cc{"1 p
kk=: 0.97*kk
end.
0 0 0 sline size s
(".col) spoly size s
255 255 255 sline size s
255 255 255 spoly size s
cc=: cc+1
end.
kk=: 1.5
)
tot98_show_button=: showpain bind 0
tot98_pain_button=: showpain bind 1
tot98_clear_button=: glpaintx@glclear
tot98_cancel_button=: tot98_close
tot98_close=: wd bind 'pclose'
tot98_run''
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm