4D v13BLOBs |
||
|
4D v13
BLOBs
BLOBs
In addition to the manipulations explained in the video, you should also note the following: When starting out, we always ask the same questions:
Let’s start by tackling the second question: Even though we can access any byte of the BLOB, in most cases we’ll use what we call FIFO (First In First Out). This means that you retrieve the content of the BLOB in the order in which you put it into the BLOB. It’s the same thing in a BLOB, especially because you know what you put away in the BLOB. For example, when you put away:
When re-reading, you will take the information in the same order again and put it away in variables that are adapted to the expected content (typed correctly). This way the BLOB is read in a consistent manner.
The VARIABLE TO BLOB command stores the data in a format internal to 4D. That’s why the required space is slightly greater than the raw data size. The advantage of this command is that it keeps you from having to manage Byte Swapping (position of the most significant byte) when working cross-platform. When you fill a BLOB, you can use the * character instead of the $PositionInBlob variable that we used. When you use this parameter, 4D understands that it must store the variable at the end of the BLOB and increase its size as a result. Now let's imagine that you have a number of parameters in your database that must be taken into account for each user (or each site where your application is installed):
To keep them, there are several solutions (create a table, a text file, an XML file, etc.). In our case, we will keep these preferences in a BLOB, which is stored in a file on your disk. The read and write commands for BLOBs are BLOB TO DOCUMENT and DOCUMENT TO BLOB. To save space and/or transfer time, you may also want to consider compressing your BLOBs. Remember that 4D only compresses BLOBs if their size is greater than 255 bytes. When decompressing BLOBs, remember to check to see whether the BLOB is actually compressed. Otherwise, trying to decompress it will generate an error.
|
PROPERTIES
Product: 4D |