## Calculations

#### Tables

##### Mini-spreadsheets

Blockpad supports tables that act like mini-spreadsheets inside of a document. You can use normal Blockpad formulas in the table, and reference values back and forth between the table and report.

###### Insert a mini-spreadsheet table:

- While in a document, click the
*Insert Table*button in the toolbar. - Click OK.

You can use all of the Blockpad formula features inside of a table, including units, naming values, and creating functions.

To reference values in the table, you can use clicking like in a spreadsheet or any other referencing method. Notice the table name appears in front of the value. This is because a table is a frame that contains values.

You can change a table's name so that a useful name appears in the formula.

- Select the table by clicking on the label.
- Open the properties window.
- Under
*Object*, click*Name*. - Type in the new name.
- Press enter.

Referencing works both ways. You can reference document values from inside a table too.

##### Multiline cells

You can also have a word processor style table cell, called a multiline cell. Multiline cells act a lot like a document, so you can do all the same things, like format text, equations with math notation, and more.

###### Change a cell to multiline:

- Select the cell or cells.
- In the toolbar, change
*Value Cell*to*Multiline*.

(To change a cell width, you can use the properties window or
show rulers (*View*>*Show Rulers*) and drag the borders of the ruler.)

A multiline cell is considered to be a frame, like a table. You don't need to specify the name in front of references because capture values is set to no by default.

##### Word processor tables

In a report, you may often want all of the cells in a table to be multiline. Do this automatically by selecting word processing mode when you insert a table.

###### Insert a word processor style table:

- While in a document, click the
*Insert Table*button in the toolbar. - In the window that appears, change
*Mode*to*Word Processing Mode*. - Click OK.

#### Fields

Fields act like spreadsheet cells, but in a document. You can have formulas in them like a dynamic equation, but the formatting is more similar to a spreadsheet cell.

##### Dropdown lists

You can use fields to make a dropdown list so that people using the document can only choose from a pre-set list of options.

###### Create a dropdown list in a report:

- Insert a field using the field button in the toolbar or the insert button.
- Select the field and open the properties window.
- If desired, name the field by editing the
*Name*property. - This is the name that will be used in calculations.
- In the properties window, select the
*Value Definition*property, near the bottom under*Style*. - In the window that appears, select
*From Option List*in the dropdown. - Enter a formula that results in an array.
- The items in that array will be the the dropdown list options.
- You can type in an array directly, reference a named array, or reference a group of cells.
- Often it's best to create an array in the document, and then reference it in this window.
- Click OK.

You can also follow the steps above to create a dropdown list in a spreadsheet cell.

#### Functions

In Blockpad, you can use functions inside of formulas/dynamic equations, just like in a spreadsheet. There are a lot of built in functions, but it's also easy to make your own functions.

##### Built-in functions

Built-in functions are stored in the Blockpad library, but using them is as simple as typing them in, like a normal spreadsheet. You can view all of the built in functions through the math, text, logic, and lookup libraries.

There are basic math functions.

Functions will track units.

Functions that require angles are unit sensitive.

There are logical functions.

The expression above uses the if() function. It's shown in the display form.

*A quick note on logical functions: to test if something is equal, a double equals sign is used (==).*

There are also text functions and lookup functions for use with spreadsheets and tables.

##### Create your own function

Custom functions are simple and accessible in Blockpad - you can create them in a normal formula and use them throughout a document.

You can also save functions to a library and use them in different files or share them with colleagues.

###### Defining custom functions

To define a function, specify the function name, the function variables, and the calculation. Let's look at the sample below.

In the first dynamic equation, "hypotenuse" is the function name, "A" and "B" are the function variables, and Sqrt(A^2 + B^2) is the calculation. Now hypotenuse() is defined as a function, and you can use it in calculations. In the second equation, hypotenuse is used as a function and calculates the inputs 3 ft and 5 ft.

###### Create your own function

- Type in the function name.
- Type in open and closed parentheses.
- Inside of the parentheses, type in the function variables.
- Variables are separated by a comma.
- Variables are in the order that you will select them when using the function later.
- Type an equals sign.
- Type the function calculation like any other calculation, but use the function variables where you want them.

You can also think of making a function in terms of calculating a value.

First, write out the formula as if you were calculating a single value. Then, replace change the value or values in the formula to parameters by renaming them and putting them in parentheses after the name.

Using a defined function is very similar to referencing a value: clicking, copy reference, or typing the name in all work. Then proceed like a normal built-in function, with parentheses and values for the function variables.

You can use values in the document to help define a function, just make sure the names don't conflict with the parameter names.

In the example below, the density value is part of the function. If you change the density, then it changes the function and thus the output as well.

You can also use your own defined functions inside of a custom function.

This makes sense to do if a function you're writing starts to get too long. You can write part of it in one function, then use that function in the final one.

A few things to remember:

- Function names and function variable names follow the same rules as value names (can't start with a number, etc.).
- Function variable names are local to the function. So, you can use that same name for a value outside of the function, and it won't relate in any way to the function.
- Functions are stored in Blockpad very similarly to values (functions are actually considered to be "values"). So, referencing values and using a defined function are very similar.

##### In-line functions

There is another way to define a function, without giving it a name.

To do so, type the function variables in parentheses, an equals sign with a greater than sign, and then the calculation. To use this function, you can use copy reference or clicking and Blockpad will auto-generate a name. For single variable functions, the parentheses can be dropped.

You can define functions like this in a spreadsheet cell, and then reference the cell to use the function. Using a function like this can feel a little funny. It's not particularly recommended, but it's mentioned here for understanding.

You can also name functions while defining them like this. Just type the name and equals sign before the in-line function, like you are naming a value.

#### Equation solving

##### Solver sections

Solver sections make solving systems of equations straight forward. Check out the video on solver sections or learn more in sections.

###### Insert a solver section:

- Select the solver button in the toolbar.

To use a solver section, type in dynamic equations that use new variables. You can reference already named values like normal. When there's enough information to solve for the variables, the answers appear at the bottom. You can reference these answers the same way you reference other values in a document.

#### That's enough to get started with calculations

Feel free to move on to spreadsheets, or continue to learn more calculation features.

#### Table of Contents

- Spreadsheet in a file
- Sort and filter
- Conditional formatting
- Blockpad specific features
- Open a CSV file
- Mini-spreadsheets in a document

- Reports in a file
- Reference values from other reports in a file
- Header and footer
- Misc. document formatting

- Drawing inside a document or file
- Drawing objects
- Lines, points, and shapes
- Text labels
- Linear dimension labels
- Textboxes
- Images
- Selecting multiple objects
- Ordering objects
- Using the point snapping
- Points you can snap to
- Horizontal and vertical from points
- Parallel or perpendicular lines
- Point snap options
- Transformations - resizing and moving
- Format drawings
- Keyboard input and canvas scales

- Top level frames
- Frames in Frames
- Value containers and location
- Frames and sections are containers
- Containers inside containers
- Dot notation to specify a value in a container
- Capture values

- What is a block?
- Block example
- Use the block results
- Block inputs
- View block as table
- Block instances and block definitions
- More examples
- Create a block
- When to make a block
- Make a block with Blockpad calculations
- Update a block definition
- Create a block using scripts
- Block tables

- Examples library
- Use library items in a document
- Use the long form library item name
- Assign a shortcut name to the library
- Include a library in a file
- Use a library number value
- Use a library function
- Use items in a library frame
- Use a library data table as function
- Use library blocks
- Core, built-in, and subscription libraries
- Create personal libraries
- Save items to your library
- Manage your library online
- Library subscriptions