Contact | Privacy | Datenschutzerklärung | Impressum

? Tag

Format: < ? Expression [Format] >

Purpose: Evaluates Expression and outputs the result in the given Format.

If no Format is given, Format defaults to 'H', if text is sent to the browser, 'A' otherwise. For more information on when text is sent to the browser, see the definition of the HTML mode.

If you need to exercise a finer degree of control over the outputted result, you can explictly specify one of six Format options. The format can be either a string expression or one of the words heitml, html, quoted, hstv, furl.

String Expression - The string expression must evaluate to an option string. Each character of the option string has its own meaning and special effect on the formatting done. A precise description is found below.

heitml - The evaluated expression itself is interpreted as heitml code and executed except for include statements. This way layouts or even complete heitml pages can be maintained in the database.

html1 - same as 'A' format, see below.

quoted1 - same as 'Q' (see 'Q' below), if text is not sent to the browser (see HTML mode). Otherwise, the evaluated expression is printed with 'H' format and surrounding double quotes.

hstv1 - same as 'Qh', see 'Q' below.

furl1 - same as 'U' format, see below.

String Format Parameters

In general, the formatting option string has the following format:
[Separator%] [Context] [Options] [Format]
We first give an introduction and afterwards a detailed description.

Separator a string of arbitrary characters excluding %. Context is one of the following characters (sequences): 'H','A','T','F','FT','Q','U','P','J'. Options are documented below. The Format is one of the following characters 'x','i','s','f','e','E','g','t' .

Context specifies for what context the output should be formatted. The Context defaults to 'H', if text is sent to the browser (see HTML mode), and 'A' otherwise. The Context 'H' which is a shortcut for HTML, means that the value is formatted in a way to be shown on a HTML page. In contrast, 'A' stands for ASCII-File. For example, formatting the string "x<p" prints the characters 'x','<','p' in the ASCII Context, but 'x','&','l','t',';','p' in 'H' Context. The < character is substituted so that the browser shows 'x<p' rather than interpreting the < character as an HTML tag.

Other Contexts are 'T' for inside an HTML table, 'F' for inside an HTML form, 'FT' for inside a form and inside a table, 'P' for an HTML tag parameter, 'Q' for inside an SQL query, 'J' for inside JavaScript code, and 'U' for inside an URL.

The Format character specifies different ways to format a value. These are dependent on the type of the value to be formatted. For strings, there is the 's' Format only, and 's' is the default. For integers, 'i' is the default, and other possibilities are 'x','X','o','c' for hexadecimal, octal or character representation. For reals, 'f' is the default, and other possibilities are 'e','E', and 'g' requesting different forms of scientific notation. For objects, there is the special 't' Format described later. If the data type does not match the Format character given, then the default Format is taken.

Also complete objects can be formatted. Without Options, the object is shown nicely as in debugging mode: if it is small enough in one line otherwise inside a table. With the Format character 't', all fields of the object are formatted with the format specified. The fields are separated by the Separator string.

There are various Options possible. Most important are : the 'n' option that will include the field name and a number specifying the field size.

Formatting Contexts

