Filesystem-Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Filesystem-Commands >

Filesystem-Commands

CFF. -  Copy from file

Previous Top Next


MiniRobotLanguage (MRL)

 

CFF. Command

Copy from File

 

NTFS-Direct

Intention

 

This command is used to read any Text- or Binary Data from any file on into a variable.

It just like if you say "Put the content of this file into a variable". The syntax is very easy:

 

' put the filename into a variable

: $$FIL=C:\MyFilename.txt

' GEt the content of this file into $$CON

CFF.$$FIL|$$CON

 

Now the question is, did you get the file or not?  To answer this question, there is a third parameter, which must be a variable. If you got the file, the content of this variable will be 1. If you did not get the file, the content of the variable will be 0. Also the timeout-flag will be set according to the success of the file-operation.

 

' put the filename into a variable

: $$FIL=C:\MyFilename.txt

' Get the content of this file into $$CON

CFF.$$FIL|$$CON|$$RES

IVV.$$RES=0

 MBX.I did not get the file!

EIF.

 

If you just specify a filename and you omit the path, it is assumed that you load the file from ?path\ - that is your project folder.

 

' put the filename into a variable

: $$FIL=ProjectConfig.ini

' Get the content of this file into $$CON

' the filename will internally be completed to

' ?path\MyFilename.txt

CFF.$$FIL|$$CON

 

And the limits?

The size of the file that is read, can be up to several hundred Megabytes. While the theoretical size limit of a variable is 2 GB, the real-life limit is set by windows, depending on how fragmented your memory is.

 

 

 

Syntax

 

CFF.[P1]|[P2]|[P3]

 

 

Parameter Explanation

 

P1 - Filename

 

P2 - Variable to insert data from file

 

P3 - Opt. Variable which receives a TRUE value when the operation was successful and a FALSE value when the operation failed.

 

 

 

Example

 

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

' EXAMPLE 1: CFF. Read from file

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

VAR.$$FIL=ProjectConfig.ini

IEF.?path\$$FIL

 CFF.$$FIL|$$VAR|$$RES

 MBX.$$RES

EIF.

MBX.Success: $$VAR

ENR.

 

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

' EXAMPLE 1: CFF. Read from file

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

VAR.§§FIL=?desktop\one.txt

CFF.§§FIL|§§DAT|§§RES

PRT. Success: §§RES - Data: §§DAT

' Read file, put on TOS

CFF.§§FIL

' Get TOS

PRT.$$000

CFF.§§FIL|§§DAT

PRT.§§DAT

END.

 

 

 

Remarks

 

 

 

 

Limitations:

 

While the theoretical limit of variables is 2 GB, in real life windows may not have so much string-memory available. This depends mostly on how fragmented your computer memory is. Under normal circumstances a file that is below 400 MB should be read into a variable with no problems.

 

 

 

See also:

 

    ATF - Append-to-File

    CTF - Copy-To-File

    CTI. - Copy-To-Inifile

    CFI. - Copy-From_IniFile

    3.3 Specialfolders

    COP. - Copy File

    GLC. - Get-Line-Count

    IEF. / NEF. - If - exist - File

    LFF - Line-From-File

    SHF. - Shell-File-Operation

    WFF. - Wait-For-File