PROC m:
GLOBAL a$(10),s$(10),t$(25),u$(25),v$(25)
STATUSWIN ON
FONT 12,0
gAT RND*gWIDTH,RND*gHEIGHT
 DO
   IF i:
    c:
   ELSE
    a$="" :s$="" :t$="" :u$="" :v$=""
   ENDIF
  gLINETO RND*gWIDTH,RND*gHEIGHT
 UNTIL 0
ENDP

PROC i:
LOCAL d%
dINIT
dTEXT "","Uniform acceleration: enter 3 values",$302
dEDIT a$,"Acceleration (a) ms-ý"
dEDIT s$,"Displacement (s) m"
dEDIT t$,"Time (t) s"
dEDIT u$,"Initial velocity (u) ms-û"
dEDIT v$,"Final velocity (v) ms-û"
dBUTTONS "Exit",-27,"Clear all",-9,"Calculate",13
d%=DIALOG
IF d%=0 :STOP :ENDIF
RETURN (d%=13)
ENDP

PROC c:
LOCAL a,s,t,u,v,t%,u1,u2,v1,v2,t1,t2

ONERR error1
IF a$<>"" :a=EVAL(a$) :ENDIF
IF s$<>"" :s=EVAL(s$) :ENDIF
IF t$<>"" :t=EVAL(t$) :ENDIF
IF u$<>"" :u=EVAL(u$) :ENDIF
IF v$<>"" :v=EVAL(v$) :ENDIF
ONERR OFF

t%=-(a$<>"")*10000-(s$<>"")*1000-(t$<>"")*100-(u$<>"")*10-(v$<>"")

ONERR error2
IF t%=00111 :s=0.5*(u+v)*t :a=(v-u)/t
ELSEIF t%=01011 :t=s/(0.5*(u+v)) :a=(v-u)/t
ELSEIF t%=01101 :u=(2*s)/t-v :a=(v-u)/t
ELSEIF t%=01110 :v=(2*s)/t-u :a=(v-u)/t
ELSEIF t%=10011 :t=(v-u)/a :s=0.5*(u+v)*t
ELSEIF t%=10101 :u=v-a*t :s=0.5*(u+v)*t
ELSEIF t%=10110 :v=u+a*t :s=0.5*(u+v)*t
ELSEIF t%=11001 :u1=SQR(v*v-2*a*s) :t1=(v-u1)/a :u2=-u1 :t2=(v-u2)/a :u=&7fffffff
ELSEIF t%=11010 :v1=SQR(u*u+2*a*s) :t1=(v1-u)/a :v2=-v1 :t2=(v2-u)/a :v=&7fffffff
ELSEIF t%=11100 :u=(s-0.5*a*t*t)/t :v=u+a*t
ELSE ONERR OFF :GIPRINT "Enter 3 values!",1 :RETURN
ENDIF
ONERR OFF

a$=GEN$(a,10)
s$=GEN$(s,10)
 IF u=&7fffffff OR v=&7fffffff
  t$=GEN$(t1,10)+" or "+GEN$(t2,10)
 ELSE
  t$=GEN$(t,10)
 ENDIF
 IF u=&7fffffff
  u$=GEN$(u1,10)+" or "+GEN$(u2,10)
 ELSE
  u$=GEN$(u,10)
 ENDIF
 IF v=&7fffffff
  v$=GEN$(v1,10)+" or "+GEN$(v2,10)
 ELSE
  v$=GEN$(v,10)
 ENDIF
RETURN

error1::
ONERR OFF
GIPRINT "Entry error: "+ERR$(ERR),1
RETURN
error2::
ONERR OFF
GIPRINT "Calculation error: "+ERR$(ERR),1
RETURN
ENDP
