Deutsch English
Home
About tdbengine
Newsletter
Download
Helpware
Forum
Chat
Documentation
Installation
Configuration
First Steps
Runtime Switches
Text files
System functions
Database functions
Index functions
Full-text Indexing
Memos and BLOBs
Semaphore concept
Error codes
Hints for PHP developers
Basic Course
Function reference
HOWTO...?
Projects
Links
Benchmarks
Bug Reporting
Support request
 
Home    Overview    Search    Impressum    Contact    Members
Runtime switches of tdbengine
Runtime switches control the behavior of the tdbengine. With the exception of AK, all switches are activated at runtime and are operating strictly global.

Setting and Selecting


There are two possibilities of setting a switch:

  • point instruction (out of date)
  • function SetPara()

A point instruction is a program line, which begins with a point (whereby leading space characters are ignored). After this point the single switches are written sequentially with the corresponding value and separated from each other by comma:

.ec 1, nb 0

Because in next basic version (6.3.x) the line structure is abolished in EASY programs, the switch setting of this kind must not be used any further.

This now can be achieved by the function SetPara()

SetPara(Switch : STRING) : REAL

The switches are expressed as string here (without leading point) and separated by comma also.

SetPara('ec 1, nb 0')

The return value of the function is always 0, an illegal instruction causes aruntime.

The value of a switch can be polled by the function GetPara().

GetPara(Switch : STRING) : REAL

Example:

GetPara('ec') -> 0|1 (depending on the situation)

Overview of all Switches ...

Switch

Meaning

Action

Preset value

ak

Abbreviation

Abbreviations are allowed by field identificators (1)

0
ec

ErrorCheck

Error processing by program (1)

0
em

ExactMatch

Full-text indexing and searching compare masks exactly (1)

0
de

Descending

Subreport reverses sequence of the data blocks (1)

0
nb NoBreak

The program can not be interrupted by a file named 'abort' (1)

0
nv NumericValues

VAL permits numerical constants only (1)

1

... and Details about them


ak

This switch is used by dynamical table analyses only, so, for example, by FindAndMark() or SUB, if referring to data fields via field identifiers. Here, we are dealing with an obsolete relic from DOS-TDB times. Normally it should be left in the default setting (abbreviations are forbidden).

ec

Everytime a critical error happens the tdbengine generates a runtime error with a corresponding entry into the file bin/error.log. If the error occurs at the execution of a variable assignment, the runtime error can be caught, when the switch is set into ec 1 position. In this case the exception handling must be performed by the program itself.

From the handling of the switch as runtime function (and not at all as flag for the code generation) it follows that the switch must be explicitly reset after a local use.

Example:

PROCEDURE OpenTable(path : STRING) : REAL
VAR result : REAL
  SetPara('ec 1')  // Perform error processing
  result:=OpenDB(path)
  RETURN result
  SetPara('ec 0')  // REPEAT error processing (?) by system
ENDPROC

The reset of the switch is never completed here and the switch is hold set in the rest of the program till it is reset again on occasion somewhere. Therefore the better solution is:

PROCEDURE OpenTable(path : STRING) : REAL
VARDEF result, t_ec : REAL
  t_ec:=GetPara('ec') // Mark external position
  SetPara('ec 1') // Perform error processing
  result:=OpenDB(path) // none of runtime error
  SetPara('ec '+str(t_ec)) // Restore external position again   RETURN result
ENDPROC

In this example the positioning of the switch was examined only. For error processing itself the EASY has the following system functions:

TDB_LastError determines the error code
TDB_ErrorStr(TDB_LastError) determines the error message as string

Furthermore, following system variable is set (upper / lower case is noteworthy here):

TDB_ErrorMsg determines the (retranslated) expression, in which the error occurs

Now an example with error processing is here:

PROCEDURE OpenTable(path : STRING; VAR system_msg : STRING) : REAL
VAR result, t_ec : REAL
  t_ec:=GetPara('ec')  // Mark external position
  SetPara('ec 1')      // Perform error processing
  result:=OpenDB(path) // none of runtime error
  IF TDB_LastError=0   // all is okay
  THEN system_msg:='done.'
  ELSE system_msg:=TDB_ErrorStr(TDB_LastError) // Output message
  END
  SetPara('ec '+str(t_ec)) // Restore external position again
  RETURN result
ENDPROC

em

This switch controls the handling of the mask quantity by indexing and searching of the full-text. Please see details in the documentation of full-text indexing and searching.

de

This switch sets the sequence of the data blocks of the primary table by SUB reports. Normally the sequence is ascending. SetPara('de 1') enables to toggle to descending sequence.

Example: first as ascending...

VAR db : REAL
VARDEF Sel _: STRING
  db:=OpenDB('database/addresses.dat')
  Access(db,'name.ind')
  Sel:='$Name FROM "A" TO "G"'
  SUB _sel
    CGIWriteLn(GetField(db,'Name'))
  ENDSUB
  ...

Output:

  Alzheimer
  Bernholzer
  Dorfmeister
  Elstner
  Friedrichs

... then as descending

VAR t_de : REAL
  ...
  t_de:=GetPara('de') // Mark sequence
  SetPara('de 1') // Reverse sequence
  SUB _DBName(db)
    CGIWriteLn(GetField(db,'Name'))
  ENDSUB
  SetPara('de '+str(t_de)) // Restore sequence again
  ...

Output:

  Friedrichs
  Elstner
  Dorfmeister
  Bernholzer
  Alzheimer

nb

To have a simple interruption possibility (also for non-roots) by an endless loop (or by somehow errant program), the presence of a file with the name 'abort' is sought in the directory of the tdbengine-package every other second. If such file is available, the program is interrupted and (if the rights are enough therefore) the file is deleted.

During the development and testing phase of a program this switch should be kept set to 0 (default value). But if a program has been tested and proved "error free", the switch can be set to 1. That leads to a significant increase of performance.

Note: The interruption with the aid of "abort" does not execute during the performance of system functions, e.g. during an indexing run.

Advise: If tdbengine behaves "queer" and interrupts lengthy programs without error message, then an "abort" file may be responsible for this, which can not be deleted (while the rights of the anonymous http-user are not enough or a directory is involved here).

nv

The position of this switch is evaluated in connection with the standard function Val() only. This function interprets the transmitted string argument as EASY expression and calculates its value.

In the restricted setting (switch position 1 = default value) only valid number constants are evalueded. All other expressions are rejected with the error "illegal number constants".

On the contrary in the extended setting (switch position 0) any expressions are allowed. This can become a massive security problem, if CGI variables are transmitted to the function Val() unfiltered.

Example:

...
x:=Val(GetQueryString('recno'))
...

If the program call with ...?recno=rm+-r+* is performed, you will receive with "nv 1" a program interruption with error message, but with "nv 0" - a catastrophe.



tdbengine Anwendungen im Web:

Open-Source Web CMS


Open-Source Bug-Tracking


Free wiki hosting

Open-Source Wiki-System

Kostenloses Foren-Hosting

Dišt mit tdbengine 8-)

tdbengine chat
irc.tdbengine.org
#tdbengine

   Copyright © 2003-2004 tdb Software Service GmbH
   Alle rechte vorbehalten. / All rights reserved
   Last changed: 05.05.2004


ranking-charts.de

Programmers Heaven - Where programmers go!