TCP/IP Integration: Scan data from 2 different ports, compare the data, then Print Conditionally. Follow


BarTender Content Team


In an integration, can you read data from 2 different sources, compare the data and then print a document conditionally based on the result of the data comparison?


Yes, this is indeed possible. Find below an example (using TCP/IP sockets).



The following Integration File shows how you could create either a TCP/IP or Serial Port Integration to scan a first set of data (which will stay in %EventData%), then create an additional Action which will scan for a second set of data (which I have stored to a variable called %SecondScan%).

Once you have both sets of data, you can compare them via a PowerShell Script:

$First = "%EventData%"
$Second = "%SecondScan%"
$Result = $First.equals($Second)

The Result is written to a third Integration variable called %Result%.

Finally, you can perform a conditional "Print Document" action, based on the value of %Result%. If it's True, then the document will be printed (well, in my example I've used "Begins with" T as the "Equals" True comparison wasn't working). 



Some screenshots:

The initial TCP/IP detection is configured to stop reading after 5 characters:


The Second Read from Network Socket (this time as an Action), works exactly in the same way, but opens a new connection:



The PowerShell command to perform the comparison:



The conditional Print Document Action:



More Information (Internal)

The Integration File + the Hydrashok File (which is a Seagull Tool used to fire data over Serial or TCP/IP port) can be downloaded from here:


As per the Hydrashok configuration, I've created 2 triggers, one which fires at 5 seconds and which will provide data for the TCP/IP Integration, and the second one which fires at 15 seconds, and which will provide the data for the "Read from Network Socket" Action.

Do you have feedback or questions on this article? We encourage you to post them on our Community Forums