FIL. - File-Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Filesystem-Commands > FIL. - File-Commands >

FIL. - File-Commands

FIL.Prepend to File

Previous Top Next


MiniRobotLanguage (MRL)

 

FIL.Prepend to File

Prepends a string to a file.

 

 

Intention

 

The FIL.Prepend to File command is used to insert a specific string at the beginning of a file. This command is particularly useful when you need to modify a file without reading the entire file into memory, which makes it suitable for working with large files.

 

To prepend the string "Hello World" to a file named "example.txt", and store the result in a variable named "$$RES", you would use the following command:

 

FIL.Prepend to File|Hello World|c:\example.txt|$$RES

MBX.$$RES

 

This command will insert the string "Hello World" at the beginning of the file "example.txt". If the operation is successful, the command will return 0 in the variable "$$RES".

 

This command works by creating a temporary copy of the file, making the necessary modifications, and then replacing the original file with the modified copy. This ensures that the original file is not corrupted if the operation is interrupted. However, this also means that the command requires enough free disk space to store the temporary copy of the file. If there is not enough free disk space, the command will fail with an error.

 

Syntax

 

 

FIL.Prepend to File|P1|P2[|P3]

FIL.PTF|P1|P2[|P3]

 

 

Parameter Explanation

 

P1 - The string to be prepended to the file.

P2 - The filename or path of the file to be modified.

P3 (optional) - The variable to store the return code of the operation. The command returns a numeric code indicating the result of the operation:

0 - The operation was successful.

1 - An error occurred while opening the file.

2 - An error occurred while writing to the file.

 

 

 

 

Example

 

'***********************************

'

'***********************************

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also:

 

 

    Split File

    Join File

    OPT. - Optional Settings

    GEC. - Get Encryption

    RMD. - Remove-Directory

    ATF - Append-to-File

    CFF. - Copy-From-File

    CTF - Copy-To-File

    COP. - Copy File

    SHF. - Shell-File-Operation

    MDF. - Make-Direktory-File

    MKD. - Make-Directory

    GLC. - Get-Line-Count

    IEF. / NEF. - If - exist - File

    LFF - Line-From-File

    WFF. - Wait-For-File

    REN. - Rename File/Dir