For Programmers: Free Programming Magazines  


Home > Archive > APL > October 2004 > GUI Help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author GUI Help
smandula

2004-10-21, 3:55 am

What am I doing wrong? Small pogram to change temperature C to F
Demonstrating, enter value into editbox1(ED1) when onclick OK
button,converts to Farenheit,
and places the result on editbox2(ED2). Closing the Gui is no problem

[1] Temp;V
[2]
[3] 'ff' {quad} 'Delete'
[4] 'ff' {quad}wi 'Create' 'Form'
[5] 'ff.bnOK' {quad}wi 'New' 'Button'
[6] 'ff.bnOK' {quad}wi 'caption' 'OK'
[7] 'ff.bnOK' {quad}wi 'where' 2 45
[8] 'ff.bnOK' {quad}wi 'onClick' 'ff.bnOK.Click'
[9]
[10] 'ff.bnCancel' {quad}wi 'New' 'Button'('caption' 'Cancel')('where' 8 45)
('style' 2)
]11]
[12] 'ff.Lb1' {quad}wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
[13] 'ff.ED1' {quad}wi 'New' 'Edit' ('where' 5 20)
[14] 'ff.Lb2' {quad}wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
[15] 'ff.ED2' {quad}wi 'New' 'Edit' ('where' 10 20)
[16]
[17] 'ff.bnOk.Click' {quad}wi 'value'(V<-'ff.ED1'{quad}wi'text')
[18] 'ff.ED1' {quad}wi 'text' ({Thorn}V)
[19] 'ff.ED2' {quad}wi 'text'({Thorn}32+V󭝵)

Any help would be appreciated. I am using Apl+Win 4.0
With Thanks
Steve


LatLong

2004-10-21, 3:55 am

Modifying your code to make it work, here is a solution.
{del} Temp;V
[1]
[2] 'ff' #wi 'Create' 'Form'
[3] 'ff.bnOK' #wi 'New' 'Button'
[4] 'ff.bnOK' #wi 'caption' 'OK'
[5] 'ff.bnOK' #wi 'where' 2 45
[6] 'ff.bnOK' #wi 'onClick' "V{<-}#fi 'ff.ED1'#wi'text' & 'ff.ED2' #wi
'text'({format}32+V{times}9{divide}5)"
[7]
[8] 'ff.bnCancel' #wi 'New' 'Button'('caption' 'Cancel')('where' 8
45)('style' 2)
[9]
[10] 'ff.Lb1' #wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
[11] 'ff.ED1' #wi 'New' 'Edit' ('where' 5 20)
[12] 'ff.Lb2' #wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
[13] 'ff.ED2' #wi 'New' 'Edit' ('where' 10 20)
{del}

Note -your onClick handler needs to be valid code or a function that is run
when the Click event fires.



"smandula" <smandula@idirect.com> wrote in message
news:qvadnSU5NJTSuOrcRVn-pA@look.ca...
> What am I doing wrong? Small pogram to change temperature C to F
> Demonstrating, enter value into editbox1(ED1) when onclick OK
> button,converts to Farenheit,
> and places the result on editbox2(ED2). Closing the Gui is no problem
>
> [1] Temp;V
> [2]
> [3] 'ff' {quad} 'Delete'
> [4] 'ff' {quad}wi 'Create' 'Form'
> [5] 'ff.bnOK' {quad}wi 'New' 'Button'
> [6] 'ff.bnOK' {quad}wi 'caption' 'OK'
> [7] 'ff.bnOK' {quad}wi 'where' 2 45
> [8] 'ff.bnOK' {quad}wi 'onClick' 'ff.bnOK.Click'
> [9]
> [10] 'ff.bnCancel' {quad}wi 'New' 'Button'('caption' 'Cancel')('where' 8

45)
> ('style' 2)
> ]11]
> [12] 'ff.Lb1' {quad}wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
> [13] 'ff.ED1' {quad}wi 'New' 'Edit' ('where' 5 20)
> [14] 'ff.Lb2' {quad}wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
> [15] 'ff.ED2' {quad}wi 'New' 'Edit' ('where' 10 20)
> [16]
> [17] 'ff.bnOk.Click' {quad}wi 'value'(V<-'ff.ED1'{quad}wi'text')
> [18] 'ff.ED1' {quad}wi 'text' ({Thorn}V)
> [19] 'ff.ED2' {quad}wi 'text'({Thorn}32+V󭝵)
>
> Any help would be appreciated. I am using Apl+Win 4.0
> With Thanks
> Steve
>
>



