Deutsch English
Alphabetical index
Array functions
CGI functions
Data types
Date functions
Fulltext functions
Language elements
Numerical functions
Other functions
Ramtext functions
  • loadtemplate()
  • ramtext()
  • ramtext_copy()
  • ramtext_delete()
  • ramtext_find()
  • ramtext_insert()
  • ramtext_name()
  • ramtext_part()
  • ramtext_paste()
  • ramtext_subst()
  • subst()
    Socket functions
    Statistical functions
    Stream functions
    String functions
    System functions
    Table functions
    Text functions
    Home    Overview    Search    Impressum    Contact    Members
    Topic complex Ramtext functions
    Function subst()
    Short Replaces a string in the system ramtext
    Syntax SUBST(target : STRING; (replacement : STRING | db : INTEGER; field)[; mode : INTEGER]) : INTEGER
    Parameter target : any string
    replacement : any string
    db : table handle from OpenDB
    field : field number or field identiefier (as string)
    mode : INTEGER (0 = default)
    Return 0 : target not found
    # 0 : Substitution executed
    See also:
    loadtemplate() cgiwritetemplate()
    Description The SUBST function is a universal function. It is multiple overloaded that means it can be called with quite different parameters. Here the simplest form:

    SUBST(target,string) replaces the first appearance of target by string

    Example: We have a template in which we want insert the actual date and time (of server). There to in the template the following text is written:

    A Template for the tdbengine

    Date: #date#    Time: #time#

    That is an HTML site which was edited by the tdbengine

    (the welt of targets with '#' chars has exposed as quite advantageous because in this way the danger of confusion is very small)

    The template is stored at "templates/my_site.html". The following program solves our problem:

       cgiwriteln('content-type: text/html')
       IF LoadTemplate('templates/my_site.html')=0 THEN
         cgiwriteln('template not found')

    If the inserted string starts with »extern:«, this string is not inserted but the rest of the string is interpreted as path of a textfile. The content of this replaces then the target. Corresponding a string that starts with »ramtext:« refers to an internal text file.

    Just if the target shall be replaced by whole text files the kind of substitution is important: What happens with word wraps? In which character set shall the substitution executed? That can specified with another parameter, the »mode«.


    Replaces the target ...

    0 (default) -> Substitution without any further editing
    1 -> All chars are converted to HTML
    2 -> All chars are converted to ANSI
    4 -> Hard word wraps are replaced by »
    16 -> The external text is there in ASCII format (instead of ANSI)
    32 -> Only the BODY of an external HTML site is read

    These modes can be added to reach the wished aim. The mode 5 (=1+4) means for example that the chars are converted to HTML and hard word wraps are replaced by »

    Instead of raplacement string there can also be a combination of table handle and table field. Then the content of the specified field is inserted.

    Example: The following code replaces all fields of the database in the template:

    VAR i, db : INTEGER;

    User comments:
    Write a comment:
    Text (Switch mode)

    Choose between
    the normal and the
    advanced editor.
    The advanced editor
    runs in IE 5+ and
    Mozilla 1.4+ only
    SPAM-Protection Please enter tdbengine in this field.

    tdbengine chat

       Copyright © 2003-2004 tdb Software Service GmbH
       Alle rechte vorbehalten. / All rights reserved
       Last changed: 21.10.2004
    {Fehler für :execmacro{execmacro="sessionspy"}