Read entire file

Command groupFlag affectedReversibleExecute on clientPlatform(s)
External commandsYESNONOWindows,Linux

Syntax

Read entire file
 
(path, binary-variable [,'r'])
 
Returns 
err-code

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This command reads an entire file into a binary field. If you specify 'r' as the third parameter, it opens the file in read-only mode. It returns an error code, or zero if no error occurs. The returned binary value has the following format:

  1. 12 byte header containing the Type (4 bytes), Creator (4 bytes), and file length (4 bytes).
  2. File data.

The Type is always ‘TEXT’, and the Creator is always ‘mdos’.

Example

# Prompt the user for a file and read it's entire contents into the

# binary variable lBinFld

Do
 
FileOps
.
$putfilename
(
lPathname
,
'Select a file'
,
''
)
 
Returns 
lReturnFlag

If
 
lReturnFlag

  
Read entire file
 
(
lPathname
,
lBinfld
)
 
Returns 
lErrCode

End If