User Manual table of contents
 INDEX | GETTING STARTED | TASKS | LANGUAGE | LIBRARY | SYSTEM | SAMPLES

Introduction to pop!talkTM

On this Page
Overview
System Elements
Variables and Expressions
User-Defined Macros
Objects, Methods and Properties


Home
Products
*Tour
*Manual
Corporate
Support
Search



!
Quick Reference
Object Types
System Properties
System Methods
Command-Line
Binary Operators





Overview

pop!talk is a superset of HTML. When you use pop!siteTM, you are composing pop!talk documents and pop!site translates them into plain HTML.

<em>pop!site</em> converts <em>pop!talk</em> to HTML

Because HTML is the foundation of pop!talk, it's important to understand some key HTML terms that we use:

  • Element
  • Tag
  • Attribute
  • Container Elements vs Empty Elements
  • Minimization
  • Entity

If you're not comfortable with these terms, you should review our quick Key Concepts in HTML page before proceeding.

To begin to write pop!talk documents, you must have a basic understanding of the following concepts:

  • Built-in Elements
  • Variables and Expressions
  • User-Defined Macros
  • Objects, Methods and Properties

In the following sections, you'll find an introduction to each of these concepts. At the bottom of some sections, you'll find a link to a more comprehensive discussion of the topic.

System Elements

When processing a document, pop!site (generally) ignores HTML tags and simply passes them on to the output document for processing by a browser. pop!talk, however, supports a variety of additional built-in system elements which are processed immediately by pop!site.

As an example, pop!talk supports an <include> element that lets you insert the contents of a secondary "include file" into your main document.

The include element in action.

Examples of additional system elements include:

  • <if> - Conditional processing
  • <define> - Define a macro
  • <env> - Access environment variables
  • <maindocument> - Access information about a document
  • <random> - Generate a random number

Variables and Expressions

HTML supports a variety of entities. For example, the HTML entity &lt; produces a "<" symbol. pop!talk extends this entity feature and allows you to define your own entities, called variables.

As an example:

&(thisyear = 43)
&(nextyear = thisyear + 1)
<p>My age this year is &(thisyear);.
<p>Next year I will be &(nextyear); years old.

After processing by pop!site, this will produce:

<p>My age this year is 43.
<p>Next year I will be 44 years old.

In this example, thisyear and nextyear are variables. The sequences between the &( and the ) are called expressions.

In the first two expressions, we are setting the values of our two variables. In the second two expressions, we are obtaining the values of the variables.

As a convenience, you can leave off the parentheses in an expression if you're just refering to the value of a variable. In this case, you can even leave off the trailing semicolon if the next character is something other than a digit or letter. Thus the above example could also be written:

&(thisyear = 43)
&(nextyear = thisyear + 1)
<p>My age this year is &thisyear.
<p>Next year I will be &nextyear years old.

As an additional convenience, you can also embed some simple references to variables in quoted strings.

More Information: Variables and Expressions.

User-Defined Macros

In addition to HTML's elements and pop!talk's system elements, authors can also define their own elements (called macros). A macro is a fragment of pop!talk that is used whenever the macro is referred to.

Imagine that you're building a document and you want to put a navigation toolbar at the top of each page on a personal web site you're building. You might want this toolbar to look like this:

TOP - BIOGRAPHY - VACATIONS - FAMILY

Each of these four items would be links to the different sections of your site. The HTML to produce this toolbar would be:

<strong>
<a href="top.html">TOP</a> -
<a href="biography.html">BIOGRAPHY</a> -
<a href="vacations.html">VACATIONS</a> -
<a href="family.html">FAMILY</a>
</strong>

To have this tool bar on every page, you'd have to paste this sequence into each HTML document on your site. For example:

TOP.HTML BIOGRAPHY.HTML etc...
<html>
<head>
<title>Top Page on My Site</title>
</head>
<body>
<strong>
<a href="top.html">TOP</a> -
<a href="biography.html">BIOGRAPHY</a> -
<a href="vacations.html">VACATIONS</a> -
<a href="family.html">FAMILY</a>
</strong>
Blah
Blah
Blah
</body>
</html>
<html>
<head>
<title>Biographical Info About ME!</title>
</head>
<body>
<strong>
<a href="top.html">TOP</a> -
<a href="biography.html">BIOGRAPHY</a> -
<a href="vacations.html">VACATIONS</a> -
<a href="family.html">FAMILY</a>
</strong>
Here is information about me!
</body>
</html>

Unfortunately, changing your mind about the appearance or contents of this toolbar will be a pain because you'll have to go change each page again. Using pop!talk, you'd define a macro for your toolbar. Macros are defined using the built-in <define> element:

<define name="toolbar" empty>
<strong>
<a href="top.html">TOP</a> -
<a href="biography.html">BIOGRAPHY</a> -
<a href="vacations.html">VACATIONS</a> -
<a href="family.html">FAMILY</a>
</strong>
</define>