Graham Steer

2004-10-21, 3:55 pm

Steve,

Your question has already been answered in coding terms. I would recommend
as a
matter of style you write all your handlers as functions. In your example I
would name them Convert and Cancel. In this way having developed your form
layout and basic functionality you can then add functionality by developing
the handler functions without having to touch the form coding. For example
it would be easy to make Convert go either way depending on which box your
user input a value. You could then add error trapping if no value was
entered. Similarly you could control what happened when you user cancels the
form.

Graham.
"smandula" <smandula@idirect.com> wrote in message
news:qvadnSU5NJTSuOrcRVn-pA@look.ca...
> What am I doing wrong? Small pogram to change temperature C to F
> Demonstrating, enter value into editbox1(ED1) when onclick OK
> button,converts to Farenheit,
> and places the result on editbox2(ED2). Closing the Gui is no problem
>
> [1] Temp;V
> [2]
> [3] 'ff' {quad} 'Delete'
> [4] 'ff' {quad}wi 'Create' 'Form'
> [5] 'ff.bnOK' {quad}wi 'New' 'Button'
> [6] 'ff.bnOK' {quad}wi 'caption' 'OK'
> [7] 'ff.bnOK' {quad}wi 'where' 2 45
> [8] 'ff.bnOK' {quad}wi 'onClick' 'ff.bnOK.Click'
> [9]
> [10] 'ff.bnCancel' {quad}wi 'New' 'Button'('caption' 'Cancel')('where' 8

45)
> ('style' 2)
> ]11]
> [12] 'ff.Lb1' {quad}wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
> [13] 'ff.ED1' {quad}wi 'New' 'Edit' ('where' 5 20)
> [14] 'ff.Lb2' {quad}wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
> [15] 'ff.ED2' {quad}wi 'New' 'Edit' ('where' 10 20)
> [16]
> [17] 'ff.bnOk.Click' {quad}wi 'value'(V<-'ff.ED1'{quad}wi'text')
> [18] 'ff.ED1' {quad}wi 'text' ({Thorn}V)
> [19] 'ff.ED2' {quad}wi 'text'({Thorn}32+V󭝵)
>
> Any help would be appreciated. I am using Apl+Win 4.0
> With Thanks
> Steve
>
>




Eric Landau

2004-10-21, 3:55 pm

In article <1098362850.19508.0@spandrell.news.uk.clara.net>, "Graham
Steer" <graham@runsell.clara.co.uk> wrote:

>Your question has already been answered in coding terms. I would recommend
>as a
>matter of style you write all your handlers as functions. In your example I
>would name them Convert and Cancel. In this way having developed your form
>layout and basic functionality you can then add functionality by developing
>the handler functions without having to touch the form coding. For example
>it would be easy to make Convert go either way depending on which box your
>user input a value. You could then add error trapping if no value was
>entered. Similarly you could control what happened when you user cancels the
>form.


A minor digression regarding Graham's suggestion as to style, which is
certainly sound...

...and is undoubtedly the best way to structure a simple application
with one form, or perhaps just a few fairly simple ones.

My experience with writing complex applications with a large number of
forms, however, is that maintainability is better served by writing not
one function for each handler, but one function for each form, with the
individual handlers as :CASE statements (or the equivalent in other than
APL+Win) selected by a descriptively named argument. If those functions
are consistently named (<formname>_Handlers or the like), someone new to
the code will know in which function to find the handler for any control
on any form without even having to look at the function list.

