WRITE

Windows Linux macOS

Syntax

WRITE <identifier>, <text> {, BINARY|HEX}

WRITE CONSOLE, <text>

WRITE RESOURCE,<resource type>, <resource id>, <filename>

Description

Writes the specified text to the file <identifier>, or to the console. The text may represent binary data containing non-printable characters, in which case the optional third parameter is used to specify the format. This may be:

BINARY Data is returned as a series of decimal numbers (one per byte) separated by the character specified using the command OPTION FIELDSEP (by default this is '|').
HEX Data is returned as a series of two-digit hexadecimal numbers (one per byte) separated by spaces.

The WRITE RESOURCE command is the equivalent of the BINFILE SAVERES command in VDS 5. This command allows a user defined resource that has been linked in to the executable file to be saved to disk using the specified filename and path. Note that the <resource type> should be a user defined resource type name such as BINARY, which was used in the #RESOURCE directive that specified the file to be linked. Windows-supported resource types such as ICON and BITMAP are stored using ordinal type names. If the <resource type> is specified as (for example) "BITMAP" then the resource will not be found, as there is no actual type with this name.

It is possible to access Windows-supported resources using the ordinal number, if you know it. However, most Windows-supported resource types are stored in a special resource format which is not the same as the format used on disk. If a resource such as a bitmap or icon is saved to disk using the BINFILE SAVERES command it will not be readable by a bitmap or icon editor. Therefore, it is important that user-defined types are used when linking resources intended to be used with this command, to ensure that they are linked as raw binary data.

OK

Set to false if the command fails.

Example

WRITE %%mydata, 123@tab()ABCD@tab()
WRITE RESOURCE, TEXT, config, C:\config.dat

See also