okay I tried this... if ans$ = sum then beep: print "Correct!" but it gives a error bad factor in expression On Jul 22, 2009, at 7:53 PM, Brian Heibert wrote: > I was experimenting with the FBtoC passthrough function > so far I got this... (see below) > > My question is how do I go about finding out what the math question > was > and tell if the user answer is correct or not? > > Brian > > > #if def _PASSTHROUGHFUNCTION > #import <stdio.h> > #include <Carbon/Carbon.h> > #endif > > toolbox fn IsMenuBarVisible = Boolean > toolbox ShowMenuBar > toolbox HideMenuBar > HideMenuBar > > #if def _PASSTHROUGHFUNCTION > long add (long a, long b) > { > long sum; > sum = a + b; > return (sum); > } > #endif > > #if def _PASSTHROUGHFUNCTION > long subtract (long c, long d) > { > long sum1; > sum1 = c-d; > return (sum1); > } > #endif > > #if def _PASSTHROUGHFUNCTION > long multiply (long e, long f) > { > long sum2; > sum2 = e*f; > return (sum2); > } > #endif > > > #if def _PASSTHROUGHFUNCTION > long divide (long g, long h) > { > long sum3; > sum3 = g*h; > return (sum3); > } > #endif > > toolbox fn add (long a, long b) = long > toolbox fn subtract (long c, long d) = long > toolbox fn multiply (long e, long f) = long > toolbox fn divide (long g, long h) = long > > _mathmasterplus = 1 > > local fn Buildmathmasterplus > '~'1 > dim as Rect r > dim as RGBColor rgb > dim as WindowAttributes wa > > wa = _kWindowCompositingAttribute > > rgb.red = 0 > rgb.green = 0 > rgb.blue = 0 > > dim sw as long,sh as long > sw = system(_scrnWidth) > sh = system(_scrnHeight) > > //SetRect( r, 0, 0, 480, 360 )// Optional FB auto-centre > SetRect( r, 0, 0, sw, sh ) > appearance window -_mathmasterplus, "MathMaster Plus", @r, > _kPlainWindowClass, wa > def SetWindowBackground( rgb, _zTrue ) > > > window _mathmasterplus > end fn > > dim rnd1 as integer,rnd2 as integer > rnd1 = INT(RND(20)) > rnd2 = INT(RND(9)) > > fn Buildmathmasterplus > color=_zWhite > TEXT _Geneva,24,0 > print @(20,5), ("Welcome to MathMaster Plus") > TEXT _Geneva,50,0 > print @(20,5) rnd1; > print " + "; > print @(24,5) rnd2; > print " = "; > dim ans$ > TEXT _Geneva,24,0 > input "";ans$ > > print fn add (rnd1,rnd2) > > > //if ans$ = rnd1+VALrnd2 then print @(30,5), ("Correct!") > > do > HandleEvents > until ( gFBQuit ) > ShowMenuBar > #if def _PASSTHROUGHFUNCTION > #import <stdio.h> > #include <Carbon/Carbon.h> > #endif > > toolbox fn IsMenuBarVisible = Boolean > toolbox ShowMenuBar > toolbox HideMenuBar > HideMenuBar > > #if def _PASSTHROUGHFUNCTION > long add (long a, long b) > { > long sum; > sum = a + b; > return (sum); > } > #endif > > #if def _PASSTHROUGHFUNCTION > long subtract (long c, long d) > { > long sum1; > sum1 = c-d; > return (sum1); > } > #endif > > #if def _PASSTHROUGHFUNCTION > long multiply (long e, long f) > { > long sum2; > sum2 = e*f; > return (sum2); > } > #endif > > > #if def _PASSTHROUGHFUNCTION > long divide (long g, long h) > { > long sum3; > sum3 = g*h; > return (sum3); > } > #endif > > toolbox fn add (long a, long b) = long > toolbox fn subtract (long c, long d) = long > toolbox fn multiply (long e, long f) = long > toolbox fn divide (long g, long h) = long > > _mathmasterplus = 1 > > local fn Buildmathmasterplus > '~'1 > dim as Rect r > dim as RGBColor rgb > dim as WindowAttributes wa > > wa = _kWindowCompositingAttribute > > rgb.red = 0 > rgb.green = 0 > rgb.blue = 0 > > dim sw as long,sh as long > sw = system(_scrnWidth) > sh = system(_scrnHeight) > > //SetRect( r, 0, 0, 480, 360 )// Optional FB auto-centre > SetRect( r, 0, 0, sw, sh ) > appearance window -_mathmasterplus, "MathMaster Plus", @r, > _kPlainWindowClass, wa > def SetWindowBackground( rgb, _zTrue ) > > > window _mathmasterplus > end fn > > dim rnd1 as integer,rnd2 as integer > rnd1 = INT(RND(20)) > rnd2 = INT(RND(9)) > > fn Buildmathmasterplus > color=_zWhite > TEXT _Geneva,24,0 > print @(20,5), ("Welcome to MathMaster Plus") > TEXT _Geneva,50,0 > print @(20,5) rnd1; > print " + "; > print @(24,5) rnd2; > print " = "; > dim ans$ > TEXT _Geneva,24,0 > input "";ans$ > > print fn add (rnd1,rnd2) > > > //if ans$ = rnd1+VALrnd2 then print @(30,5), ("Correct!") > > do > HandleEvents > until ( gFBQuit ) > ShowMenuBar > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@... >