{"title":"InStream.Read(var Boolean [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/instream/instream-read-boolean-integer-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/instream/instream-read-boolean-integer-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/instream/instream-read-boolean-integer-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Reads a specified number of bytes from an InStream object.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"InStream.Read(var Boolean [, Integer]) Method","slug":"instreamreadvar-boolean-integer-method","at":0,"chars":2731},{"level":2,"title":"Syntax","slug":"syntax","at":198,"chars":89},{"level":2,"title":"Parameters","slug":"parameters","at":287,"chars":468},{"level":2,"title":"Return Value","slug":"return-value","at":755,"chars":185},{"level":2,"title":"Remarks","slug":"remarks","at":940,"chars":547},{"level":2,"title":"Example","slug":"example","at":1487,"chars":1108},{"level":2,"title":"Related information","slug":"related-information","at":2595,"chars":136}],"text":"# InStream.Read(var Boolean [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nReads a specified number of bytes from an InStream object. Data is read in binary format.\n## Syntax\n```al\n[Read := ]  InStream.Read(var Variable: Boolean [, Length: Integer])\n```\n## Parameters\nInStream\nType: instream-data-type\nAn instance of the instream-data-type data type.\nVariable\nType: ../boolean/boolean-data-type\n*[Optional] Length*\nType: ../integer/integer-data-type\nDescribes 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.\n## Return Value\n*[Optional] Read*\nType: ../integer/integer-data-type\nIf you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nRead 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<../../devenv-write-read-methods-line-break-behavior>.\nIf 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.\nIf the return value is present, then you must verify the validity of the data that has been read.\n## Example\nThe 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.\n```al\n var\n    recBinaries: Record \"Company Information\";\n    varInstream: Instream;\n    varChars: Text[50];\n    numChars: Integer;\n    Text000: Label 'Number of characters read: %1. Characters read: %2.';\nbegin\n    recBinaries.Find('-');\n    recBinaries.CalcFields(recBinaries.Picture);\n    recBinaries.Picture.CreateInStream(varInstream);\n    numChars := varInstream.Read(varChars,3);\n    Message(Text000, numChars, varChars);\nend;\n```\n## Related information\ninstream-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}