screen 0,420,32 cls 1 title "整数電卓 v0.1" gsel 0,1 sdim txt,1024 sdim m_a,256 sdim m_b,256 sdim tmp1,1024 sdim m_tmp,256 sdim siki,256 sdim m_buf,1024 sdim osiki,256 siki="0" input siki,256 pos 260,0 mes "=" pos 280,0 mesbox m_tmp,128 repeat wait 1 if osiki!=siki { txt=siki osiki=siki gosub *m_calc objprm 1,txt objsel 0 } loop stop ;//************************************************************************** ;// 計算ルーチン ;// 括弧使用可能、整数だけ *m_calc repeat strlen l,txt p=-1 pp=-1 stf=0 c=0 repeat l if c=='\\'&(oc=='\\') :c='!' oc=c peek c,txt,cnt if c=$22&(oc!'\\') :stf=(stf=0):continue if stf :continue if c='(' :p=cnt if c=')' :pp=cnt:break loop if p=-1|(pp=-1) :break strmid tmp,txt,p+1,pp-p-1 ;//Dialog tmp+"\n in "+txt peek tmp1,txt,pp+1 poke txt,p,0 gosub *m_calc_t ;dialog txt+","+tmp+","+tmp1 txt+=tmp+tmp1 loop tmp=txt gosub *m_calc_t txt=tmp peek c,txt,0 if c=$22 { strlen l,txt strmid txt,txt,1,l-2 } return *m_calc_t strlen l,tmp mf=0 mp=0 pp=0 stf=0 mc=0 m_buf="" repeat if oc='\\'&(mc='\\') :mc='!' oc=mc peek mc,tmp,cnt of=mf mf=$2f$3f { ; h_name=refs ; gosub *he_get ; str refs ; if h_typ :gosub *unconv_str ;} if pp-mp :peek c,tmp,pp-1:if c=='-' :poke m_tmp,pp-mp-1,0:poke refs,1,refs:poke refs,0,c m_buf+=m_tmp+","+refs+"\n" mp=cnt } if mc=0 :break loop ;dialog "'"+m_buf+"'\n\n"+tmp+"\nlen="+l notesel m_buf repeat 5 if cnt=0 :en="* / % " if cnt=1 :en="+ - " if cnt=2 :en="> < >= <= " if cnt=3 :en="== != " if cnt=4 :en="&& || " pp=1 notemax m_max repeat if pp>=m_max :break noteget m_tmp,pp getstr enzansi,m_tmp,0,',' if enzansi=="" :enzansi="+" instr p,en,enzansi+" " if p<0 :pp++:continue str m_a str m_b peek m_b,m_tmp,strsize peek c,m_b,0 if c==$22 { h_typ=1 strlen l,m_b strmid m_b,m_b,1,l-2 } else { h_typ=0 } noteget m_tmp,pp-1 getstr te,m_tmp,0,',' peek m_a,m_tmp,strsize peek c,m_a,0 if c==$22 { h_typ=1 strlen l,m_a strmid m_a,m_a,1,l-2 } if h_typ==0 :int m_a:int m_b if enzansi="*" :m_tmp=m_a*m_b if enzansi="/" :m_tmp=m_a/m_b if enzansi="%" :m_tmp=m_a\m_b if enzansi="+" :m_tmp=m_a+m_b :else: h_typ=0 if enzansi="-" :m_tmp=m_a-m_b if enzansi="<" :m_tmp=m_am_b if enzansi="<=" :m_tmp=m_a<=m_b if enzansi=">=" :m_tmp=m_a>=m_b if enzansi="==" :m_tmp=m_a==m_b if enzansi="!=" :m_tmp=m_a!=m_b if enzansi="&&" :m_tmp=m_a&&m_b if enzansi="||" :m_tmp=m_a||m_b ;dialog ""+m_a+" "+enzansi+" "+m_b+"="+m_tmp if h_typ :m_tmp="\""+m_tmp+"\"" :else { int m_tmp if te=="" :te=="+" ;if m_tmp<0 :if te=="-" :te="+" :else: te="" } notedel pp noteadd te+","+m_tmp,pp-1,1 m_max-- loop loop noteget tmp,0 getstr te,tmp,0,',' peek tmp,tmp,strsize if te="-" :int tmp:tmp=-tmp:str tmp return