編集

次の方法で共有


InStream.Read(var Text [, Integer]) Method

Version: Available or changed with runtime version 1.0.

Reads a specified number of bytes from an InStream object. Data is read in binary format.

Syntax

[Read := ]  InStream.Read(var Variable: Text [, Length: Integer])

Parameters

InStream
 Type: InStream
An instance of the InStream data type.

Variable
 Type: Text

[Optional] Length
 Type: Integer
Describes the number of characters to be read. If you do not specify Length, the size of the variable is used. In the case of data types other than string, code, and binary, if you specify a length that differs from the size of the variable, you receive an error message.

Return Value

[Optional] Read
 Type: Integer
If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

Read reads until the specified length or a zero byte. For more information about how zero bytes and line endings are read, see WRITE, WriteText, Read, and ReadTEXT Method Behavior Regarding Line Endings and Zero Terminators.

If the optional return value (Read) is not present and the data being read is less than the length requested to be read, then you receive an error message.

If the return value is present, then you must verify the validity of the data that has been read.

Example

The following example shows how to use the Instream.Read method to read data in binary format. The Find method finds the first record from the Company Information table. The CalcFields method retrieves the Picture field, which is a BLOB field. The CreateInStream method uses the recBinaries variable to create an InStream object that is named varInstream. The varInstream.Read method then reads three characters from the varInstream variable and stores the binary data in the varChars variable. The number of characters that is read is stored in the numChars variable. The binary data and the number of characters that is read are displayed in a message box.

 var
    recBinaries: Record "Company Information";
    varInstream: Instream;
    varChars: Text[50];
    numChars: Integer;
    Text000: Label 'Number of characters read: %1. Characters read: %2.';
begin
    recBinaries.Find('-');  
    recBinaries.CalcFields(recBinaries.Picture);  
    recBinaries.Picture.CreateInStream(varInstream);  
    numChars := varInstream.Read(varChars,3);  
    Message(Text000, numChars, varChars);  
end;

InStream Data Type
Get Started with AL
Developing Extensions