calculator program... simple to input by Sven B13th Mar 2005 12:29
|
---|
Summary i sticked to +,-,* and /. My next step is adding buttons... Description notting to say... Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `****************************************************** ` calculator `****************************************************** sync on restart: a$="" s=0 do cls a$=a$+returnnr() if scancode()=14 then a$="" text 50,50,a$ if returnkey()=1 then goto calc sync loop calc: for x=1 to len(a$) if mid$(a$,x)="/" or mid$(a$,x)="*" or mid$(a$,x)="-" or mid$(a$,x)="+" for i=1 to x-1 a=a*10+val(mid$(a$,i)) next i for i=x+1 to len(a$) b=b*10+val(mid$(a$,i)) next i goto calc2 endif next x calc2: if mid$(a$,x)="/" then c=a/b if mid$(a$,x)="*" then c=a*b if mid$(a$,x)="+" then c=a+b if mid$(a$,x)="-" then c=a-b print c repeat sync until returnkey()=0 suspend for key goto restart `functions function returnnr() a$="" if hold=0 if inkey$()="1" then a$="1" : hold=1 if inkey$()="2" then a$="2" : hold=1 if inkey$()="3" then a$="3" : hold=1 if inkey$()="4" then a$="4" : hold=1 if inkey$()="5" then a$="5" : hold=1 if inkey$()="6" then a$="6" : hold=1 if inkey$()="7" then a$="7" : hold=1 if inkey$()="8" then a$="8" : hold=1 if inkey$()="9" then a$="9" : hold=1 if inkey$()="0" then a$="0" : hold=1 if s=0 if inkey$()="*" then a$="*" : hold=1 : s=1 if inkey$()="-" then a$="-" : hold=1 : s=1 if inkey$()="/" then a$="/" : hold=1 : s=1 if inkey$()="+" then a$="+" : hold=1 : s=1 endif endif if scancode()=0 then hold=0 endfunction a$ |