Chapter 5:
File I/O
|
This chapter describes the file I/O functions that are available in the PGSDK library: |
|
|
||
|
||
|
|
PGSDK includes the following generic file input/output functions that can be used in any application development platform: |
|
|
IOclose: Platform independent file close |
|
|
IOconnect: Associates platform specific file reference w/IO path structure |
|
|
IOgetc: Platform independent getc - get a character from file |
|
|
IOgets: Platform independent gets - get a string from file |
|
|
IOopen: Platform independent file open |
|
|
IOread: Platform independent read - read from file |
|
|
IOseek: Platform independent seek - seek into file |
|
|
IOwrite: Platform independent write - write to file |
|
A PGSDK graph can be loaded from or saved to a Tagged Information File Format (TIFF) file. The Load_TIFFGraph() function loads a TIFF format file into a 3D Graph Structure. The graph structure identified by pGraph must be preallocated and zeroed before this function is called: |
|
|
INT16 Load_TIFFGraph ( |
|
|
The Save_TIFFGraph() function saves a graph structure into a binary or ASCII file. |
|
|
INT16 Save_TIFFGraph ( |
|
|
In both functions, the ulRequest parameter can be used to identify the information to be loaded or saved: |
|
|
REQUEST_TIFFTHUMBNAIL (0x0100): TIFF Thumbnail |
|
|
REQUEST_TDL (0x00DF): Look of the graph only (template) |
|
|
REQUEST_TDC (0x00FF): Look of the graph and chart data |
|
|
REQUEST_TDF (0x01FF): Look of the graph and chart data and TIFF Thumbnail |
|
|
REQUEST_THUMBFILEDESCRIPTION (0x0200): Thumbnail File Description |
|
|
See the PGSDK API Guide for a description of these and other API functions that support the TIFF file format. |
|
|
The following code segment shows how these functions are used to save and load a graph: |
|
|
nError=TestStruct_PackAllDummyData((GraphPtr) |
|
The RAM file functions provide your application with the ability to save a chart to memory instead of a file. |
|
|
AllocRamFile; allocate a RAM File memory structure |
|
|
FreeRamFile; free a RAM File memory structure |
|
|
GetRamFileName; returns an ASCII coded character name for RAM File |
|
|
GetRamFileBuffer; get memory address of RAM File |
|
|
AllocRamFile: The first step in using a RAM file is to allocate a memory structure to hold the contents of the graph. The AllocRamFile() function allocates a RAM File memory structure and returns a pointer to the allocated memory location as shown in the following example: |
|
|
/*** Create a new ramfile*/ |
|
|
GetRamFileName: This function returns an ASCII coded character name for the RAM File. |
|
|
/* Convert ramfile ptr to a |
|
|
GetRamFileBuffer: This function gets the memory address of RAM File. |
|
|
/* Get memory address of ramfile */ |
|
|
FreeRamFile: This function frees the RAM File memory structure. |
|
|
/* Destroy the ramfile */ |