Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 3.45 KB

file-write-integer-method.md

File metadata and controls

79 lines (61 loc) · 3.45 KB
title description ms.author ms.date ms.tgt_pltfrm ms.topic author
File.Write(Integer) Method
Writes to an MS-DOS encoded file or binary file.
solsen
02/26/2024
na
reference
SusanneWindfeldPedersen

File.Write(Integer) Method

Version: Available or changed with runtime version 1.0.

Writes to an MS-DOS encoded file or binary file.

Note

This method is supported only in Business Central on-premises.

Syntax

 File.Write(Value: Integer)

Note

This method can be invoked without specifying the data type name.

Parameters

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

Value
 Type: Integer
The data that you want to write to the file.

Remarks

You must call the TextMode Method (File) before you call the Write method.

If TextMode Method (File) is set to true and Value is an integer, then the integer is written as text, followed by a new line character.

If Value is a record, each field is separated by a tab character.

If TextMode Method (File) is false and Value is an integer, an integer is written that is four bytes long.

MS-DOS encoding requires a different character set for each language. MS-DOS text is encoded to the internal Unicode data type by using the system locale language of the computer that is running [!INCLUDEd365fin_server_md]. If you write to a file that uses MS-DOS encoding, then you must set the system locale language of the computer that is running [!INCLUDEd365fin_server_md] to match the language of the data that you want to write to the file.

We recommend that you use the File data type for files that were created in earlier versions of [!INCLUDEd365fin_md].

To read or write files in Unicode or in other formats, we recommend that you use .NET Framework interoperability and use the System.IO Namespace.

Example

The following example determines whether the specified file exists. If it exists, the WriteMode Method (File) allows the file to be open for writing. The Open Method (File) opens the file, the Write Method (File) writes the text “Hello World” to the file and then the Close Method (File) closes the file. If the file does not exist, then an error message is displayed. This example assumes that you have created the following file: C:\TestFolder\TestFile.txt.

var
    FileName: Text;
    TestFile: File;
    Inte: Integer;
begin  
    FileName := 'C:\TestFolder\TestFile.txt';  
    if Exists(FileName) then begin
      TestFile.WriteMode(True);  
      TestFile.Open(FileName);  
      TestFile.Write(Int);  
      TestFile.Close;  
    end else 
      Message('%1 does not exit.', FileName);
end;

See Also

File Data Type
Get Started with AL
Developing Extensions