Move sName to Customer.Name
Move Customer.Name to sName
Send WriteHtml (HtmlEncode(Customer.Name))
There are some conditions where you should always move data directly to or from the file-buffer, bypassing the DDO’s field buffer. Those are:
When manipulating data within DDO events. During DDO operations (saves, finds, deletes, clears) various events are triggered. When these events are called the Data Dictionary has already placed the correct data in the file-buffer. If you create event augmentations you must always refer to the data in the file-buffers. In some cases, the data in the global file-buffer will not be the current field value – but it will be the right value for the event. For example, the Backout event must be called with the original data values and not with changes you might have made in your DDO. The DDO events which require that you use file-buffer data are:
While it is possible to augment events within an object, most often these events are created within the Data Dictionary class (with OnConstrain being a notable exception).
While this may seem counter-intuitive (to use direct file buffers during events), it is very important that you follow this advice. During a DDO operation, events are called during various stages of a file buffer’s state. For example, backout is called before the local DDO-Field-Buffer data has been updated to the file-buffer, while update is called after the DDO-Field-Buffer data has been moved to the file-buffer. If you use the file-buffer, you will always be changing the right data at the right time.
Forward Send Creating
Move Customer.Name to sCustName
Move (Trim(Uppercase(sCustName))) to sCustName
Move (Replaces(' ',sCustName,'')) to sCustName
Move sCustName to Customer.Login_Name
You should always move data directly to the file-buffer when you are performing finds (Find, Request_Find, etc.). This almost always causes confusion with new developers. When performing find operations, seeding the local DDO-Field-Buffers will have no effect; you must seed the global file-buffers. This allows you to perform a find without changing the current data in your DDO. This is required when you use finding methods that are not supposed to update your DDO.
// This function is used to find a customer by Customer number
// and return the RowId for that customer
Function SearchUser Integer iCustNo Returns RowId
Move oCustomer_DD to hoDD
Send Clear of hoDD
Move iCustNo to Customer.Customer_Number
Send Find of hoDD EQ 1
Get CurrentRowId of hoDD to riRecId
When seeding data for a find, always use the File-Buffer. When changing data for a save, always use the DDO-Field-Buffer.
If you need to retrieve the value of a DDO field, you can always use the Field_Current_Value message. This retrieves the current value of a field from the DDO’s local DDO-Field-Buffer. Note that this is the current value – if a field value was changed since it was last found, those changes will be retrieved. The file-buffer will contain the old value of the field – the field value before it was changed. If a field is unchanged, the DDO field value and file buffer value will be the same. Therefore, if you know that a field is unchanged you can use the file buffer to retrieve field values. If a field has not been changed, the following two code examples would return the same result.
Get Field_Current_Value of oCustomer_DD Field Customer.Name to sName
Move Customer.Name to sName
Because it is syntactically simpler to directly access the file-buffer, we will often use this method. Reports, which need to return unchanged field values, will use the simpler file buffer syntax.
Integer iFontSize iStyle
Send Update_Status (String(Customer.Customer_number))
Move "Arial" to sFont
Move 8 to iFontSize
Move (font_default) to iStyle
DfWritePos Customer.Customer_Number 0.8 (iStyle + Font_Right) 0
DfWritePos Customer.Name 2 iStyle -1 4.98
DfWritePos Customer.Address 7 iStyle -1 4.98
DfWritePos Customer.City 12 iStyle -1 3.98
DfWritePos Customer.State 15 iStyle -1 0.98
DfWritePos Customer.Zip 17 iStyle -1 1.98
Immediately after a successful find, the DDO-Field-Buffer and the File-Buffer will contain the same values. After additional processing, this may no longer be case, even if the DDO-Field-Buffer has not changed. This is discussed in Synchronization of File Buffers and DDO-Field-Buffer.
Understanding File Buffers and DDO Field Buffers