How to Use the Callback Function

The callback function is a function that allows you to include project processing during the processing of a library's public function.
The library developer writes a callback function template (skeleton code) and description in the public program file, using the function name, arguments, and return value specified by the library.
The library user can implement necessary processing by looking at the description within the file because the public program file will be added when a library is added to a project.

Example: Example of a callback function description

Function Lib_Callback(num As Integer) As Boolean
   'Called from the library after XXX is processed.
   'Parameter: Checks whether the num values are appropriate. True is returned when appropriate and False when it is not appropriate.
Fend

It can be used in the following way.

・A user program can change the subsequent processing during library processing.
【Example】

  • The library monitors the value of the input bit and calls for the callback function with the Boolean type return value if it has been OFF for a certain period of time. If the return value is False, the processing continues and ends when it is returned as True.
  • The library user can implement the callback function in the following ways and choose to continue/end the subsequent processing.
    • When a different input bit is On: With the MsgBox command, have the operator select continue/end and use the result as a return value of the call back function.
      -When a different input bit is Off: Set the return value to True and terminate the process without having the operator select it.

・Progress indicator and termination when it takes a long time to process the public function.
【Example】

  • The library periodically calls a callback function with a Boolean return value, with the progress rate as an argument. When the return value is True, the process will be terminated.
  • The library user displays the progress rate obtained by the callback function as a GSet in the GUI builder form.When the terminate button on the form is pressed, the return value of the callback function will be set to True the moment the callback function is called.