I am trying to split a HL7 message (RDE O11) into several messages depending on how many RXC segments there are in the message (Two RXC segments would need to two separate HL7 messages)

I have seen a couple of posts regarding this but am struggling with my BP using ObjectScript, the idea is to take the receiving message and split this before passing it onto another BP

Here is my code so far

0 2
0 339