# MX\_TRANSCOPY

> [HTML Version](mx_transcopy.htm)

_Added June 2023_

**xcall MIAMEX, MX\_TRANSCOPY, op, srcfile, dstfile, tcffile, section, status\{, flags, maxlen, errmsg\}**

MX\_TRANSCOPY (MIAMEX 202) copies and translates a file, applying a series of regular expression replacement operations such that the destination file is a variant of the source. The new term "transcopy"—translate or transform plus copy—was coined to describe this operation.

**Parameters**

_op_  ([Num](num.md))  \[in\]

must be set to 1

_srcfile_  ([String](string.md))  \[in\]

source filespec

_dstfile_  ([String](string.md))  \[in\]

destination filespec; replaced if already exists 

_tcffile_  ([String](string.md))  \[in\]

configuration filespec; see [TCF specification](tcf-specification.md)

_section_  ([String](string.md))  \[in\]

optional section name within the [TCF](tcf-specification.md)

_status  _([Signed Int](integer-signed.md))  \[out\]

on success, number of modified lines; see table below for errors

_flags  _([Int](integer.md))  \[in\]

optional [REGEX](optionsflags.md)[xs](keyword-types.md)[ flags](optionsflags.md) combined with any that are set in the [TCF](tcf-specification.md)

_maxlen  _([Int](integer.md))  \[in\]

optional max length of source lines to support; default 16K

_errmsg_  ([String](string.md))  \[out\]

set only if status < 0)

**Comments**

This function (Op 1) is essentially equivalent to the compiler _transclude_ mechanism (++include with integrated transcopy) and may be used to debug your ++include TCF files. But it is also useful for general purpose file translations.

**Errors (status parameter)**



| **Value** | **Description** |
|------|------|
| \-2 to -25 | matching errors (same as [REGEX](regex_sbr.md)[xs](keyword-types.md)) |
| \-101 to -199 | pattern compiliation errors (same as REGEX[xs](keyword-types.md)) |
| \-93 to -99 | misc errors (same as REGEX[xs](keyword-types.md)) |
| \-92 | unable to allocate sufficient memory |
| \-91 | input file error |
| \-90 | output file error |
| \-89 | invalid item or syntax error in TCF |
| \-88 | too many s#/r# pairs in TCF |
| \-87 | TCF maximum line length exceeded |
| \-86 | unable to open TCF |
| \-85 | TCF section not found |
| \-84 | Unable to load REGEX library (PCRE) |




**History**

2023 June, A-Shell 6.5.1732:  Routine added to A-Shell.