Reads a specified number of bytes from an InStream object. Data is read in binary format.
[Read := ] InStream.Read(Variable[, Length])
Describes the variable that will receive the data that is read.
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.
Property Value/Return Value
The return value is the number of characters that were read.
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.
The following example shows how to use the Instream.READ function to read data in binary format. The FIND function finds the first record from the Company Information table. The CALCFIELDS function retrieves the Picture field, which is a BLOB field. The CREATEINSTREAM function uses the recBinaries variable to create an InStream object that is named varInstream. The varInstream.READ function 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. This example requires that you create the following variables and text constants in the C/AL Globals window.
|recBinaries||Record||Company Information||Not applicable|
|varInstream||InStream||Not applicable||Not applicable|
|numChars||Integer||Not applicable||Not applicable|
|Text constant name||ENU value|
|Text000||Number of characters read: %1. Characters read: %2.|
recBinaries.FIND('-'); recBinaries.CALCFIELDS(recBinaries.Picture); recBinaries.Picture.CREATEINSTREAM(varInstream); numChars := varInstream.READ(varChars,3); MESSAGE(Text000, numChars, varChars);
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.