{"title":"OutStream.WriteText([Text] [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/outstream/outstream-writetext-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/outstream/outstream-writetext-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/outstream/outstream-writetext-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":"Writes text to an OutStream object.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"OutStream.WriteText([Text] [, Integer]) Method","slug":"outstreamwritetexttext-integer-method","at":0,"chars":1765},{"level":2,"title":"Syntax","slug":"syntax","at":145,"chars":89},{"level":2,"title":"Parameters","slug":"parameters","at":234,"chars":336},{"level":2,"title":"Return Value","slug":"return-value","at":570,"chars":188},{"level":2,"title":"Remarks","slug":"remarks","at":758,"chars":247},{"level":2,"title":"Example","slug":"example","at":1005,"chars":623},{"level":2,"title":"Related information","slug":"related-information","at":1628,"chars":137}],"text":"# OutStream.WriteText([Text] [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nWrites text to an OutStream object.\n## Syntax\n```al\n[Written := ]  OutStream.WriteText([Text: Text] [, Length: Integer])\n```\n## Parameters\nOutStream\nType: outstream-data-type\nAn instance of the outstream-data-type data type.\n*[Optional] Text*\nType: ../text/text-data-type\nThe text to write. If you do not specify this, a carriage return and a line feed are written.\n*[Optional] Length*\nType: ../integer/integer-data-type\nThe number of characters to be written.\n## Return Value\n*[Optional] Written*\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\nFor more information about how zero bytes and line endings are written and read, see Write, WriteText, Read, and ReadText Method Behavior Regarding Line Endings and Zero Terminators<../../devenv-write-read-methods-line-break-behavior>.\n## Example\nThis example also requires that the c:\\\\TestFiles folder exists.\n```al\nvar\n    MyHTMLFile: File;\n    TestOutStream: OutStream;\nbegin\n    MyHTMLFile.Create('c:\\TestFiles\\main.html');\n    MyHTMLFile.CreateOutstream(TestOutStream);\n    TestOutStream.WriteText('<html>');\n    TestOutStream.WriteText;\n    TestOutStream.WriteText('<head>');\n    TestOutStream.WriteText('<title>My Page</title>');\n    TestOutStream.WriteText('</head>');\n    TestOutStream.WriteText;\n    TestOutStream.WriteText('<P>Hello world!</p>');\n    TestOutStream.WriteText;\n    TestOutStream.WriteText('</html>');\n    MyHTMLFile.Close;\nend;\n```\n## Related information\noutstream-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}