Difference between revisions of "Working with Multimedia Data"

From Recital Documentation Wiki
Jump to: navigation, search
(Inserting Multimedia Data using Recital Navigational Data Commands)
 
(17 intermediate revisions by one user not shown)
Line 1: Line 1:
 
==Working with Multimedia Data==
 
==Working with Multimedia Data==
===Inserting Multimedia Data using Recital Navigational Data Commands===
+
Multimedia data can be stored in Recital tables in object [[Appendix A|datatype]] fields.  The data is stored in binary large object (BLOB) format in the ''.dbt'' file, with a corresponding pointer in the table record.
OBJECTREAD(<filename>,<object field>)  
+
  
The OBJECTREAD() function reads an external binary file into a Recital Object field. It returns .T. if the operation was successful, and .F. otherwise.
+
Recital provides the following functions to handle the transfer and querying of multimedia data:
  
The file to read in is specified in <filename>, and can be any valid Recital/4GL expression that returns a valid file name. The first three characters of the file extension are stored in the Object field as the Objects type, as returned by the OBJECTTYPE() function.
+
* [[OBJECTREAD()|objectread()]] - read a binary file into a Recital object field
 +
* [[OBJECTWRITE()|objectwrite()]] - write the contents of a Recital object field to a binary file
 +
* [[OBJECTTYPE()|objecttype()]] - return the type of a Recital object field, e.g. ''jpg''
  
The field into which the file is placed is specified in <object field>, and must be a Recital Object field in the currently selected workarea.
+
===Inserting Multimedia Data===
 +
<pre>
 +
objectread(<filename as character>,<fieldname as character>)
 +
</pre>
  
===Inserting Multimedia Data using Recital SQL===
+
The [[OBJECTREAD()|objectread()]] function reads an external binary file into a Recital object field. It returns true (.T.) if the operation was successful, and false (.F.) otherwise.
===Retrieving Multimedia Data using Recital Navigational Data Commands===
+
 
===Retrieving Multimedia Data using Recital SQL===
+
The file to read in is specified in <filename>, and can be any valid Recital expression that returns a valid file name.  The first three characters of the file extension are stored in the object field as the object's type, as returned by the [[OBJECTTYPE()|objecttype()]] function.
===Summary===
+
 
 +
The field into which the file is placed is specified in <object field>, and must be a Recital object field in the currently selected workarea.
 +
 
 +
'''Example'''
 +
 
 +
<code lang="recital">
 +
open database southwind
 +
use categories
 +
objectread("newpic.jpg",picture)
 +
close databases
 +
</code>
 +
 
 +
===Retrieving Multimedia Data===
 +
 
 +
<pre>
 +
objectwrite(<filename as character>,<fieldname as character> [, <tempfile as logical>])
 +
</pre>
 +
 
 +
The [[OBJECTWRITE()|objectwrite()]] function writes an external binary file from a Recital object field. The objectwrite() function returns true (.T.) if the external binary file was created successfully, and false (.F.) otherwise.
 +
 
 +
The name of the file to create can be specified in the parameter <filename>.  This can be any valid Recital expression that returns a valid filename.  The filename can also be an empty string, providing that the logical expression <expL> is true (.T.).  In this case, a unique temporary file name will be generated and the object written to this file, with the file name being returned from objectwrite().
 +
 
 +
The Recital object field containing the data to be written, is specified in the parameter <object field>, and must be a valid field in the currently selected workarea.
 +
 
 +
'''Example'''
 +
 
 +
<code lang="html">
 +
<%
 +
open database southwind
 +
use categories
 +
scan
 +
m_file = "__"+ltrim(str(recno()))+".jpg"
 +
? '<img src="'+objectwrite(m_file,picture,.t.)+'"><br>'
 +
endscan
 +
close databases
 +
%>
 +
<body bgcolor="#FFFFFF" text="#000000">
 +
</body>
 +
</code>

Latest revision as of 16:42, 17 March 2010

Working with Multimedia Data

Multimedia data can be stored in Recital tables in object datatype fields. The data is stored in binary large object (BLOB) format in the .dbt file, with a corresponding pointer in the table record.

Recital provides the following functions to handle the transfer and querying of multimedia data:

  • objectread() - read a binary file into a Recital object field
  • objectwrite() - write the contents of a Recital object field to a binary file
  • objecttype() - return the type of a Recital object field, e.g. jpg

Inserting Multimedia Data

objectread(<filename as character>,<fieldname as character>)

The objectread() function reads an external binary file into a Recital object field. It returns true (.T.) if the operation was successful, and false (.F.) otherwise.

The file to read in is specified in <filename>, and can be any valid Recital expression that returns a valid file name. The first three characters of the file extension are stored in the object field as the object's type, as returned by the objecttype() function.

The field into which the file is placed is specified in <object field>, and must be a Recital object field in the currently selected workarea.

Example

open database southwind
use categories
objectread("newpic.jpg",picture)
close databases

Retrieving Multimedia Data

objectwrite(<filename as character>,<fieldname as character> [, <tempfile as logical>])

The objectwrite() function writes an external binary file from a Recital object field. The objectwrite() function returns true (.T.) if the external binary file was created successfully, and false (.F.) otherwise.

The name of the file to create can be specified in the parameter <filename>. This can be any valid Recital expression that returns a valid filename. The filename can also be an empty string, providing that the logical expression <expL> is true (.T.). In this case, a unique temporary file name will be generated and the object written to this file, with the file name being returned from objectwrite().

The Recital object field containing the data to be written, is specified in the parameter <object field>, and must be a valid field in the currently selected workarea.

Example

<%
open database southwind
use categories
scan
m_file = "__"+ltrim(str(recno()))+".jpg"
? '<img src="'+objectwrite(m_file,picture,.t.)+'"><br>'
endscan
close databases
%>
<body bgcolor="#FFFFFF" text="#000000">
</body>