{"title":"InStream.ReadText(var Text [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/instream/instream-readtext-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-readtext-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-readtext-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 text from an InStream object.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"InStream.ReadText(var Text [, Integer]) Method","slug":"instreamreadtextvar-text-integer-method","at":0,"chars":2146},{"level":2,"title":"Syntax","slug":"syntax","at":145,"chars":90},{"level":2,"title":"Parameters","slug":"parameters","at":235,"chars":365},{"level":2,"title":"Return Value","slug":"return-value","at":600,"chars":226},{"level":2,"title":"Remarks","slug":"remarks","at":826,"chars":639},{"level":2,"title":"Example","slug":"example","at":1465,"chars":545},{"level":2,"title":"Related information","slug":"related-information","at":2010,"chars":136}],"text":"# InStream.ReadText(var Text [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nReads text from an InStream object.\n## Syntax\n```al\n[Read := ]  InStream.ReadText(var Variable: Text [, Length: Integer])\n```\n## Parameters\nInStream\nType: instream-data-type\nAn instance of the instream-data-type data type.\nVariable\nType: ../text/text-data-type\nThe variable that receives the characters that were read.\n*[Optional] Length*\nType: ../integer/integer-data-type\nThe number of characters to be read. If you do not specify this parameter, the maximum length of the string is used.\n## Return Value\n*[Optional] Read*\nType: ../integer/integer-data-type\nThe number of characters that were read. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nReadText reads the stream until the specified number of bytes, the maximum length of the string, a zero byte, or until the end of the line. 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>.\nData is read in text format.\nIf you do not use the optional return value and the data being read is less than the length requested to be read, an error message is displayed.\nIf you use the return value, you must verify the validity of the data that has been read.\n## Example\nThis example shows to use the InStream.ReadText method to read stream from a text file. This example is only supported on Business Central on-premises.\n```al\n var\n    FileTest: File;\n    StreamInTest: Instream;\n    Txt: Text;\n    Int: Integer;\nbegin\n    FileTest.Open('c:\\XMLDocs\\NewTest.txt');\n    FileTest.CreateInStream(StreamInTest);\n    // Starting a loop\n    while not (StreamInTest.EOS) do begin\n      Int := StreamInTest.ReadText(Txt,100);\n      Message(Txt + '\\Size: ' + Format(Int));\n    end;\n    FileTest.Close();\nend;\n```\n## Related information\ninstream-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}