# Example for Changing a Job by Job Name

The following image shows an example PLC logic for changing a job by Job Name, in this case specifically a Rockwell ControlLogix PLC:

The signals used are the following:

Signal Name | Vision System Defined Signal or Tag | PLC User Defined Tag | Notes
--- | --- | --- | ---
ChangeToJobName | - | Yes | Internal memory string tag holding the new job name to change to.
ZeroUserData | - | Yes | Internal memory tag holding job name length + 1.
UserData | Yes | - | Holds the job name byte data array to be written to the vision system.
Command_ByJobName | - | Yes | Internal memory tag holding job change by name command ID of 16384.
CommandID | Yes | - | This holds the job ID of the job to change to and is sent to the vision system.

For the job change by name case the logic is almost identical except in rung 0 there are two more branch elements to handle copying the new job name into the User Data. Also the CommandID is 16384 which is the command ID reserved for changing jobs by name.

The second branch has an ADD instruction which is for getting the string length of the new job name (ChangeToJobName.LEN) and then it adds 1 to it, in order to make sure that any user data left in that memory area does not affect the new job name once the job name is copied there. The new length is stored in ZeroUserData. Then the FLL instruction runs to fill the bytes in the User Data array with 0's using the new ZeroUserData length.

As an example a new job name, "CheckItems.jobx" needs to be loaded and is 15 characters long. If this were copied into the UserData (bytes 0 - 14) and there is non-zero data in byte 15 already from previous job load that data would be appended to CheckItems.jobx and the job change fails. Adding the extra byte as a 0 (null) allows the job to load correctly even if there is non-zero data in the rest of the bytes in the User Data array.

The third branch has a COP instruction to copy the new string byte data of the job name into the User Data byte array using the original ChangeToJobName string length as the length (number of bytes in this case). This way all of the characters for the new job name are copied to the User Data and it is followed by a 0 (null) to make sure the job name is correct and no extra characters are added to it.