Save

Saves saves a picture and optionally overlay ink to a file or blob from an InkPicture control or saves an OLE object in an OLE control or an OLE storage object. The syntax you use depends on the type of object you want to save.

To

To

Save the contents of an InkPicture control

Syntax 1

Save an OLE object

Syntax 2


Syntax 1: For InkPicture controls

Description

Saves a picture and optionally overlay ink to a file or blob from an InkPicture control.

Applies to

InkPicture controls

Syntax

inkpicname.Save( t | b , format { , WithInk } )

Argument

Description

inkpicname

The name of the InkPicture control from which you want to save a picture.

t

A string containing the name and location of the file into which the picture will be saved.

b

The name of a blob passed by reference that will hold the picture in the control.

format

An integer specifying the format in which the picture is to be saved. Values are:

0 -- BMP (bitmap)

1 -- JPEG (Joint Photographic Experts Group)

2 -- GIF (Graphics Interchange Format)

3 -- TIFF (Tagged Image File Format)

4 -- PNG (Portable Network Graphics)

WithInk (optional)

A boolean specifying whether overlay ink should be saved with the picture. Values are:

True -- overlay ink is saved with the picture (default)

False -- overlay ink is not saved with the picture


Return value

Integer. Returns 1 for success and -1 for failure.

Usage

Use the Save function to save the image in an InkPicture control to a file or blob with or without any ink annotations that have been made to it. By default, the ink is saved with the image.

Examples

The following example saves the image in an InkPicture control and its ink annotations in bitmap format into a blob, and attempts to update the image in the database:

int li_return
blob lblb_ink

li_return = ip_1.save(lblb_ink, 0, true)
UPDATEBLOB employee SET backimage = :lbb_ink WHERE emp_id = :gi_id;
IF sqlca.SQLNRows > 0 THEN
   COMMIT;
ELSE
   messagebox("Update failed",sqlca.sqlerrtext)
END IF

The following example saves the image in an InkControl into a GIF file without any ink annotations:

int li_return
string ls_pathname, ls_filename

GetFileSaveName("Save As", ls_pathname, ls_filename, "GIF")
li_return = ip_1.save(ls_pathname, 2, false)

See also

LoadInk

LoadPicture

ResetInk

ResetPicture

SaveInk

Syntax 2: For OLE objects

Description

Saves an OLE object in an OLE control or an OLE storage object.

Syntax

oleobject.Save ( )

Argument

Description

oleobject

The name of an OLE control or an OLE storage variable


Return value

Integer. Returns 0 if it succeeds and one of the following negative values if an error occurs:

-1 -- Control is empty

-9 -- Other error

If oleobject is null, Save returns null.

Usage

When you save an OLE object, PowerBuilder saves it according to the current connection between it and an open storage or file. You establish an initial connection when you call the Open function. When you call SaveAs, the old connection is ended and a new connection is established with another storage or file.

When you call Save for an OLE control, PowerBuilder saves the object in the OLE control to the storage to which it is currently connected. The storage can be a storage object variable or a OLE storage file.

If the data has never been saved in the server application, so that there is no file on disk, the Save function in PowerBuilder returns an error.

When you call Save for a storage object variable, PowerBuilder saves the storage to the file, or substorage within the file, to which it is currently connected. You must have previously established a connection to an OLE storage file on disk, or a substorage within the file, either with Open or SaveAs.

When do you have to save twice?

If you create a storage object variable and then open that object in an OLE control, you need to call Save twice to write changed OLE information to disk: once to save from the object in the control to the storage, and again to save the storage to its associated file.

Examples

This example saves the object in the control ole_1 back to the storage from which it was loaded, either a storage object variable or a file on disk:

integer result
result = ole_1.Save()

This example saves a storage object to its file. Olestor_1 is an instance variable of type olestorage:

integer result
result = olestor_1.Save()

In a window's Open script, this code creates a storage variable ole_stor, which is declared as an instance variable, and associates it with a storage file that contains several Visio drawings. The script then opens one of the drawings into the control ole_draw. After the user activates and edits the object, the script for a Save button saves the object to the storage and then to the storage's file.

The script for the window's Open event includes:

OLEStorage stg_stor
stg_stor = CREATE OLEStorage
stg_stor.Open("myvisio.ole")
ole_draw.Open(ole_stor, "visio_drawing1")

The script for the Save button's Clicked event is:

integer result
result = ole_draw.Save()
IF result = 0 THEN ole_stor.Save()

See also

Close

SaveAs