Do I need 2 EditText Boxes in this programme ??
- Posted by Selgor Jan 27, 2011
- 1364 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 )