Last Day to Bring HTML5 to Livecode - $300,425 pledged of $395,000 target Get Involved >

Over the last few years, more information has been emerging in the media, contrasting differences in education practices between Asian and Western parents and guardians, with books being published and reports appearing in prestigious journals. I do not intend to poke around in a bees nest here and will leave judgement on child education to the respective parents and guardians.

What I do offer is an insight into how LiveCode can assist would be Tiger Mothers, parents and guardians who would like to raise their children’s mental maths ability and self-esteem.

In most societies, mathematics is part of an educational curriculum and there are a number of tested and proven approaches to teach this and encourage sprogs to enjoy their learning. However, especially when it comes to learning the basics of manipulating numbers and using mathematical operators, you may come across a degree of resistance.

Maybe this is because a certain games console is being neglected or there is a lack in agreement on the importance of being able to add a couple of numbers together. On the other hand you may find yourself with a child who is just purely bored with the level of mathematics offered at school and requires more challenging content. And no, the latter kind of children are not just fabled beings, they do actually exist and can be a challenge to work with.

There are of course applications that teach maths, and there are text books that have problems upon problems your kids are encouraged to indulge in. These tools are limited by what the application designers consider appropriate or by the number of equations one can squeeze on the page of a textbook. As most parents/guardians will know, children develop at different speeds, and motivation can be a balancing act between joy and tantrums.

This is where LiveCode comes in. Properly applied, LiveCode can help you emerge victorious from any battle and empower you to generate an endless numbers of equations that are at the right level for your child.

And of course the answers are also provided, allowing you to keep your street cred. Children have a miraculous tendency to remember events where you display any sign of weakness, and they utilize this knowledge to maximize their advantage in the next round of homework activities.

The code in this blog is a mathematical problem generator that can be placed in the script of a button control and modified at will. There is no woolliness in the code, only functionality that serves the purpose of generating equations for endless fun at learning.

You can of course modify the code to create your own stack that populates the configuration information with the appropriate variables and outputs the problems in a more interactive fashion. If you are really adventurous, why not ask your child to update the code for you, teaching them to build their own learning aids.

I have added comments after the lines of code that are intended to be updated. These lines set variable values that control how the problems are generated:

1. tOperators stores a list of operators that should be used in the equations.

2. tInputRange1 defines the range of the first number in the equations.

3. tInputRange2 defines the range of the second number in the equations.

4. tOutputRange specifies the range of valid result values.

5. tAllowReal is a flag that determines whether or not the output can be a floating point number.

6. tProblemCount defines the maximum number of equations that are to be generated.

on mouseUp local tOperators, tInputRange1, tInputRange2, tOutputRange, tProblemCount, tAllowReal local tProblems, tProblemIndex, tEquation, tOperator, tVariable1, tVariable2, tResult // Parameters to be updated. put "+,-,*,/" into tOperators // The operators that are used in the equations. put "-50,50" into tInputRange1 // The range of the first number in the equations. put "1,100" into tInputRange2 // The range of the second number in the equations. put "-500,500" into tOutputRange // The permissible result range. put false into tAllowReal // Are the results allowed to have floating point values (true/false). put "20" into tProblemCount // The number of problems to generate. put empty into tProblems repeat with tProblemIndex = 1 to tProblemCount put item random (number of items in tOperators) of tOperators into tOperator repeat with tTestValidity = 1 to 100 put random (item 2 of tInputRange1 - item 1 of tInputRange1 + 1) + item 1 of tInputRange1 -1 into tVariable1 put random (item 2 of tInputRange2 - item 1 of tInputRange2 + 1) + item 1 of tInputRange2 -1 into tVariable2 // Do a bit of testing to ensure we do not violate some fundamental rules. if tOperator is "/" and tVariable is 2 then next repeat do "do" && quote & "put" && tVariable1 && tOperator && tVariable2 && "into tResult" & quote // Test if the answer is allowed to contain floating point results. if tAllowReal is false and tResult is not an integer then next repeat // Test if the answer is within the specified range. if tResult item 2 of tOutputRange then next repeat put tVariable1 & tab & tOperator & tab & tVariable2 & tab & "=" & tab & tab & tab & tResult into tEquation // Check that we do not already have the new equation we generated. if tEquation is among the lines of tProblems then next repeat put tEquation & return after tProblems exit repeat end repeat end repeat put tProblems into msg end mouseUp

The default settings, as shown in this code, were used to generate the output shown in the attached image. The output is written directly into the message box. This output can be copied and pasted into other applications for printing or other manipulation. I left a larger gap between the problems and the results. This allows the results to be covered up when the problems are being solved and revealed when the answers are being checked.

krHi Hanson,

This line creates an error:

if tResult item 2 of tOutputRange then next repeat

maybe it should be:

if tResult = item 2 of tOutputRange then next repeat

k

HansonHi kr,

you are right, there is an issue in the code and it looks like “” got filtered out during editing or its being rejected because HTML thinks this is tagged content. I will have the issue addressed in the code example. In the meantime, this is what should be in the code:

if tResult item 2 of tOutputRange then next repeat

Kind Regards,

Hanson