fileloadpartial(
PATH
,
START
,
LENGTH
)

The fileloadpartial( function reads a portion of the contents of any file on disk.


Parameters

This function has three parameters:

path – is a path to the file to be loaded, including the file name (see Files and Folders for more information about file paths).

start – is the first byte (character) of the file that should be read. This function numbers bytes in the file starting from 0 (not 1).

length – is the number of bytes that should be read.


Description

This function returns a portion of contents of the specified file as binary data (see Binary Data). This example displays the first one hundred bytes of a file named news.txt in the Documents folder.

displaydata fileloadpartial("~/Documents/news.txt",0,100)

Warning: The fileloadpartial( function should not be used with text files that use an encoding method with a variable number of bytes per character. Since standard text files on Mac OS X and iOS use UTF–8 encoding, which does have a variable number of bytes per character, you should not use the fileloadpartial( function with most text files, as it may result in garbled, incomplete or missing text. Instead, you should the fileload( function and extract the portion of text you want after it is loaded into a field or variable.

If the text file uses a fixed length encoding, like ASCII or Mac OS Roman, the fileloadpartial( will work fine. If the text file uses 16 bit character encoding (for example UTF–16) then the start and end parameters should always be even values (2, 4, 6, 8, etc.). If the text file uses 32 bit character encoding (for example UTF–32) then the start and end parameters should always be divisible by four (4, 8, 12, 16, etc.) No matter what encoding you are using, you will need to convert the binary data returned by the fileloadpartial( function into a text value using the binarytotext( function.

If the specified file contains actual binary data in a format that is known to you, you can use the fileloadpartial( function in accordance with your knowledge of the file structure.

Legacy Syntax (Separate Folder and File Parameters)

In older versions of Panorama (6.0 and earlier) the fileloadpartial( had four parameters, folderid, filename, start and end. To maintain compatibility with older databases, two parameters will still work, as shown in this example:

displaydata fileload(folder("~/Documentation"),"news.txt",40,24)

For new applications you’ll probably find it easier to use the new three parameter mode.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now may have either three parameters (path,start,length) or four (folder, path,start,length).