Seek

Moves the file pointer in an OLE stream object or displays a specified frame in an AVI clip in an animation control.

To

To

Move the read/write pointer in an OLE stream object.

Syntax 1

Displays a specific frame in an AVI clip

Syntax 2


Syntax 1: For OLE stream objects

Description

Moves the read/write pointer to the specified position in an OLE stream object. The pointer is the position in the stream at which the next read or write begins.

Applies to

OLEStream objects

Syntax

olestream.Seek ( position {, origin } )

Argument

Description

olestream

The name of an OLE stream variable that has been opened.

position

A long whose value is the position relative to origin to which you want to move the read/write pointer.

origin (optional)

The value of the SeekType enumerated datatype specifying where you want to start the seek. Values are:

  • FromBeginning! -- (Default) At the beginning of the file

  • FromCurrent! -- At the current position

  • FromEnd! -- At the end of the file


Return value

Integer.

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

-1 -- Stream is not open

-2 -- Seek error

-9 -- Other error

If any argument's value is null, Seek returns null.

Examples

This example writes additional data to an OLE stream. First, it opens an OLE object in the file MYSTUFF.OLE and assigns it to the OLEStorage object stg_stuff. Then it opens the stream called info in stg_stuff and assigns it to the stream object olestr_info. Seek positions the read/write pointer at the end of the stream so that the contents of the instance blob variable lb_info is written at the end.

The example does not check the functions' return values for success, but you should be sure to check the return values in your code:

boolean lb_memexists
OLEStorage stg_stuff
OLEStream olestr_info
 
stg_stuff = CREATE OLEStorage
stg_stuff.Open("c:\ole\mystuff.ole")
olestr_info.Open(stg_stuff, "info", &
      stgReadWrite!, stgExclusive!)
olestr_info.Seek(0, FromEnd!)
olestr_info.Write(lb_info)

See also

Open

Length

Read

Write

Syntax 2: For animation controls

Description

Displays a specific frame in an AVI clip in an animation control.

Applies to

Animation controls

Syntax

animationname.Seek ( s )

Argument

Description

animationname

The name of animation control displaying the AVI clip

s

A long value in the range 0 to 65,535 indicating the frame to display


Return value

Integer.

Returns 1 for success and -1 for failure.

Usage

Seek displays the specified frame. If you specify a value that is greater than the number of frames in the clip, Seek displays the last frame in the clip and returns 1. If you specify a value that is not in the specified range, Seek does nothing and returns -1. If the animation was playing, Seek always triggers the Stop event.

Examples

This code in a button's clicked event displays the frame specified by a number in a single line edit control, then increments the number by one. Each click of the button advances the clip by one frame:

// instance variable number
integer li_return
number = long (sle_seek.text)
li_return = am_1.Seek(number)
number +=1
sle_seek.text = string(number)

See also

Play

Stop