Binary Type

Use the Binary primitive type to define Binary variables and attributes.

When you specify a length less than or equal to 540 for a Binary attribute, it is embedded. Space is allocated within instances of the class to store a binary value with a length less than or equal to the specified length.

When you specify a length greater than 540 or you select the Maximum Length check box (which corresponds to 2,147,483,647 bytes) for a Binary attribute, it is not embedded. It is stored in a separate variable-length object, a Binary Large Object (blob), which can store a binary value with a length less than or equal to the specified length. The amount of storage required for a blob is determined by the binary value.

Binary variables can be bounded or unbounded, as shown in the following code fragment.

vars
   bin1 : Binary[100]; // Bounded - bin1 can store a binary value with a
                       // length less than or equal to 100 bytes
   bin2 : Binary;      // Unbounded - bin2 can store a binary value with a
                       // length less than or equal to 2,147,483,647 bytes

To specify a substring bin[m:n] of a Binary value bin, use two integers separated by a colon (:) character. The first integer is the start position and the second integer (following the colon (:) character) is the length of the binary substring or end, to indicate the end of the binary string. The first byte is at position 1.

A variable of type Byte can be used to reference a single byte in a binary value, in effect treating the binary value as an array of bytes, as shown in the following code fragment.

vars
   bin : Binary;
   byte : Byte;
begin
   bin := app.loadPicture("C:\Jade\bin\jade.bmp");
   byte := bin[716];       // 716th byte of the binary data in bin

For details about the constants and methods defined in the Binary primitive type, see "Binary Constants" and "Binary Methods", in the following subsections. For details about converting primitive types, see "Converting Primitive Types", in Chapter 1 of the JADE Developer’s Reference.