'H' - format for use inside an HTML document: The field is formatted to be shown by the browser. Special characters that the browser interprets as formatting control are replaced ( '<' is replaced by &lt, '>' by &gt, &' by &amp, 'ˆ' by &circ and '"' by &quot). 'H' is the default format, if text is sent to the browser (see HTML mode) and it should usually be used when embedding data in an HTML page.

For objects, the Separator defaults to a space character.

'T' - format for use inside an HTML table: Formatting is very similar as with 'H'. However the field is enclosed in <td> and </td> tags. This is convenient especially when an object is formatted, because the <td> and </td> tags are put around each field. Field alignment is handled by specifying the align parameter in the <td> tag, normally strings are left aligned and numbers are right aligned.

For objects, the Separator defaults to a newline character.

'F' - format for use inside an HTML form: An HTML form-text-field is created using the HTML-<input> tag. The value to be formatted is put into the text-field. As a name the field receives the name of the variable or object field being formatted. The field size is taken from the field size option specified in the format string. Using the 'h' option, also hidden fields can be created.

For objects, the Separator defaults to a newline character.

'TF' or 'FT' - format for use inside an HTML form and a table: This combines table and form Context ('T' and 'F'). Form fields are produced, embedded in <td> and </td> tags.

'P' - format for use inside an HTML tag: This format applies when creating an HTML tag definition. For example, if you want to create an HTML-<img> tag where the filename is stored in a variable named src

< img src=< ? src "P" > >
the field content will automatically be put in double quotes and special characters are replaced. Using the 'n' option, the field name followed by an equal sign is written before the field content:
< img < ? src "Pn" > >

For objects, the Separator defaults to a space character, so it is possible to format an object in order to pass multiple parameters.

'J' - format for use in JavaScript code: The value is formatted to be used in JavaScript code. String values are put in double quotes and special characters of JavaScript, like carriage return and newline are escaped.

For objects, the Separator defaults to a semicolon.

'U' - format for use inside the query part of an URL: The value is formatted to be used inside the query part of an URL which are the characters following the ? character.

For objects, the Separator defaults to &amp; as required for URLs.

Characters in the query part of an URL are encoded in the following way: all characters with ASCII code < 32 and > 126 and any of the following characters are replaced by the corresponding octet which is written as a character triplet %XX with X denoting a hexadecimal digit: & ? + ~ ` ! # $ % ( ) = ^ [ ] { } ; ' \ : " | , / < >
The space character is replaced by the + character.

'UF' - format for use inside the Front part of an URL: The value is formatted to be used inside the Front part of an URL which are the characters preceding the ? character.

According to RFC1808, characters in the front part of an URL are encoded in the following way: all characters with ASCII code < 32 and > 126 and any of the following characters are replaced by the corresponding octet which is written as a character triplet %XX with X denoting a hexadecimal digit: ? ~ ` # % ^ [ ] { } \ " | , < >
The space character is replaced by %20.

'A' - format for use inside an ASCII text: The value is formatted to be used in an ASCII text. No character replacement is performed. 'A' is the default format if text is not sent to the browser (see HTML mode). The 'A' format can also be used to insert a string into an HTML document without doing any character translation.

For objects, the Separator defaults to a tabulator character. So formatting of an object results in a field list, separated by tabs.

'Q' - format for use inside a query: The value is formatted to be used inside an SQL query as a field content. It is enclosed in quotes and special characters are encoded as required for the database system at hand.

Using the 'n' option, the field name followed by a '=' sign is written before the value. This is useful inside an SQL-update statement or in a search condition.

For objects, the Separator defaults to a comma, so the value list for an SQL-update statement can be directly produced.

If the database system is capable of handling host variables, the 'h' option will print a '?' sign for the value and will put the value in a special data structure of the database system where it is read from when the SQL-update statement is executed. The 'h' option can only be used inside a dbupdate Tag.

If text is sent to the browser or to a file (see HTML mode), the field content is printed in double quotes. Otherwise, the 'Q' format uses the quoting mechanism of the underlying database system.

Format Characters

For String Values, only 's' is allowed, and 's' is the default.

For Integer Values, 'i' is the default. It will print the integer value as a decimal number. 'x' will print it as a hexadecimal number using lowercase letters. 'X' will print a hexadecimal number using uppercase letters. 'o' will print the number in octal. If a precision option is given, it gives the minimal number of digits to be displayed. If necessary leading zeros are inserted.

For Real Values, 'f' is the default. It will print the real number in the form dd.dd where dd is a sequence of digits. As precision option the number of digits after the decimal point can be specified, the default is 6. The 'e' Format will display the real number in exponential representation. 'E' does the same, but uses a capital E to show the exponent. 'g' (or 'G') will use either 'f' or 'e' (or 'E') Format. 'e' is used if the precision is smaller than the exponent or if the exponent is less than -4. The precision here give the number of significant digits.

The number formatting Options are very similar to those of the C printf library function. If you are interested in a more detailed discussion please refer to these.

For objects, there are two fundamental different formatting mechanisms. In 'H' Context, an object is formatted by an intelligent formatting routine, that tries to show the object in the most readable way. If the object is small, it is printed within one line, if it is bigger it is printed in form of a table. Nested objects are also shown, up to a sensible limit. This formatting option is very good for debug and test output, as well as applications that do not require a customized format. Using the 'n' option, the object name followed by an '=' sign is printed before the formatted object.

The other way of object formatting applies in all Contexts other than 'H', or when using the 't' Format in 'H' Context. All fields of the object are formatted with the same given format. The fields are separated by the Separator string given, or the Contexts default Separators described above. Using the 'n' option, the field name can be printed for each field. If the 't' Format character is used with the 'n' option in any Context other than 'H', field names have the form objectname.fieldname. Objectname is the name of the object variable that is formatted, fieldname the name of the current object field. Nested objects are not displayed. Fields containing null are displayed according to the 'N' option, including the Separator. If 'Nv' is specified, fields containing null are completely left out (including the Separator and the field name).

Options

'n' - Include the field name The field name is included into the formatting. If the expression to be formatted is a variable, then the variable name is taken. If an object field is displayed then the field name is taken. Otherwise the field name is empty and the 'n' option has no effect.

In 'H', 'A', 'F', 'P', 'Q', 'J', and 'U' Contexts, the field name followed by a '=' sign is printed before the formatted value. In 'T' and 'TF' Context, a table column containing the name is shown before the table column containing the value.

If a Boolean variable is formatted with Context 'P', no '=' sign and value is printed and the variable name is only printed if the variable value is true.

Using the 'n' option to format an object in 'H' Context, prints the name of the object. If an object is formatted in field list format (using 'Ht' or any other Context), then the 'n' option will include the field names for each field of the object. In any Context other than 'H', using the 't' format together with the 'n' option prints objectname.fieldname.

dd - Field Size dd must be a sequence of digits or spaces. They specify the minimal field size. If the field content is smaller then the field is filled up with spaces (or zeros, see option '0'). Numbers are shown right justified, strings left justified. In 'F' and 'TF' Context, the field size is also taken as the size of the form field.

.dd - Precision dd must be a sequence of digits or spaces. If field size and precision are given, then precision must be given immediately after the field size. The precision can have very different meanings, depending on the Format character. Please read the documentation of the Format character you are using.

'-' - Alternative Alignment With this option, numbers are left aligned and strings are right aligned.

'D' - Use Default Function The default() function is used on the argument before it is formatted: If the variable or the object field that should be displayed is not declared then null is assumed. Normally an undefined variable error message is shown.

'N'x - Handling of Null Values The capital N must be followed by another character that specifies how null values are formatted. Possibilities are '0' to display an integer '0', 'r' to display a real '0.0', 'e' to display an empty string, 'b' to display 'false', 's' to display a string consisting of one space. Other possibilities are 'n' to display 'null', 'N' to display 'NULL', 'S' to display &nbsp, and 'v' to display nothing.

'v' is special, it does not even display the field name and the Separator. It is useful in 'P', 'U', and 'Q' Contexts to completely leave out the fields containing null. The 'S' is useful to display a normal but empty table cell in HTML. HTML normally displays empty table cells in a different layout.

In 'H', 'P', 'U', and 'A' Context, 'v' is the default. In the 'Q' Context, 'N' is the default. In the 'J' Context, 'n' is the default. In 'T', 'F', and 'TF' Contexts, 'e' is the default.

'NV' - does not show a value This is useful to display the field name only. So 'NV' prints all field names of an object separated by commas, "\t%NV" prints them separated by tabs.

'h' - create hidden fields or handle host variables This Options is valid in 'F', 'FT' and 'Q' Contexts only. In 'F' and 'FT' Contexts, it creates hidden fields instead of normal text form fields.

With a 'Q' Context, the 'h' option can only occur inside a dbupdate Tag. If the database system is capable of handling host variables, the 'h' option will print a '?' sign for the value and will put the value in a special data structure of the database system where it is read from when the SQL-update statement is executed.

'0' - Zero Padding Fields are padded with zeros instead of blanks.

'+' - Show Sign For non negative numbers, a '+' sign is printed. Normally a sign is printed for negative numbers only.

' ' - Show a space for the + sign Leaves a space as sign for positive numbers.

'#' - Alternative Format In real formatting, always a decimal point is shown, even if not followed by a digit. Octal conversions start with a leading 0. Hexadecimal conversions start with 0x or 0X for x and X Formats respectively.

Examples

Let's look at some more examples of how the ? tag can be used:

Example:

Quoted Data <? "H(e)i 2 all of U">
A Local Variable <? VariableName>
A Global Variable <? gl.VariableName>
An object Variable <? ObjectName.ObjectField>
A Server Variable <? SrvUserAgent>
A Numerical Formula <? sqr(4)*5>
A String Formula <? FirstName+" "+LastName>
A Mixed-Data Formula <? Item+" costs $"+(Price*.80)>

Here is what heitml does without any format specification, if text is to be sent to the browser (see HTML mode):

Example:

heitml input: heitml sends to Client Browser: Browser displays:
<let x="Text1<p>Text2">
<? x>
Text1&lt;p&gt;Text2 Text1<p>Text2

Here is what heitml does with the 'A' (html) format:

Example:

heitml input: heitml sends to Client Browser: Browser displays:
<let x="Text1<p>Text2">
<? x "A">

Text1<p>Text2

Text1

Text2

Here is what heitml does with the 'Q' or quoted format:

Example:

input:resulting output:
  <let x = "message<br >">
  <? x>
  <hr>
  <? x quoted>
  <hr>
  <? x "Q">
  
  message

'message
'
'message
'

Using the ? tag with a string format parameter makes lots of formatting options available. The following example prints a real constant with two digits after the decimal point:

Example:

input:resulting output:
<? 55.666 ".2">55.67

However, heitml's formatting options go far beyond. For example, the 'T' Context formats a value for use in an HTML table as illustrated below.

Example:

input:resulting output:
<let x="Numbers are right aligned"; y=700>
<\table border>
<\tr> <? y "Tn"> <\/tr>
<\tr> <? x "Tn"> <\/tr>
<\/table>

y700
xNumbers are right aligned

The 'n' option character in the example causes heitml to include the variable name.

Using the 't' format together with the 'n' option, you can dump objects in customized format. The following example uses a newline character to separate object fields:

Example:

input:resulting output:
<let x=emptytuple;x.a="a";x.b="b";x.c="c";
? x "\n%Ant">
x.a=a
x.b=b
x.c=c

Finally, here is an example of how to use the heitml format:

Example:

input:resulting output:
<def Pic><img src="heitmlsm.jpg"></def;

 def Slogan
><b>h<i>ei</i>tml takes the<br >
World Wide Web<br > to a higher level! </b><
/def;

 let x = "<Pic>" + "<p >" + "<Slogan>";
 ? x heitml></p>

heitml takes the
World Wide Web
to a higher level!

1 Format is deprecated.


This page was dynamically generated by the web application development tool RADpage of H.E.I. H.E.I. provides support, tools, and services like Webdesign in Mannheimm, the HTML/CSS 3D WebGL Animation Library taccgl, 3D Webdesign, and 3D Product Configurator (3D Produkt Konfigurator in German).

Selected blog articles : 3D Objects on HTML pages, CSS Transition Visibility, and CSS Transition Display.


© 1996-2024 H.E.I. All Rights Reserved.



Homepage
Intro/Features
Component Guide
Programming
  Language Guide
  Language Ref.
    General Design
    Lexical Structure
    Expressions
    Objects
    Methods
    Classes
    heitml Tags
      ? Tag
      assign Tag
      break Tag
      callenv Tag
      dbdatabase Tag
      dbquery Tag
      dbupdate Tag
      def Tag
      defautoclose Tag
      defbody Tag
      defclass Tag
      defcontpara Tag
      defenv Tag
      defhtml Tag
      definpara Tag
      defpara Tag
      defremovecdata Tag
      deftranspara Tag
      defwysiwyg Tag
      for Tag
      forin Tag
      forsep Tag
      if Tag
      elsif Tag
      else Tag
      include Tag
      includeonce Tag
      inherit Tag
      let Tag
      mail Tag
      return Tag
      shell Tag
      while Tag
      writefile Tag
      \ Tag
    heitml Functions
    Advanced Functions
    Database Access
    Global Variables
    Form Fields
    Server Variables
    Sessions
    heitml Syntax
  Component Ref.
  Class Library
  User Components
  Tutorial
  New Features
  heitml 1
User Guide
Services
Privacy
Datenschutz
 
Contact / Impressum