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