Arithmetic tag tutorial

Parent Category: Mad Blanks Information Category: Score Script Tags Tutorials
Created on Wednesday, 11 November 2009 Last Updated on Wednesday, 11 November 2009 Published Date Written by Chris Hallett

The arithmetic tag looks like this:

[:arithmetic:{1st operand}:operator:{2nd operand}:]

You can use the following operators: + - * / %

  • + is for addition
  • - is for subtraction
  • * is for multiplication
  • / is for division
  • % is the modulo operator, which gives the remainder of a division operation (the modulus); one use for this is to tell if a number is evenly divisible by a certain number

Usage Example: [:arithmetic:{2}:+:{3}:] will show up in the Score Script output as 5.

The operands can include other Score Script tags.

Usage Example: [:arithmetic:{[:info:1:user_response:]}:*:{2}:] will multiply a number the website user entered for field #1 times two and display the output.

The arithmetic tag only supports two operands.

The workaround if you need to add or multiply more than two things together is to use expressions and then add or multiply the expressions together:



This will show up in the Score Script output as 20. Note again that you can also use other Score Script tags as operands.

If the user puts in four numbers for fields 1 through 4 you could do something like the following to add them all together:




Usage example: [:arithmetic:{[:info:5:user_response:]}:%:{2}:] will be 0 if a number the website user entered for field #5 is even (evenly divisible by two), or 1 if a number the website user entered for field #5 is odd (not evenly divisible by two).

See the linked survey to see an example of this.

This is the official website for Mad Blanks, a component written for Joomla!™

Mad Blanks, when used with Joomla!™, will allow you to give a quiz on your site. You can also use it to give a survey. Quizzes and surveys are popular applications on the Internet, including personality quizzes, name generators, and assessments.

This website and the featured software products herein written for Joomla!™ are the property of Chris Hallett, an independent programmer. Chris does not represent Open Source Matters, Inc. nor the Joomla!™ project.

Mad Blanks, Mad Current Event, and Mad Simple True False Quiz are licensed under the GNU General Public License (GPL) version 2. | Mad Blanks - Quiz, survey, assessment, calculator, general purpose form

Terms & Conditions | Privacy Policy | Contact Us | © 2015 Chris Hallett

Monday the 30th. Joomla Templates Free.