Here we have defined a new empty element (one without an end tag) called toolbar. We can immediately use this macro in place of the explicit HTML:

TOP.PT BIOGRAPHY.PT etc...
<html>
<head>
<title>Top Page on My Site</title>
</head>
<body>
<toolbar>
Blah
Blah
Blah
</body>
</html>
<html>
<head>
<title>Biographical Info About ME!</title>
</head>
<body>
<toolbar>
Here is information about me!
</body>
</html>

Of course, each document must "know" about the definition of toolbar. This is handled by placing the macro definition in an additional "include file" which each document will "include." Thus:

MACROS.PTI
<define name="toolbar" empty>
<strong>
<a href="top.html">TOP</a> -
<a href="biography.html">BIOGRAPHY</a> -
<a href="vacations.html">VACATIONS</a> -
<a href="family.html">FAMILY</a>
</strong>
</define>

TOP.PT BIOGRAPHY.PT etc...
<include file="macros.pti">
<html>
<head>
<title>Top Page on My Site</title>
</head>
<body>
<toolbar>
Blah
Blah
Blah
</body>
</html>
<include file="macros.pti">
<html>
<head>
<title>Biographical Info About ME!</title>
</head>
<body>
<toolbar>
Here is information about me!
</body>
</html>

In the above example, we defined a simple empty macro (one with no end tag). Let's also define a container macro. A common use for container macros is wrapping a section of a document with some extra elements. In the example above, the standard HTML tags (<html>, <body>, etc) are a good candidate for a container macro. Let's define a new element called doc which takes care of all these common HTML tags. With the new macro we'll be able to say:

TOP.PT BIOGRAPHY.PT etc...
<include file="macros.pti">
<doc heading="Top Page on My Site">
<toolbar>
Blah
Blah
Blah
</doc>
<include file="macros.pti">
<doc heading="Biographical Info About ME!">
<toolbar>
Here is information about me!
</doc>

Our new <doc> macro will be defined like this:

<define name="doc" attributes="heading" container>
<html>
<head>
<title>&heading;</title>
</head>
<body>
&contents;
</body>
</html>
</define>

Important things to note about this macros include:

  • The "container" indicator in the <define> tells us that we're defining a container macro (instead of an empty one).
  • The "attributes" attribute tells us what attributes our newly-defined <doc> tag will use. In this case, there's only one and it's called heading.
  • We refer to the value of the heading attribute in the macro using &heading. When the macro is used (as in the above examples), this will be replaced with the actual value of the heading attribute.
  • We refer to everything between <doc> and </doc> using a special variable called &contents;.

More Information: Defining Macros.

Objects, Methods and Properties

There are two kinds of elements: properties and methods.

  • property - a quality or trait of something
  • method - an activity or function that is performed

With pop!talk, you'll be dealing with a variety of objects (for example, Documents, TimeStamps, and Strings). These objects have elements (properties and methods) called object elements. For example, a String object, has a length property, and a substring method (which divides the String into pieces).

In the case of system elements (system properties and system methods), we're dealing with aspects of pop!site as a whole. For example, there is a system method <read> which reads information from a file.

Thus we have:

System Properties Object Properties
System Methods Object Methods

When using properties (and some methods), you're manipulating objects. When you refer to a property or method, you "get" an object which you can then manipulate. As described above, these objects have properties and methods. To understand what you can do with a particular object, you must consider its type: objects of different types have different properties and methods. Consider String and Number objects. You can capitalize a String - but not a Number. You can subtract one from a Number - but not from a String.

To understand how you might use objects, let's examine the system property <maindocument>. When you refer to this property, you get a Document object. Document objects have timestamp and filename properties:


Using
You Get

<maindocument.timestamp>
a TimeStamp object which identifies when the document was last modified
<maindocument.filename>
a FileName object which holds the location of the pop!talk file for the document

Imagine that you wanted each of your web pages to identify when it was last changed. You could place this pop!talk into your document:

Last modified: <maindocument.timestamp>

This first gets the system property maindocument (a Document object), and then asks it for its timestamp property (producing a TimeStamp object).

Taking this example further, the TimeStamp object has properties, so you could say:

Last modified on <maindocument.timestamp.dayofweek>.

which might produce something like:

Last modified on Monday.

Of course, dayofweek property gives you a String object which you could further manipulate...

More Information: List of System Methods.
More Information: List of System Properties.
More Information: List of Object Types.

 


powered by pop!site Copyright 1995-1997. Pragmatica, Inc. All Rights reserved.
Pragmatica, pop!site and pop!talk are trademarks of Pragmatica, Inc.
Modified: 07 March, 1997 23:47:22

Page Feedback
Webmaster Contact