Deutsch English
About tdbengine
Basic Course
Function reference
Bug Reporting
Support request
Home    Overview    Search    Impressum    Contact    Members
How to write dynamic programs?

What does it actually mean?
As is generally known tdbengine is a database engine, an interpreter and acompiler in one.
So we are happy that a source code written in EASY can be compiled. Many potential errors in the code found without compiler only  at the runtime of Interpreter would cause a data chaos. Imagine while doing a backup interpreter finds out that a parrameter of a function will transfered as a wrong type and aborts the process. The question is now do you have a backup or you don't.

But sometime it would be of use if you could mix the fixed structure up. That could help to keep source codes abstact to use them easier in other projects. It would also allow us to give the user of our applications powerful tools. In other database systems like MS ACCESS you have a SQL editor, too, which you can do many things (in line with SQL) with.

Fortunately tdbengine offers divers options how to affect dynamic program stream. That's what I want to specify to you. DO _"continue_reading()"

DO _
Using DO combined with _ (underline) you can analyse and following run any expression.


VAR x : STRING = "cgiwriteln('hello world')"
DO _x

Only at runtime more precisely when the interpreter comes in the second line to the underline the value of the variable x will be analysed. Here it's nothing mind because it's value is alleged. DO makes tdbengine running the expression delivered by the underline _. In this situation we also could do it easier:

CGIWriteLn('hello world')

It would suffice.

Another example:

PROCEDURE deletefromadressen(nID : INTEGER)
    //exemplarily delete routine
    DelRec(dbADDRESSES, FindAuto(dbADDRESSES, nID))

PROCEDURE deletefromniederlassungen(nID : INTEGER)
    DelRec(dbNETHERL, FindAuto(dbNETHERL, nID))

    VAR x : STRING = "deletefrom"+cTable+"("+Str(nID)+")"
     //analyse x at runtime AND "run" it's result
    DO _x

We assume that any table in our project will need a table specific cleanup if datasets will be deleted. But in the whole application should be used only one routine delete(). This routine has to take care for running the deleteform...() procedure that belongs to the table. Sure, we could do it with a IF-THEN-ELSIF-ELSE-END monster ,too. But with any new table this IF tree would grow in and some projects it could pssibly become very complex. In the example the variables affect the program action at the runtime.

The function Val()

Val() evaluates any strings. At least Val() tries to do it. In other words Val() makes a string out of an integer.

For example:

VAR c1 : STRING = "123"
VAR c2 : STRING = "123 + 321 + 1 / 2 * 3"
VAR c3 : STRING = "Val(c1) + Val(c2)"
VAR c4 : STRING = "Val('999' + Str(Val(c3),0,2))"


SetPara("nv 0")

n:=Val(c1)   // n = 123
n:=Val(c2)   // n = 445,5
n:=Val(c3)   // n = 568,5
n:=Val(c4)   // n = 999568,5

So you see with Val() you can evaluate nearly any string. Thereby they may also access functions and variables of the program. However thereto you have to set the runtime switchnv to 0.

The function ExecProg()

ExecProg(cFilename : STRING)

Compiles and runs any EASY programs.
Thereby cFilename may refer both file and ramtext:.

(Very easy) Example:

   VAR f : INTEGER = Rewrite("ramtext:code")

   WriteLn(f, "Procedure XYZ : String")
   WriteLn(f, "  RETURN 'xyz'")
   WriteLn(f, "Endproc")
   WriteLn(f, "")
   WriteLn(f, "c := xyz")



Here the ramtext:code will be written only at the runtime following compiled and runed with ExecProg().

Dynamic selection programs demonstrate an interesting application which will be individually assembled only at runtime of the blocks. An (A very complex) application area is here for example analysis and conversion of SQL statements Anwendungsgebiet wäre hier zum Beispiel die Auswertung und Umsetzung von SQL-Statements to EASY code.

Continuative links:

/documentation/runtime switch

Author: Thomas Friebel <>

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

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

Programmers Heaven - Where programmers go!