Eric Landau, APL Solutions, Inc.
"Sacred cows make the tastiest hamburger." - Abbie Hoffman
Bj?rn Helgason

2004-10-21, 3:55 pm

www.jsoftware.com

--------------- script from J Primer
NB. base form

CFGUI=: 0 : 0
pc cfgui;
xywh 12 18 40 10;cc ccstatic static;cn "centigrade:";
xywh 56 16 40 14;cc cid edit ws_border es_autohscroll;
xywh 12 40 40 10;cc ccstatic static;cn "Fahrenheit:";
xywh 56 36 40 14;cc fid edit ws_border es_autohscroll;
pas 6 6;pcenter;
rem form end;
)

cfgui_run=: 3 : 0
wd CFGUI
NB. initialize form here
wd 'pshow;'
)

cfgui_close=: 3 : 0
wd'pclose'
)

cfgui_cid_button=: 3 : 0
t =. 0 ". cid
t =. fahrenheit t
t =. ": t
wd 'set fid *', t
)

cfgui_close_button=: 3 : 0
wd 'pclose'
)

g1=: %&1.8
g3=: -&32
g5=: g1@g3
g6=: g5^:_1

fahrenheit=:3 : 0
g5 y.
)

centigrade=:3 : 0
g6 y.
)

cfgui_fid_button=: 3 : 0
t =. 0 ". fid
t =. centigrade t
t =. ": t
wd 'set cid *', t
)

cfgui_run 0
LatLong

2004-10-26, 8:55 am

Modifying your code to make it work, here is a solution.
{del} Temp;V
[1]
[2] 'ff' #wi 'Create' 'Form'
[3] 'ff.bnOK' #wi 'New' 'Button'
[4] 'ff.bnOK' #wi 'caption' 'OK'
[5] 'ff.bnOK' #wi 'where' 2 45
[6] 'ff.bnOK' #wi 'onClick' "V{<-}#fi 'ff.ED1'#wi'text' & 'ff.ED2' #wi
'text'({format}32+V{times}9{divide}5)"
[7]
[8] 'ff.bnCancel' #wi 'New' 'Button'('caption' 'Cancel')('where' 8
45)('style' 2)
[9]
[10] 'ff.Lb1' #wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
[11] 'ff.ED1' #wi 'New' 'Edit' ('where' 5 20)
[12] 'ff.Lb2' #wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
[13] 'ff.ED2' #wi 'New' 'Edit' ('where' 10 20)
{del}

Note -your onClick handler needs to be valid code or a function that is run
when the Click event fires.



"smandula" <smandula@idirect.com> wrote in message
news:qvadnSU5NJTSuOrcRVn-pA@look.ca...
> What am I doing wrong? Small pogram to change temperature C to F
> Demonstrating, enter value into editbox1(ED1) when onclick OK
> button,converts to Farenheit,
> and places the result on editbox2(ED2). Closing the Gui is no problem
>
> [1] Temp;V
> [2]
> [3] 'ff' {quad} 'Delete'
> [4] 'ff' {quad}wi 'Create' 'Form'
> [5] 'ff.bnOK' {quad}wi 'New' 'Button'
> [6] 'ff.bnOK' {quad}wi 'caption' 'OK'
> [7] 'ff.bnOK' {quad}wi 'where' 2 45
> [8] 'ff.bnOK' {quad}wi 'onClick' 'ff.bnOK.Click'
> [9]
> [10] 'ff.bnCancel' {quad}wi 'New' 'Button'('caption' 'Cancel')('where' 8

45)
> ('style' 2)
> ]11]
> [12] 'ff.Lb1' {quad}wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
> [13] 'ff.ED1' {quad}wi 'New' 'Edit' ('where' 5 20)
> [14] 'ff.Lb2' {quad}wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
> [15] 'ff.ED2' {quad}wi 'New' 'Edit' ('where' 10 20)
> [16]
> [17] 'ff.bnOk.Click' {quad}wi 'value'(V<-'ff.ED1'{quad}wi'text')
> [18] 'ff.ED1' {quad}wi 'text' ({Thorn}V)
> [19] 'ff.ED2' {quad}wi 'text'({Thorn}32+V󭝵)
>
> Any help would be appreciated. I am using Apl+Win 4.0
> With Thanks
> Steve
>
>



