I have an HL7 message, which is a simple text file. It consists of several ‘segments’ delimted with Chr(13). I’m trying to read in the file and store it in an SQLite DB which has been created and encrypted with Xojo. This is a Windows service application. The variables have all been declared properly.
Var InBoundFileStream As TextInputStream
Var InBoundFileFolderItem As FolderItem // (assigned to passed parameter = the FolderItem of the file to be read)
Var InBoundFileText As String
InBoundFileStream = TextInputStream.Open(InBoundFileFolderItem)
InBoundFileStream.Encoding = Encodings.UTF8
InBoundFileStream.BytePosition = 0 // trying this makes no difference
InBoundFileText = InBoundFileStream.ReadAll
The ‘pipe’ character is at 4. “MSH|^~&|…”. Have never had a problem with these characters. Chr(13) has always worked for me; some literature says 0x0D, others Chr(13). All segments are delimited with the same and the remaining message segments come through using them. I was wondering about that too, perhaps Xojo in Windows reads differently but there’s no consistency with the problem. Thanks!
I suspect it is to do with chr(13) being the line delimiter. On Windows chr(13) moves the cursor to the start of line but doesn’t move it down a line. It is then overwritten by the next line. Do the following:
Bingo!, almost. Doing the replace line endings it now returns the entire message. In practice can’t use the tilde as it’s a designated HL7 character but that’s beside the point. This at least points me in the right direction. Kudos!