m.Successful = .F. FOR ix = 1 TO NumberOfLinesInText m.Segment = GetSegmentHeader * Somewhere in here I need to know when one message ends and another begins to set m.Successful DO CASE CASE m.Segment = 'MSH' First Line of Message so Do Something APPEND BLANK CASE m.Segment = 'EVN' Next Line of Message so Do Something Else REPLACE MyTable.EVN WITH SomeStuff ENDCASE IF m.Successful * Send ACK back to HL7 Client m.Acknowledgement = "MSA|CA|123456789|Text Message|0001||" IF ThisForm.tcpServer.Object.State = 7 ThisForm.tcpServer.Object.SendData(m.Acknowledgement) ELSE WAIT WINDOW "Not Connected." TIMEOUT 1 ENDIF ELSE STRTOFILE("Message failed at: " + TRANSFORM(DATETIME()) + CHR(13),"C:\Errors.log",.T.) ENDIF ENDFOR