Skip to main content

Randomize

procedure Randomize;

Example

procedure ScriptEvent(var Value: variant);
begin
Randomize;
Value := Random;
end;

Usage

Randomize reseeds Velox's shared pseudo-random generator from current Windows timing. The new state affects subsequent Random and RandomInt calls throughout the same Designer, Service or API Service process.

Additional Technical Info

vxCommonNumber.Randomize now calls System.Randomize directly. It no longer assigns GetTickCount to RandSeed first, removing the range-check failure that could occur during the upper half of the 32-bit tick-count cycle.

Call it only when that shared reseed is intended. Repeated row/event calls can degrade predictability and couple otherwise unrelated flows. The example is fictional and source-reviewed only.

Implementation

  1. vxCommonNumber.Randomize calls System.Randomize.
  2. On Windows, System.Randomize obtains a high-resolution QueryPerformanceCounter value and falls back to GetTickCount if necessary.
  3. It combines one generated value with that counter.
  4. DefaultRandomize XORs the high and low 32-bit halves and replaces RandSeed.

State and concurrency

  • The mutation is process-global and unprotected. Concurrent random calls/reseeds can interleave.
  • Calling from one action changes sequences observed by all other actions in the same Designer/Service/API Service process.
  • There is no per-flow generator instance, lock, audit record or previous-seed return.
  • The Windows fallback tick count wraps approximately every 49.7 days, but the normal high-resolution counter and generated-state mix add other variation.
  • Timing-based seeding does not make the underlying 32-bit linear-congruential generator cryptographically secure.

Errors and platform assumptions

The reviewed product uses the Windows implementation. Performance-counter failure is handled by System.Randomize using its tick-count fallback. Velox does not catch or separately log this call.

Related entries

  • Random consumes the shared state.
  • RandomInt consumes the same state with biased rounding.
  • RandomizeSeed directly sets a repeatable signed 32-bit seed, subject to shared-state interference.

External references

Created 2026-07-15