What is the default value of the Text parameter in TField.OnGetText

I have a procedure related to the TField.OnGetText event of the Score field as follows:

 procedure TMyForm.GetScoreText(Sender: TField; var Text: string; DisplayText: Boolean); begin if StrToInt(Sender.AsString) >= 80 and StrToInt(Sender.AsString) <= 100 then Text := 'Great!'; else if StrToInt(Sender.AsString) >= 60 and StrToInt(Sender.AsString) < 80 then Text := 'Good'; end; 

From the OnGetText documentation , I know that if there is no OnGetText handler, the OnGetText property of the field is the name of the AsString property. But my question is: what value does the var Text get parameter have, OnGetText exists, but the Text value is defined for the current field value. This is in my case, what is the value of Text when the value of the Score field is less than 60? Is it Null , or an empty string, or something else? I need to know this explicitly because there is some kind of logic that depends on the displayed value.

I found out from this post to https://stackoverflow.com/a/212575/129 that nothing is displayed for the field if the OnGetText handler procedure has no code, that is, the body of the procedure is empty.

+1
source share
1 answer

If OnGetText and nothing is returned in the Text argument, the result is an empty string.

Look at the source of Db :

 function TField.GetDisplayText: string; begin Result := ''; if Assigned(FOnGetText) then FOnGetText(Self, Result, True) else GetText(Result, True); end; 

Initially, Result set to an empty string and passes it to FOnGetText if it has been assigned.

+5
source

All Articles