Skip to content

FREAD ​

FREAD reads the content of a file.

Syntax ​

leo-grammar
CC "AdoScript" FREAD file:strValue [ binary:boolValue ] [ base64:boolValue ] .
# -->RESULT text:strValue ecode:intValue
CC "AdoScript" FREAD file:strValue [ binary:boolValue ] [ base64:boolValue ] .
# -->RESULT text:strValue ecode:intValue

Parameters ​

  • file (strValue) - the name of the file (including path)
  • binary (boolValue, optional) - specifies whether the file should be read in binary mode (binary:1) or in text mode (binary:0). In text mode, all line breaks in the scanned text are automatically set to '\n'. In binary mode all line breaks stay the way they are.
  • base64 (boolValue, optional) - if specified, it means that the resulting text value shall be the base64 encoded content of the file instead of the original (binary) content.

Returns ​

  • text (strValue) - contains the content of the file.
  • ecode (intValue) - has the value 0 if no errors occurred, a value different than 0 if an error occurred.

Details ​

Relative paths relate to the installation directory.

Note that the parameter binary does not mean that binary files can be read into a string! A binary file may contain null characters which are used as end character in strings. Binary files can just be read as a base64 encoded string (see below).

If ecode has the value 2, the the file is too large to store its content in a string variable. The maximum length for a string variable is 2^31 characters (~2GB).

See Also ​

Examples ​

asc
CC "AdoScript" FWRITE file:"C:\\temp\\text.txt" text:"Hello World"

CC "AdoScript" FREAD file:"C:\\temp\\text.txt"

CC "AdoScript" INFOBOX (text)
CC "AdoScript" FWRITE file:"C:\\temp\\text.txt" text:"Hello World"

CC "AdoScript" FREAD file:"C:\\temp\\text.txt"

CC "AdoScript" INFOBOX (text)

Creates a file in the temp folder and writes 'Hello world' into and then the file is read again and shown in an INFOBOX.

Versions and Changes ​

Available since ADOxx 1.3