AsInteger
property AsInteger: LongInt read write;
Example
procedure IncrementAttempts(const Data: TvxClientDataSet);
begin
Data.Edit;
Data.FieldByName('AttemptCount').AsInteger :=
Data.FieldByName('AttemptCount').AsInteger + 1;
end;
Usage
AsInteger reads or writes the field through a signed 32-bit integer conversion, including type-specific rounding, range and null behaviour.
- Check
DataTypeand range before converting large identifiers or counts. - Use
AsVariantwhen a 64-bit value must remain dynamically typed and supported by the field. - Preserve null separately instead of using sentinel zero unless the mapping contract defines it.
Additional Technical Info
PascalScript exposes AsInteger as LongInt, matching Delphi's signed 32-bit Integer in the supported Windows build.
Source-backed behaviour
The runtime helper delegates to native TField.AsInteger; base access raises. Integer descendants read their native buffer and return zero for null. Narrow descendants enforce their signed/unsigned range on assignment. Numeric descendants may round a floating value, and a string descendant parses decimal text and raises on invalid input. Values outside -2147483648..2147483647 cannot be represented through this member even when the database field is 64-bit.
Writing requires a dataset write state and flows through field read-only checking, validation, DSBase verification, buffer mutation and change notification. Reading zero cannot distinguish a database null from numeric zero; use IsNull first. The Velox helper AsInteger0 intentionally also maps null/empty textual representations to zero, so it does not restore null information.