uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
ValueBool(bool)
Method
Product:
Class:
Assigns a boolean value to a variable item from the host application.
Syntax
Parameters
Return
void
This method does not return a value.
Remarks
The ValueBool method provides a direct way for the host application to set the value of a uCalc variable that has been defined as a Boolean type.
This method is part of a family of type-specific setters (e.g., ValueInt32, ValueStr) that act as a bridge between your native code and the uCalc engine's internal state. It is the primary mechanism for updating variables programmatically without executing an expression string.
To retrieve the current value, use the getter overload: ValueBool().
💡 Comparative Analysis
There are two ways to change a variable's value:
Programmatic (Host-Side): Using
item.ValueBool(true)- Use Case: When the host application needs to update the engine's state based on its own logic (e.g., user input in a checkbox, application state changes).
- Performance: Very fast, as it involves a direct memory write with no parsing overhead.
Expression-Based (Engine-Side): Using
uc.EvalStr("myVar = true")- Use Case: When the value change is the result of a user-written script or a calculation within the uCalc engine itself.
- Performance: Slower, as it requires the string to be parsed and evaluated.
In summary, use this ValueBool(bool) setter for efficient, direct state manipulation from your application code. Use an expression-based assignment when the logic resides within the user's script. See DefineVariable for more information on creating variables.
Examples
Checking if a uCalc object is the default with IsDefault
using uCalcSoftware;
var uc = new uCalc();
var Status = uc.DefineVariable("Status As Bool");
Console.WriteLine(Status.ValueBool());
var MyuCalc = new uCalc();
Status.ValueBool(MyuCalc.IsDefault);
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
MyuCalc.IsDefault = true;
Status.ValueBool(MyuCalc.IsDefault);
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
False
MyuCalc is the current default? false
MyuCalc is the current default? true using uCalcSoftware; var uc = new uCalc(); var Status = uc.DefineVariable("Status As Bool"); Console.WriteLine(Status.ValueBool()); var MyuCalc = new uCalc(); Status.ValueBool(MyuCalc.IsDefault); Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")); MyuCalc.IsDefault = true; Status.ValueBool(MyuCalc.IsDefault); Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto Status = uc.DefineVariable("Status As Bool");
cout << tf(Status.ValueBool()) << endl;
uCalc MyuCalc;
Status.ValueBool(MyuCalc.IsDefault());
cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl;
MyuCalc.IsDefault(true);
Status.ValueBool(MyuCalc.IsDefault());
cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl;
}
False
MyuCalc is the current default? false
MyuCalc is the current default? true #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto Status = uc.DefineVariable("Status As Bool"); cout << tf(Status.ValueBool()) << endl; uCalc MyuCalc; Status.ValueBool(MyuCalc.IsDefault()); cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl; MyuCalc.IsDefault(true); Status.ValueBool(MyuCalc.IsDefault()); cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim Status = uc.DefineVariable("Status As Bool")
Console.WriteLine(Status.ValueBool())
Dim MyuCalc As New uCalc()
Status.ValueBool(MyuCalc.IsDefault)
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"))
MyuCalc.IsDefault = true
Status.ValueBool(MyuCalc.IsDefault)
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"))
End Sub
End Module
False
MyuCalc is the current default? false
MyuCalc is the current default? true Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim Status = uc.DefineVariable("Status As Bool") Console.WriteLine(Status.ValueBool()) Dim MyuCalc As New uCalc() Status.ValueBool(MyuCalc.IsDefault) Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")) MyuCalc.IsDefault = true Status.ValueBool(MyuCalc.IsDefault) Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")) End Sub End Module