Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Variable.Add

Adds a value to a given variable atomically.

Component Version macOS Windows Linux Server iOS SDK
Variable 8.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Variable.Add"; Name; Value )   More

(old name: FM.VariableAdd)

Parameters

Parameter Description Example
Name the name of the variable "test"
Value the value to add to the variable 5

Result

Returns new value or error.

Description

Adds a value to a given variable atomically.
Internally does similar to Variable.Get to read value, then adds given parameter and stores like Variable.Set, all in one operation, so no other script or calculation can get between.
Creates variable, if it's not existing yet.

Examples

Sets $ID and counts up with each call:

Set Variable [ $ID ; Value: MBS( "Variable.Add"; "ID"; 1 ) ]

Add values:

Let([
  c = MBS( "Variable.Clear"; "ID" );
  v1 = MBS( "Variable.Add"; "ID"; 1 );
  v2 = MBS( "Variable.Add"; "ID"; 1 );
  v3 = MBS( "Variable.Add"; "ID"; 1 );
  v4 = MBS( "Variable.Get"; "ID")
]; v1 & v2 & v3 & " " & v4)

Example result: 123 3

Try in a script:

Set Variable [$r; Value: MBS("Variable.Clear"; "Total")]

Set Variable [$r1; Value: MBS("Variable.Add"; "Total"; 10)]
Set Variable [$r2; Value: MBS("Variable.Add"; "Total"; 25)]

Set Variable [$sum; Value: MBS("Variable.Get"; "Total")]

Show Custom Dialog ["Sum Total"; $sum]

See also

Blog Entries

This function checks for a license.

Created 8th June 2018, last changed 12nd June 2025


Validate.FindReceipt - Variable.Append