Skip to main content
Version: Next

VP FLUSH COMMANDS

History
ReleaseChanges
20 R9Support of callback parameter

VP FLUSH COMMANDS ( vpAreaName : Text {; callback : 4D.Function} )

ParameterTypeDescription
vpAreaNameText->4D View Pro area form object name
callback4D.Function->(Optional) A callback function executed after all VP commands and 4D custom functions have been executed

Description

The VP FLUSH COMMANDS command immediately executes stored commands and clears the command buffer.

In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.

In order to increase performance and reduce the number of requests sent, the 4D View Pro commands called by the developer are stored in a command buffer. When called, VP FLUSH COMMANDS executes the commands as a batch when leaving the method and empties the contents of the command buffer.

If a callback function is provided, it is only executed after all stored commands and 4D custom functions have finished processing. This ensures that any follow-up actions, such as saving or printing the document, are only performed after all calculations have completed.

The following parameters can be used in the callback function:

ParameterTypeDescription
param1TextThe name of the 4D View Pro area object
param2ObjectAn object returned by the method with a status message
.successBooleanTrue if import was successful, False otherwise
.errorCodeIntegerError code
.errorMessageTextError message

Example 1

You want to execute commands and empty the command buffer:

// Set text values in specific cells
VP SET TEXT VALUE(VP Cell("ViewProArea1";10;1);"INVOICE")
VP SET TEXT VALUE(VP Cell("ViewProArea1";10;2);"Invoice date: ")
VP SET TEXT VALUE(VP Cell("ViewProArea1";10;3);"Due date: ")

// Execute stored commands, clear the buffer, and trigger the callback
VP FLUSH COMMANDS("ViewProArea1")

Example 2

You want to execute commands, empty the command buffer and trigger a callback function:

// Set text values in specific cells
VP SET FORMULA(VP Cell("ViewProArea1";10;1);"MyCustomFunction()")
VP SET FORMULA(VP Cell("ViewProArea1";10;2);"MyCustomFunction2()")
VP SET FORMULA(VP Cell("ViewProArea1";10;3);"MyCustomFunction3()")

// Execute stored commands, clear the buffer, and trigger the callback
VP FLUSH COMMANDS("ViewProArea1"; Formula(onFlushComplete))
// Method 'onFlushComplete'
#DECLARE($name : Text; $status : Object)
ALERT("All commands and custom functions have finished executing. You can now print or save the document.")