Matrix.Add
----------

Adds a value to cells in matrix.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Matrix](component_Matrix.md) | [10.2](newinversion102.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Matrix.Add"; MatrixRef; Value { ; FirstRow; LastRow; firstCol; lastCol } ) 

**MBS**( **"Matrix.Add";** /\* Adds a value to cells in matrix. \*/  
**$MatrixRef**; /\* The matrix reference number.e.g. $matrix \*/   
**$Value**; /\* The value to add to all cells.e.g. 123 \*/   
**$FirstRow**; /\* Optional; The index of first row.  
Default is 0.e.g. 0 \*/   
**$LastRow**; /\* Optional; The index of last row.  
Default is [Matrix.Height](MatrixHeight.md)-1.e.g. 5 \*/   
**$firstCol**; /\* Optional; The index of first column.  
Default is 0.e.g. 0 \*/   
**$lastCol**) /\* Optional; The index of last column.  
Default is [Matrix.Width](MatrixWidth.md)-1.e.g. 6 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| MatrixRef | The matrix reference number. | $matrix |  |
| Value | The value to add to all cells. | 123 |  |
| FirstRow | The index of first row.   Default is 0. | 0 | Optional |
| LastRow | The index of last row.   Default is [Matrix.Height](MatrixHeight.md)-1. | 5 | Optional |
| firstCol | The index of first column.   Default is 0. | 0 | Optional |
| lastCol | The index of last column.   Default is [Matrix.Width](MatrixWidth.md)-1. | 6 | Optional |

### Result

Returns OK or error.

### Description

Adds a value to cells in matrix.  
We loop over all rows in all columns for the range and add the given value to the numbers.  
If the cell doesn't contain a number, it's converted to a number like GetAsNumber().  
  
Use [Matrix.New](MatrixNew.md) or [Matrix.NewWithSQL](MatrixNewWithSQL.md) to create the matrix object before adding something to it.  
### Examples

Add one to each cell:

 Set Variable \[ $matrix ; Value: MBS ("[Matrix.New](MatrixNew.md)"; 5; 6) \]   
\# set values   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 0; "Joe¶Miller¶New York¶123") \]   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 1; "Bob¶Jones¶Washington¶234") \]   
Set Variable \[ $r ; Value: MBS ("[Matrix.SetRow](MatrixSetRow.md)"; $matrix ; 2; "Jane¶Stones¶Los Angeles¶567") \]   
\# add one to all   
Set Variable \[ $r ; Value: MBS ("Matrix.Add"; $matrix ; 1; 0; 3; 3; 3) \]   
\# show numbers   
Show Custom Dialog \[ "Values" ; MBS ("[Matrix.GetColumn](MatrixGetColumn.md)"; $matrix ; 3) \]   
\# free   
Set Variable \[ $r ; Value: MBS ("[Matrix.Release](MatrixRelease.md)"; $matrix ) \]  
### See also

- [Matrix.AddColumn](MatrixAddColumn.md)
- [Matrix.AddColumns](MatrixAddColumns.md)
- [Matrix.AddRow](MatrixAddRow.md)
- [Matrix.AddRows](MatrixAddRows.md)
- [Matrix.Avg](MatrixAvg.md)
- [Matrix.GetColumn](MatrixGetColumn.md)
- [Matrix.NewWithSQL](MatrixNewWithSQL.md)
- [Matrix.Release](MatrixRelease.md)
- [Matrix.SetRow](MatrixSetRow.md)
- [Matrix.Width](MatrixWidth.md)

### Release notes

- **Version 12.5**
    - Fixed a bug in [Matrix.Add](https://www.mbsplugins.eu/MatrixAdd.shtml) and [Matrix.Multiply](https://www.mbsplugins.eu/MatrixMultiply.shtml).
- **Version 10.2**
    - Added [Matrix.Add](https://www.mbsplugins.eu/MatrixAdd.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 12.5pr3](https://www.mbsplugins.de/archive/2022-10-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-12/Neues_MBS_FileMaker_Plugin_102/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.2 - More than 6200 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-05-12/MBS_FileMaker_Plugin_102_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr2](https://www.mbsplugins.de/archive/2020-04-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 2nd April 2020 , last changed 7th April 2022

  
[Math.TextToNumber](MathTextToNumber.md) - [Matrix.AddColumn](MatrixAddColumn.md)

[HTML Version](MatrixAdd.shtml)