Graham Steer

2004-10-26, 3:55 pm

Steve,

Your question has already been answered in coding terms. I would recommend
as a
matter of style you write all your handlers as functions. In your example I
would name them Convert and Cancel. In this way having developed your form
layout and basic functionality you can then add functionality by developing
the handler functions without having to touch the form coding. For example
it would be easy to make Convert go either way depending on which box your
user input a value. You could then add error trapping if no value was
entered. Similarly you could control what happened when you user cancels the
form.

Graham.
"smandula" <smandula@idirect.com> wrote in message
news:qvadnSU5NJTSuOrcRVn-pA@look.ca...
> What am I doing wrong? Small pogram to change temperature C to F
> Demonstrating, enter value into editbox1(ED1) when onclick OK
> button,converts to Farenheit,
> and places the result on editbox2(ED2). Closing the Gui is no problem
>
> [1] Temp;V
> [2]
> [3] 'ff' {quad} 'Delete'
> [4] 'ff' {quad}wi 'Create' 'Form'
> [5] 'ff.bnOK' {quad}wi 'New' 'Button'
> [6] 'ff.bnOK' {quad}wi 'caption' 'OK'
> [7] 'ff.bnOK' {quad}wi 'where' 2 45
> [8] 'ff.bnOK' {quad}wi 'onClick' 'ff.bnOK.Click'
> [9]
> [10] 'ff.bnCancel' {quad}wi 'New' 'Button'('caption' 'Cancel')('where' 8

45)
> ('style' 2)
> ]11]
> [12] 'ff.Lb1' {quad}wi 'New' 'Label' ('caption' 'Celsius')('where' 3 20)
> [13] 'ff.ED1' {quad}wi 'New' 'Edit' ('where' 5 20)
> [14] 'ff.Lb2' {quad}wi 'New' 'Label' ('caption' 'Farenheit')('where' 8 20)
> [15] 'ff.ED2' {quad}wi 'New' 'Edit' ('where' 10 20)
> [16]
> [17] 'ff.bnOk.Click' {quad}wi 'value'(V<-'ff.ED1'{quad}wi'text')
> [18] 'ff.ED1' {quad}wi 'text' ({Thorn}V)
> [19] 'ff.ED2' {quad}wi 'text'({Thorn}32+V󭝵)
>
> Any help would be appreciated. I am using Apl+Win 4.0
> With Thanks
> Steve
>
>




Eric Landau

2004-10-26, 3:55 pm

In article <1098362850.19508.0@spandrell.news.uk.clara.net>, "Graham
Steer" <graham@runsell.clara.co.uk> wrote:

>Your question has already been answered in coding terms. I would recommend
>as a
>matter of style you write all your handlers as functions. In your example I
>would name them Convert and Cancel. In this way having developed your form
>layout and basic functionality you can then add functionality by developing
>the handler functions without having to touch the form coding. For example
>it would be easy to make Convert go either way depending on which box your
>user input a value. You could then add error trapping if no value was
>entered. Similarly you could control what happened when you user cancels the
>form.


A minor digression regarding Graham's suggestion as to style, which is
certainly sound...

...and is undoubtedly the best way to structure a simple application
with one form, or perhaps just a few fairly simple ones.

My experience with writing complex applications with a large number of
forms, however, is that maintainability is better served by writing not
one function for each handler, but one function for each form, with the
individual handlers as :CASE statements (or the equivalent in other than
APL+Win) selected by a descriptively named argument. If those functions
are consistently named (<formname>_Handlers or the like), someone new to
the code will know in which function to find the handler for any control
on any form without even having to look at the function list.

Eric Landau, APL Solutions, Inc.
"Sacred cows make the tastiest hamburger." - Abbie Hoffman
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com