|Powered by QM on a Rpi server|
KnowledgeBase 00073: Directory File Mark Translation
This article was originally published as a Tip of the Week.
Directory files are widely used for exchanging data with other software. By default, when QM writes a record to a directory file, field marks are replaced by newlines. This is because the software that reads this data may not have any knowledge of the multivalue data model. Effectively, each field becomes a line of text in much the same way as when data is viewed with an editor. The opposite translation occurs when reading data.
If the data contains value marks or subvalue marks, these are left unchanged. Export of data that includes values or subvalues implies that whatever reads the data must understand the multivalue data model.
The process described above is fine where the data is text but it is not appropriate for binary data such as bit-mapped images. Directory files are ideal for storing digital pictures because they are optimised for large data items but, because the data is a binary representation of the picture, some bytes will have a value that appears to be a field mark and the mark translation would corrupt the image.
The QMBasic MARK.MAPPING Statement
Translation of field marks can be suppressed by use of the MARK.MAPPING statement after the file has been opened.
OPEN 'IMAGE.FILE' TO IMG.F ELSE STOP 'Cannot open file' MARK.MAPPING IMG.F, OFF READ IMG.REC FROM IMG.F, ID THEN .....Used with ON instead of OFF, this statement can reinstate mark mapping for subsequent read/write operations though it is rare to need to switch modes from one record to the next.