Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
SpeedScript : Overview of Embedded SpeedScript
 

Overview of Embedded SpeedScript

Embedded SpeedScript provides a way for you to build Web objects directly from standard HTML files by including SpeedScript as a scripting language.
An Embedded SpeedScript file looks like a static HTML file in which you embed a section of SpeedScript code using statement escapes. The following shows a simple example where Embedded SpeedScript is used to query the Sports2000 database:

escript1.htm

<HTML>
<HEAD>
<TITLE>My First Embedded SpeedScript File</TITLE>
</HEAD>
<BODY>
<H1>My First Embedded SpeedScript File</H1>
<SCRIPT LANGUAGE="SpeedScript">
FOR EACH Customer WHERE Customer.Name BEGINS "s" NO-LOCK:
  DISPLAY {&WEBSTREAM} Customer.
END.
</SCRIPT>
<HR>
</BODY>
</HTML>
The HTML code in boldface shows the embedded SpeedScript. Note that SpeedScript, like JavaScript, can be embedded by using the HTML <SCRIPT> tag. However, SpeedScript differs from JavaScript with respect to execution. JavaScript typically executes on the client. SpeedScript executes entirely on the WebSpeed Transaction Server. Server-side execution allows the embedded SpeedScript to reference Web object variables and database fields from anywhere in the HTML file.
The Web object generated from escript1.htm outputs a Web page that lists all customer records in the sample Sports2000 database with names that begin with the letter "s."
Note: {&WEBSTREAM} ensures that all DISPLAY statement output goes to the same stream as {&OUT}. For more information, see HandlingDISPLAY Output
When you write an HTML file that includes embedded SpeedScript, the AppBuilder converts the HTML file to a SpeedScript Web object that generates the actual Web page. This Web page can be a simple static or a complex dynamic Web page with programmatically varied content.
You can actually write embedded SpeedScript to generate one of two types of WebSpeed output file:
*Complete Web objects, ready to execute, that can handle both output to and input from the Web.
*SpeedScript include files that you can include in the SpeedScript source code of other Web objects for later compilation.
You can specify the type of output file to generate by using a <META> tag in the HTML head section. The default output file is a Web object. Embedded SpeedScript also supports <META> tags to specify HTTP options such as the character set of the HTML file. You can also specify <META> tag information in the HTML body using WebSpeed <!--WSMETA --> custom tags. For more information, see Using<META> and <!--WSMETA --> tags.