<< Click to Display Table of Contents >> Navigation: 3. Script Language > Filesystem-Commands > FIL. - File-Commands > FIL. - File-Commands |
MiniRobotLanguage (MRL)
FIL.Copy to File
Writes a string into a file, overwriting the file if it already exists.
Intention
The FIL.Copy to File command is used to write a specific string into a file. If the file already exists, it will be overwritten. If the file does not exist, it will be created. This command is useful when you need to quickly write content to a file. Unlike "CTF." it uses other internal Mechanism, and therefore does not support NTFS-direct means it supports only pathes up to 255 characters.
To write 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.Copy to File|c:\example.txt|Hello World|$$$RES
MBX.$$RES
This command will write the string "Hello World" into the file "example.txt". If the operation is successful, the command will return 1 in the variable "$$RES".
If the operation fails, it will return 0. If P3 is missing, the result will be placed on the TOS.
Syntax
FIL.Copy to File|P1|P2[|P3]
Parameter Explanation
P1 - The filename or path of the file to be written to.
P2 - The string that will be written into the file.
P3 - (optional) Variable for the result.
The command returns a numeric code indicating the result of the operation:
1 - The operation was successful.
0 - An error occurred while writing to the file.
Example
'*****************************************************
'
'
'*****************************************************
Remarks
-
Limitations:
-
See also:
• IEF. / NEF. - If - exist - File