Word Binary Data (OpenInsight 32-Bit)
At 08 MAY 2011 10:07:44AM Karl Pozmann wrote:
I'm attempting to store word documents within LH using the binary data type. The code to store the data looks basically like this:
Filename=C:\DEV\WORD\TEST.DOC"
OsRead Binary from Filename Elseā¦
Record=Iconv(Binary,'VB')
Write Record on LH_Binary,"TEST" else null
Then I retrieve the binary data and write it out to a file:
Filename=c:\dev\workspace\test.doc"
Read Record from LH_Binary,"TEST" Else Record='
Binary=Oconv(Record,'VB')
OsWrite Binary on Filename
At this point if I attempt to bring that document up in word I get a message saying the file is corrupt.
Has anyone else tried doing this with Word? This same approach appears to work with PDFs for what it's worth.
At 08 MAY 2011 12:17PM Stefano Cavaglieri wrote:
Karl,
storing binary data in a field is not reliable, because of the way OI handles its delimiters. If you use a full record, such as:
Record=Iconv(Binary,'VB')that will work. If you absolutely need to store your binary data in a field, then put it into the last one and delete the lower fields just before the Oconv, like this:
Filename=C:\DEV\WORD\TEST.DOC"OsRead Binary from Filename Else...Record=Iconv(Binary,'VB')Write Record on LH_Binary,"TEST" else nullThen retrieve the binary data and write it out to a file:Filename=c:\dev\workspace\test.doc"Read Record from LH_Binary,"TEST" Else Record='for Z=1 to 4Record=delete(Record, 1, 0, 0)next ZBinary=Oconv(Record,'VB')OsWrite Binary on FilenameHope it helps,
Stefano
At 08 MAY 2011 12:41PM Karl Pozmann wrote:
Yes that works, thanks.
At 09 MAY 2011 04:54PM Jared Bratu wrote:
Regarding the first example, IConv(Binary, "VB") should return the value of Binary in a delimiter safe format so you can set/get it from a field. This should make the second (cleaver) example obsolete.
When the record is read you'll have to OCONV(FieldData, "VB") to get the original Binary value. This is according to the OpenInsight 9.2.1 help file.
Have you had problems with the IConv VB format in the current release?