Barcode Scan Commands: General Information
A barcode scan command is a piece of logic that can be executed in any scan state either by clicking a button associated with this command in the UI, or by scanning a fixed barcode associated with it. For example, this logic can change the current state of the barcode-driven engine or start a long-running process.
Learning Objectives
In this chapter, you will learn how to do the following:
- Define the set of barcode scan commands of a scan mode
- Implement a custom barcode scan command
- Add to a scan mode the logic that handles an input of the quantity
Applicable Scenarios
You define scan commands in the following cases:
- You have created a scan mode on a custom form and need to implement the set of scan commands of this mode.
- You have added a new scan mode on an existing barcode-driven form and need to implement the set of scan commands of this mode.
- You have created a scan mode on a custom form and need to add to this scan mode the command for the input of the quantity
Scan Command Component
The logic of a scan command is implemented in the ScanCommand component.
You use ScanCommand<TScanBasis>
to bind custom logic to a particular
barcode command.
All commands produce a related PXAction
. Therefore, the command can be
executed in two ways: by clicking the button in the user interface, or by scanning a barcode.
Implementation of a Scan Command
You create particular instances of this class in the
ScanMode<TScanBasis>.CreateCommands()
method.
- Code: The code that is used to perform the command. The system
automatically adds the
*
character to the beginning of all command codes and uses this character to distinguish them from the codes intended for processing by input state processors. - ButtonName: The name of the PXAction instance that is created for this command component.
- DisplayName: The display name of the button for the PXAction instance that is created for this command component.
- IsEnabled: A Boolean value that indicates (if set to
true
) that the command can be executed.
In the Process() method, you implement the logic that is performed when the scan command is executed.
If you want to run a long-running process in the scope of a command component, you use the Basis.WaitFor() method.