1. Do I need 2 EditText Boxes in this programme ??
- Posted by Selgor Jan 27, 2011
- 1451 views
Hello
Selgor here
The following programme works.
But I am wondering why I have to have 2 EditText boxes.
If I edit out EditText2
It does not allow user to enter another number thus not working
It just sits when the enter key is pressed
EditTexr2 box "back in" and it works when the enter key is pressed
If I don't need EditText2 box then how do I programme to have user enter another number
i.e. have another go ? with only i "box" ?
Any help appreciated
Cheers
Selgor
--------------------------------- NewNarA1.exw ............ work No.1. include Win32Lib.ew without warning ------------------------------------------------------------------------------- sequence seq seq = repeat(0,1000) global integer ras,tot,no_of_digits,input,a,exp,sub,work,digit ,b ras=0 tot=0 no_of_digits=0 input =0 a=0 exp=0 sub=0 work=0 digit=0 -------------------------------------------------------------------------------- global constant Window1 = create(Window,"",0,120,150,610,95,{WS_POPUP,WS_DLGFRAME}) setWindowBackColor(Window1,Parchment) -------------------------------------------------------------------------------- global constant EditText1 = createEx( EditText, "", Window1, 180, 10, 48, 20, 0, 0 ) , EditText2 = createEx( EditText, "", Window1, 180, 48, 48, 20, 0, 0 ) , LText1 = createEx( LText, "Type 3 digit Number and Enter", Window1, 5, 10, 170, 20, 0, 0 ), LText4 = createEx( LText, "IS a Narcisstic Number", Window1, 250, 50, 150, 20, 0, 0 ) , LText5 = createEx( LText, "Left Click Window to exit", Window1, 270, 70, 192, 20, 0, 0 ), LText6 = createEx( LText, "Hit Enter for another", Window1, 500, 35, 100, 20, 0, 0 ), LText7 = createEx( LText, "You entered Number -------------->> ", Window1, 5, 50, 170, 20, 0, 0 ) setFont(LText5,"Times Roman",12,Italic+Bold) procedure get_number() integer a sequence seq seq = repeat(0,1000) a=getNumber(EditText1) b=a sub = a while sub != 0 do sub = floor(sub/10) no_of_digits = no_of_digits + 1 end while for i = no_of_digits to 1 by -1 do digit = remainder(a,10) seq[i] = digit a = floor(a/10) end for exp=3 tot = 0 for i = 1 to no_of_digits do ras = power(seq[i],exp) tot = tot+ras end for setText(EditText2,b) if tot = b then setVisible(LText4,1) setVisible(LText6,1) seq = repeat(0,1000) end if end procedure -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () setVisible(LText4,0) setVisible(LText6,0) setFocus(EditText1) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure EditText1_onKeyDown (integer self, integer event, sequence params) --params is ( atom scanCode, atom shift ) if params[1]=13 then if self=EditText1 then doEvents(0) get_number() elsif self=EditText2 then setText(EditText1,"") setText(EditText2,"") setVisible(LText4,0) setVisible(LText6,0) end if end if end procedure setHandler( {EditText1,EditText2 }, w32HKeyDown, routine_id("EditText1_onKeyDown")) ------------------------------------------------------------------------------------------- procedure CloseApp ( integer self, integer event, sequence parms ) if self = Window1 then closeWindow(Window1) closeApp() end if end procedure setHandler(Window1, w32HClick, routine_id("CloseApp")) --------------------------------------------------------------------------------------------- WinMain( Window1,Normal )
2. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by dcole Jan 27, 2011
- 1341 views
Hello
Selgor here
The following programme works.
But I am wondering why I have to have 2 EditText boxes.
If I edit out EditText2
It does not allow user to enter another number thus not working
It just sits when the enter key is pressed
EditTexr2 box "back in" and it works when the enter key is pressed
If I don't need EditText2 box then how do I programme to have user enter another number
i.e. have another go ? with only i "box" ?
Any help appreciated
Cheers
Selgor
--------------------------------- NewNarA1.exw ............ work No.1. include Win32Lib.ew without warning ------------------------------------------------------------------------------- sequence seq seq = repeat(0,1000) global integer ras,tot,no_of_digits,input,a,exp,sub,work,digit ,b ras=0 tot=0 no_of_digits=0 input =0 a=0 exp=0 sub=0 work=0 digit=0 -------------------------------------------------------------------------------- global constant Window1 = create(Window,"",0,120,150,610,95,{WS_POPUP,WS_DLGFRAME}) setWindowBackColor(Window1,Parchment) -------------------------------------------------------------------------------- global constant EditText1 = createEx( EditText, "", Window1, 180, 10, 48, 20, 0, 0 ) , EditText2 = createEx( EditText, "", Window1, 180, 48, 48, 20, 0, 0 ) , LText1 = createEx( LText, "Type 3 digit Number and Enter", Window1, 5, 10, 170, 20, 0, 0 ), LText4 = createEx( LText, "IS a Narcisstic Number", Window1, 250, 50, 150, 20, 0, 0 ) , LText5 = createEx( LText, "Left Click Window to exit", Window1, 270, 70, 192, 20, 0, 0 ), LText6 = createEx( LText, "Hit Enter for another", Window1, 500, 35, 100, 20, 0, 0 ), LText7 = createEx( LText, "You entered Number -------------->> ", Window1, 5, 50, 170, 20, 0, 0 ) setFont(LText5,"Times Roman",12,Italic+Bold) procedure get_number() integer a sequence seq seq = repeat(0,1000) a=getNumber(EditText1) b=a sub = a while sub != 0 do sub = floor(sub/10) no_of_digits = no_of_digits + 1 end while for i = no_of_digits to 1 by -1 do digit = remainder(a,10) seq[i] = digit a = floor(a/10) end for exp=3 tot = 0 for i = 1 to no_of_digits do ras = power(seq[i],exp) tot = tot+ras end for setText(EditText2,b) if tot = b then setVisible(LText4,1) setVisible(LText6,1) seq = repeat(0,1000) end if end procedure -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () setVisible(LText4,0) setVisible(LText6,0) setFocus(EditText1) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure EditText1_onKeyDown (integer self, integer event, sequence params) --params is ( atom scanCode, atom shift ) if params[1]=13 then if self=EditText1 then doEvents(0) get_number() elsif self=EditText2 then setText(EditText1,"") setText(EditText2,"") setVisible(LText4,0) setVisible(LText6,0) end if end if end procedure setHandler( {EditText1,EditText2 }, w32HKeyDown, routine_id("EditText1_onKeyDown")) ------------------------------------------------------------------------------------------- procedure CloseApp ( integer self, integer event, sequence parms ) if self = Window1 then closeWindow(Window1) closeApp() end if end procedure setHandler(Window1, w32HClick, routine_id("CloseApp")) --------------------------------------------------------------------------------------------- WinMain( Window1,Normal )
`
3. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by dcole Jan 27, 2011
- 1355 views
Sorry Selgor,
The my last post got sent before I was ready to semd it.
I don't know why you want to only use one EditText?
What I did was use 2 EditTexts but fooled the user into thinking there is only one.
Don Cole
4. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by dcole Jan 27, 2011
- 1336 views
Sorry again ignore the first post.
--------------------------------- NewNarA1.exw ............ work No.1. include Win32Lib.ew without warning ------------------------------------------------------------------------------- sequence seq seq = repeat(0,1000) global integer ras,tot,no_of_digits,input,a,exp,sub,work,digit ,b ras=0 tot=0 no_of_digits=0 input =0 a=0 exp=0 sub=0 work=0 digit=0 -------------------------------------------------------------------------------- global constant Window1 = create(Window,"",0,120,150,610,95,{WS_POPUP,WS_DLGFRAME}) setWindowBackColor(Window1,Parchment) -------------------------------------------------------------------------------- global constant EditText1 = createEx( EditText, "", Window1, 180, 28, 48, 20, 0, 0 ) , --note change here EditText2 = createEx( EditText, "", Window1, 180, 28, 48, 20, 0, 0 ) , LText1 = createEx( LText, "Type 3 digit Number and Enter", Window1, 5, 30, 170, 20, 0, 0 ), -- LText4 = createEx( LText, "IS a Narcisstic Number", Window1, 250, 50, 150, 20, 0, 0 ) , LText5 = createEx( LText, "Left Click Window to exit", Window1, 270, 70, 192, 20, 0, 0 ), LText6 = createEx( LText, "Hit Enter for another", Window1, 500, 35, 100, 30, 0, 0 ), LText7 = createEx( LText, "You entered Number -------------->> ", Window1, 5, 30, 170, 20, 0, 0 )-- setFont(LText5,"Times Roman",12,Italic+Bold) procedure get_number() integer a sequence seq seq = repeat(0,1000) a=getNumber(EditText1) b=a sub = a while sub != 0 do sub = floor(sub/10) no_of_digits = no_of_digits + 1 end while for i = no_of_digits to 1 by -1 do digit = remainder(a,10) seq[i] = digit a = floor(a/10) end for exp=3 tot = 0 for i = 1 to no_of_digits do ras = power(seq[i],exp) tot = tot+ras end for setText(EditText2,b) if tot = b then setVisible(LText4,1) setVisible(LText6,1) seq = repeat(0,1000) end if end procedure -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () setVisible(LText4,0) setVisible(LText7,0) setVisible(LText6,0) setFocus(EditText1) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure EditTextBoth_onKeyDown (integer self, integer event, sequence params) --params is ( atom scanCode, atom shift ) ? if params[1]=13 then if self=EditText1 then doEvents(0) get_number() setVisible({EditText1,LText1},0) setVisible({LText7,LText5,LText6},1) elsif self=EditText2 then setText(EditText1,"") setText(EditText2,"") setVisible({LText4,LText6,LText7},0) setVisible({EditText1,LText1},1) end if end if end procedure setHandler( {EditText1,EditText2 }, w32HKeyDown, routine_id("EditTextBoth_onKeyDown")) ------------------------------------------------------------------------------------------- procedure CloseApp ( integer self, integer event, sequence parms ) if self = Window1 then closeWindow(Window1) closeApp() end if end procedure setHandler(Window1, w32HClick, routine_id("CloseApp")) --------------------------------------------------------------------------------------------- WinMain( Window1,Normal )
5. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by Selgor Jan 27, 2011
- 1343 views
Hello
Selgor here
Hi Don
This is a new programme
User enters a number
Code sees if it is a narcisstic number
Answers it is or not
Then allows user to enter another number
clearing all previous "stuff" out
But it won't work with 1 Edit box
It is not the greatest common denominator programme you helped with
Or are you saying to enter only 1 number there must be 2 edit boxes
Do you need more clarification ??
Or am I being a "purist" programmer ?
I cannot see why I need 2 boxes ??
But it works well
as it stands
And I have written more to allow up to a 6 number input
And all is fine
So ........ leave it and forget it ??
And move to my 11th programme update
Thank you my friend
Really appreciate your help and post
Cheers
Selgor
6. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by Selgor Jan 27, 2011
- 1332 views
Hello
Selgor here
Don
I think we were at cross links
You were writing your post and at the same time I was replying to your first post
Anyway
your second programme solves my dilemma I do not have to have to have 2 boxes
Yes the programme works with just 1 box
You are a champion
Your code works perfectly
U R brilliant
Don't deny it
Many thanks
cheers
Selgor
7. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by DerekParnell (admin) Jan 27, 2011
- 1328 views
The following programme works.
But I am wondering why I have to have 2 EditText boxes.
You do not have to have two edit boxes. I don't know why you think you do.
Try this code ...
--------------------------------- NewNarA1.exw ............ work No.1. include Win32Lib.ew without warning ------------------------------------------------------------------------------- sequence seq seq = repeat(0,1000) global integer ras,tot,no_of_digits,input,a,exp,sub,work,digit ,b ras=0 tot=0 no_of_digits=0 input =0 a=0 exp=0 sub=0 work=0 digit=0 -------------------------------------------------------------------------------- global constant Window1 = create(Window,"",0,120,150,610,95,{WS_POPUP,WS_DLGFRAME}) setWindowBackColor(Window1,Parchment) -------------------------------------------------------------------------------- global constant EditText1 = createEx( EditText, "", Window1, 180, 10, 48, 20, 0, 0 ) , UserNumber = createEx( LText, "", Window1, 180, 48, 48, 20, 0, 0 ) , LText1 = createEx( LText, "Type 3 digit Number and Enter", Window1, 5, 10, 170, 20, 0, 0 ), LText4 = createEx( LText, "IS a Narcisstic Number", Window1, 250, 50, 150, 20, 0, 0 ) , LText5 = createEx( LText, "Left Click Window to exit", Window1, 270, 70, 192, 20, 0, 0 ), LText6 = createEx( LText, "Hit Enter for another", Window1, 500, 35, 100, 20, 0, 0 ), LText7 = createEx( LText, "You entered Number -------------->> ", Window1, 5, 50, 170, 20, 0, 0 ) setFont(LText5,"Times Roman",12,Italic+Bold) procedure get_number() integer a sequence seq seq = repeat(0,1000) a=getNumber(EditText1) if a >= 0 and a <= 999 then b=a sub = a while sub != 0 do sub = floor(sub/10) no_of_digits = no_of_digits + 1 end while for i = no_of_digits to 1 by -1 do digit = remainder(a,10) seq[i] = digit a = floor(a/10) end for exp=3 tot = 0 for i = 1 to no_of_digits do ras = power(seq[i],exp) tot = tot+ras end for setText(UserNumber,b) if tot = b then setVisible(LText4,1) setVisible(LText6,1) seq = repeat(0,1000) end if end if -- Clear out whatever user had entered. setText(EditText1, "") end procedure -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () setVisible(LText4,0) setVisible(LText6,0) setFocus(EditText1) end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure EditText1_onKeyDown (integer self, integer event, sequence params) --params is ( atom scanCode, atom shift ) setVisible(LText4, 0) -- Hide 'Narcisstic' messages setVisible(LText6, 0) if params[1] = VK_RETURN then get_number() end if end procedure setHandler( EditText1, w32HKeyDown, routine_id("EditText1_onKeyDown")) ------------------------------------------------------------------------------------------- procedure CloseApp ( integer self, integer event, sequence parms ) closeWindow(Window1) closeApp() end procedure setHandler(Window1, w32HClick, routine_id("CloseApp")) --------------------------------------------------------------------------------------------- WinMain( Window1,Normal )
8. Re: Do I need 2 EditText Boxes in this programme ??
- Posted by Selgor Jan 27, 2011
- 1325 views
Hello
Selgor here
Thank you once again Derek
I just could not make it work without 2 boxes
I do no t have the skills yet
But with all your help and of course Don Cole too
I am learning
Yes U 2 R brilliant
Heaps of thanks
Sets me up to fix the next 20 odd old code programmes
Cheers
Selgor