IsNullEmpty
function IsNullEmpty: Boolean
Example
procedure ScriptEvent(var Value: variant);
begin
if Field.IsNullEmpty then
Value := 'No text supplied'
else
Value := Field.AsString;
end;
Usage
IsNullEmpty treats the field as empty when its converted string value is empty after Velox whitespace trimming.
Additional Technical Info
IsNullEmpty reads the field through AsString, applies Delphi Trim, and returns whether the result is the empty string.
Exact expression:
Trim(GetAsString) = ''
What counts as empty
- database null, because a null field's string conversion is empty;
- an empty string;
- a string containing only characters Delphi
Trimremoves at both ends (characters at or below U+0020); - values whose concrete field formatter produces only such whitespace.
Numeric zero, Boolean false and date/time zero normally format as nonempty text and therefore return false. Use IsNullZero for Velox's numeric/date zero sentinel rule. IsNullEmpty does not inspect IsStringType; it converts every field category to text.
Concrete-field conversion or custom OnGetText behavior can affect the result and can raise. The method has no write side effect, but calculated/lookup/display conversion work can add cost. The current cursor determines the value.
External references
- Embarcadero DocWiki:
TFielddocuments null defaults and typed conversion behavior. - Embarcadero DocWiki:
Trimdocuments the Delphi trimming rule used by Velox. - Free Pascal:
TStringHelper.Trimprovides compatible trim context; Velox uses DelphiTrim.