SaveAs

Saves the contents of a DataWindow, DataStore, graph, OLE control, or OLE storage in a file. The syntax you use depends on the type of object you want to save.

For DataWindow and DataStore syntax, see the SaveAs method for DataWindows in the DataWindow Reference or the online Help.

To

Use

Save the data in a graph

Syntax 1 For graph objects

Save the OLE object in an OLE control to a storage file

Syntax 2 For saving an OLE control to a file

Save the OLE object in an OLE control to a storage object in memory

Syntax 3 For saving an OLE control to an OLE storage

Save an OLE storage and any controls that have opened that storage in a file

Syntax 4 For saving an OLE storage object to a file

Save an OLE storage object in another OLE storage object

Syntax 5 For saving an OLE storage object in another OLE storage


Syntax 1 For graph objects

Description

Saves the data in a graph in the format you specify.

Applies to

Graph controls in windows and user objects, and graphs in DataWindow controls and DataStores

Syntax

controlname.SaveAs ( { filename, } { graphcontrol, saveastype, colheading } )

Argument

Description

controlname

The name of the graph control whose contents you want to save or the name of the DataWindow DataStore containing the graph.

filename (optional)

A string whose value is the name of the file in which you want to save the data in the graph. If you omit filename or specify an empty string (""), PocketBuilder prompts the user for a file name.

graphcontrol (DataWindow control only) (optional)

A string whose value is the name of the graph in the DataWindow control or DataStore whose contents you want to save.

saveastype (optional)

A value of the SaveAsType enumerated datatype specifying the format in which to save the data represented in the graph. Values are:

  • CSV! — Comma-separated values

  • DIF! — Data Interchange Format

  • Excel! — Microsoft Excel format

  • SQLInsert! — SQL syntax

  • Text! — (Default) Tab-separated columns with a return at the end of each row

colheading (optional)

A boolean value indicating whether you want column headings with the saved data. The default value is true. Colheading is ignored for DIF files; column headings are always saved.

Returns

Integer. Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is null, SaveAs returns null.

Usage

You must use zero or three arguments. If you do not specify any arguments for SaveAs, PocketBuilder displays the Save As dialog box, letting the user specify the format of the saved data.

NoteRegional settings If you use date formats in your graph, you must verify that yyyy is the Short Date Style for year in the Regional Settings of the user’s Control Panel. Your program can check this with the RegistryGet function.

If the setting is not correct, you can ask the user to change it manually or to have the application change it (by calling the RegistrySet function). The user may need to reboot after the setting is changed.

Examples

Example 1

This statement saves the contents of the graph gr_History. The file and format information are not specified, so PocketBuilder prompts for the file name and save the graph as tab-delimited text:

gr_History.SaveAs()

Example 2

This statement saves the contents of gr_History to the file \WINDOWS\HR\EMPLOYEE.HIS. The format is CSV without column headings:

gr_History.SaveAs("\WINDOWS\HR\EMPLOYEE.HIS",CSV!,& 	       FALSE)

Example 3

This statement saves the contents of gr_computers in the DataWindow control dw_equipmt to the file G:\INVENTORY\SALES.XLS. The format is Excel with column headings:

dw_equipmt.SaveAs("gr_computers", &

       "G:\INVENTORY\SALES.XLS", Excel!, TRUE)

See also


Syntax 2 For saving an OLE control to a file

Description

Saves the object in an OLE control in a storage file.

Applies to

OLE controls

Syntax

olecontrol.SaveAs (OLEtargetfile )

Returns

Integer. Returns 0 if it succeeds and a negative number if an error occurs.


Syntax 3 For saving an OLE control to an OLE storage

Description

Saves the object in an OLE control to an OLE storage object in memory.

Applies to

OLE controls

Syntax

olecontrol.SaveAs ( targetstorage, substoragename )

Returns

Integer. Returns 0 if it succeeds and a negative number if an error occurs.


Syntax 4 For saving an OLE storage object to a file

Description

Saves an OLE storage object to a file. If OLE controls have opened the OLE storage object, this syntax of SaveAs puts them in a saved state too.

Applies to

OLE storage objects

Syntax

olestorage.SaveAs (OLEtargetfile )

Returns

Integer. Returns 0 if it succeeds and a negative number if an error occurs.


Syntax 5 For saving an OLE storage object in another OLE storage

Description

Saves an OLE storage object to another OLE storage object variable in memory.

Applies to

OLE storage objects

Syntax

olestorage.SaveAs ( substoragename, targetstorage )

Returns

Integer. Returns 0 if it succeeds and a negative number if an error occurs.