Deutsch English
Alphabetical index
Array functions
CGI functions
Data types
Date functions
Debugging
Fulltext functions
Language elements
  • 'ANWEISUNGEN'
  • 'AUSDRÜCKE'
  • 'BEZEICHNER'
  • DEF
  • IF
  • 'INDEXBESCHREIBUNG'
  • 'KONSTANTEN'
  • MODULE
  • PROCEDURE
  • REPEAT
  • RETURN
  • USES
  • VAR
  • WHILE
    Numerical functions
    Operators
    Other functions
    Ramtext functions
    Selecting
    Socket functions
    Statistical functions
    Stream functions
    String functions
    System functions
    Table functions
    Text functions
    Home    Overview    Search    Impressum    Contact    Members
    Topic complex Language elements
    Function PROCEDURE
    Short Introduces a procedure
    Syntax PROCEDURE Bezeichner[(Parameterliste)][: Grundtyp];
    Parameter parameter_list::=parameter{;parameter}.
    parameter:=[VAR ]identifier_list : type.
    identifier_list::=identifier{, identifier}.
    type::=basic_type [Arraydef].
    basic_type::=CHAR|BYTE|INTEGER|REAL|STRING|MARKS|TBITS.
    Arraydef:=[dimension_list].
    dimension_list::=number{,number}.
    Return
    See also:
    MODULE
    Description Every executable module must include the procedure with name "Main".

    Is a result type defined at declaring a procedur, it is a function-procedure which can be used in expressions.

    A procedur has always the following structure:

    PROCEDURE

    ENDPROC

    The procedure head is composed of a coercible procedure name, an optional paramter list and an optional result type.

    The calling of a procedure is takes place by defining its name in expressions. Because a procedure is already known in its own body direct recursion is possible.

    Example for a simple procedure:
    PROCEDURE write_cgi_header;
      cgiwriteln('content-type: text/html');
      cgiwriteln('')
    ENDPROC
    parameter list

    You can commit values resp. variable references to the procedure. Those are defined directly after the procedur name in parenthesis. This is a formal parameter list:
    PROCEDURE bold(line : STRING);
      cgiwrite('');
      cgiwritehtml(line);
      cgiwriteln('')
    ENDPROC
    Calling the procedure might look like:

    fett('Headline');
    fett(lower(cgigetparam('headline')));

    With calling any expression of the (in the parameter list) defined type is in place of the formal parameters. At first this value is calculated and then is transmitted to the local variable of the procedure (here "line"). Such parameters are called value parameters (call by value).

    Important: With calling a argument has to be at every place of the procedure list!

    Besides the value parameters EASY also knows reference parameters. Here the formal parameter is considered as a free variable parameter. With calling this free variable parameter is replaced by the committed variable: Thus an assignment inside the procedure to the formal variable changes the committed variable. With calling a variable has to committed (and not an expression or a constant) instead of a reference parameter. Reference parameters are marked by a prefixed "VAR".

    Example:
    PROCEDURE douple(VAR x : REAL);
      x:=2*x
    ENDPROC
    The calling might look like:

    VAR a : REAL;
    a:=10;
    douple(a); // now a has the value 20

    Example 1: High



    PROCEDURE FieldTest(VAR a : INTEGER[,]);
    VAR max_i : INTEGER = High(1,a);
    VAR max_j : INTEGER = High(2,a);
    ...
    ENDPROC
    
    
    VAR x : INTEGER[10,5000];
    VAR y : INTEGER[5,0];
    ...
    FieldTest(x) // max_i=10; max_j=5000
    FieldTest(y) // max_i=5; max_j=0 


    User comments:
    Write a comment:
    Name
    EMail
    Subject
    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
    irc.tdbengine.org
    #tdbengine

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