Zoho Creator: Build an online calculator tutorial. #1: Preparation
A good preparation is half the work!
Elements in the calculator
There are multiple ways to get this done, but the easiest way is to create one form for the user to use to calculate the molecular weight, and another form in which to store the background data:
- The background data will consist of the data needed to calculate: the symbols and atomic mass of the elements.
- The user form needs two input fields (for the chemical formula and the substance weight), a subform to show the results per element, and a field to show the molecular weight of the molecule.
What does the calculator need to do in the backend?
A chemical formula can consist of:
- Letters, representing the elements, grouped in sets of one, two, or three, starting with a capital letter.
- Parentheses, signifying a chemical group within the molecule.
- A dot to start a hydration group.
- Numbers, multiplying the element, chemical group in parenthesis or the hydration group.
For the program to convert the user input (the chemical formula) into a molecular weight, it needs to be able to:
- Identify the elements present in the molecule.
- Recognise what the parentheses mean.
- Recognise what the dot means.
- Recognise what the numbers mean.
- Use all of the above to count the elements.
- Multiply the found elements with the atomic mass of those elements.
Most of this will be done with Deluge code. Only storing the data of the elements will be done in a separate form, so that we can use Deluge to fetch the needed data when calculating.