4D v16BLOBs |
||
|
4D v16
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.
In this video, we're going to learn how to program BLOBs and see how they interact with variables. BLOBs allow you to store and retrieve all kinds of information. Let’s use a simple example, say, storing variables. First let's create a method and then we are going to:
The principle is to:
The PositionInBlob variable works as both an input and output variable, in other words:
We're going to trace this method to see how it fills the BLOB and how it restores the variables. At this point:
To extract data from the BLOB:
This simple example helps us understand the entry and removal of data in a BLOB. We could store results from statistical arrays in a BLOB so that we can use them again later on.
Later, when we want to retrieve the contents of the arrays, we'll need to program this as follows:
During execution:
Then when we want to retrieve the BLOB contents later on:
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
Self-training ( 4D v16) |