Skip to main content

BoolToStr

function BoolToStr(B: Boolean; UseBoolStrs: Boolean): string;

Example

procedure ScriptEvent(var Value: variant);
begin
Value := BoolToStr(True, False); // '-1'
end;

Usage

BoolToStr converts a Boolean to numeric or configured Boolean text through Velox's SysUtils rules.

Parameters

NameTypeDescription
BBooleanValue to format.
UseBoolStrsBooleanFalse selects -1 or 0. True selects the first configured true or false string.

Returns

BUseBoolStrsResult
TrueFalse-1
FalseFalse0
TrueTrueTrueBoolStrs[0], initially True unless changed by the host process
FalseTrueFalseBoolStrs[0], initially False unless changed by the host process

Errors

Normal string allocation and any script-side argument conversion failures propagate. The RTL routine does not signal an invalid Boolean because B is already typed as Boolean.

Usage notes

Use UseBoolStrs = False for a stable Velox numeric representation. For an interchange contract that requires true/false, Y/N or another exact token, select it explicitly in script rather than relying on shared across the Velox process Boolean strings.

Additional Technical Info

BoolToStr uses Delphi's Boolean-to-string rules. UseBoolStrs selects either fixed numeric text or the first entries in Delphi's process-wide Boolean-string arrays.

The example requests the deterministic numeric form. It is source-reviewed and is not executed by the documentation workflow.

Implementation

The PascalScript SysUtils import forwards to System.SysUtils.BoolToStr(Boolean, Boolean). With UseBoolStrs = False, the selected Delphi overload uses fixed simple strings. With UseBoolStrs = True, it ensures the global TrueBoolStrs and FalseBoolStrs arrays have defaults when empty, then reads element zero from the applicable array.

Edge cases and quirks

  • Delphi's numeric text for True is -1, not 1.
  • The text form is not guaranteed to remain the English literal True or False. Host code can replace or reorder the process-wide arrays.
  • Initialisation of empty Boolean-string arrays and later host mutation are shared process state. Treat a configured text result as environment-dependent.
  • The function does not accept a Variant directly. Normal PascalScript parameter conversion must first produce a Boolean; unsupported values can fail before the call.

Side effects

With UseBoolStrs = True, the Delphi routine can initialise empty global Boolean-string arrays. It does not modify Velox flow data or configuration directly.

Performance and concurrency

The conversion is constant-time apart from string allocation. The numeric form uses no configurable shared text. The configured form reads, and can initialise, process-wide arrays; concurrent host mutation is outside the call's control.

External references

Created 2026-07-15