<<

Contents

Search

>>

 

Elements of the programming language

 

The programming language of the Ebus-J is derived from BASIC and contains extensions for the Index File accesses and commands for an easy creation of commercial programs. Like in BASIC variables do not have to be declared, the parameter type is specified by the spelling.

 

A program part that is written in this language is called Macro. All created macros are saved in a library. A macro can be activated either by the program specification as Macro before, Macro after, Macro before mask output, Macro after mask output, Macro for mask processing, Macro before Index-Open, Macro after Index-Open (see programs) or by the call of the command MACRO in a macro.

 

Since all macros are administered in a library, which can be accessed by all programs in the current working directory, the multi-usability of the macros is ensured. With the program generation the generator reads all necessary macros from the library and generates the program out of them.

 

Constants

 

Alphanumeric constants are strings that are restricted by the character  " . The length of the string is made up by the number of its characters. The empty string has the length 0 and is written as "" .

 

Example for alphanumeric constants:

"Hello"

"AMOUNT: 22,50 €"

 

Numeric constants consist of 1-15 decimal numbers. The decimal point is written as “.“ .

 

Examples for numeric constants:

 

123

45.99997

0.784

 

Variables

 

Variables are names used for saving values in programs. All variable names must begin with a letter.

 

There are 3 types of variables:

a)         Index File variables are written: <Index File name>.<Field name> (e.g. CUSTOMER.NAME$). Index File variables always contain at least one point and have a specified length. If the value assigned to a numeric Index File variable is bigger than the value maximum specified by the field length, the surplus leading numbers will be cut off. If a string assigned to an alphanumeric index file variable is bigger than the field length, the surplus characters at the end of the string will be cut off. If a string assigned to an alphanumeric Index File variable is smaller then the field length, the string will be filled up with blanks. Alphanumeric Index File variables thus always contain just as many characters as specified with the definition of the field length. Index file variables are global regarding the main- and subprogram.

b)        Auxiliary variables are variables that can be freely defined. Auxiliary variables may only consist of letters, numbers and the character _ . They are global regarding the main- and subprogram ONLY if they have been declared as SHARED in the main program; otherwise they only apply to the current program. Auxiliary variables can be declared as LOCAL in macros. These kinds of variables then only apply to this macro, not to other macros and not to sub-macros.

 

c)         Special variables are reserved variables of the programming language (e.g. EBUS_MENU$).

 

Every variable is either integer, numeric or alphanumeric:

 

Integer

Variables of this type are marked by the character % at the end of their name. This type is only valid with auxiliary variables. Whole numbers can be saved in the value range from –2 to the power of 63 to +2 to the power of 63.

Numeric

Numeric variables are saved as double-values. Decimal numbers can be specified with 15 positions. The characteristic of numeric variables is that they neither end with a % nor with a $.

alphanumeric (string – or character set variable)

Variables of this type are marked by the character $ at the end of their name. Alphanumeric variables (except of index file variables) have a variable length and can contain any number of characters.

 

When the program starts numeric and integer auxiliary variables are initialised with 0, alphanumeric auxiliary variables are initialised with the empty string "".

 

Examples for valid variable names:

 

Name

Type                                            Variable type

H$

alphanumeric                             Auxiliary variable

BEFORE_NAME$

alphanumeric                             Auxiliary variable

ADDRESSE.NAME$

alphanumeric                             Index file variable

BEFORE_NAME__1$

alphanumeric                             Auxiliary variable

I1

numeric                                  Auxiliary variable

FROM_DATE_1

numeric                                  Auxiliary variable

ADDRESS.PHONE

numeric                                  Index File variable

I%

integer                                          Auxiliary variable

I_2%

integer                                          Auxiliary variable

CURSUP$

alphanumeric                             Special variable

 

All names and expressions except of reserved words may be used for variables. Note that I and I% are two different variables.

 

Mask fields

 

When the mask is created every mask field must be linked to a variable. In the generated program the variable and the mask field are then identical, which means that they have the same value.

 

The value of the variable linked to the mask field is always displayed automatically on screen when the mask is displayed, the mask field is called up or a Macro before or Macro after of a mask has been executed, in which data records of an index file have been read. With the instruction DISPLAY the display of a mask field can be actualised.

 

If a value is entered into a mask field, this value is automatically included in the respective variable.

 

If in a macro a new value is assigned to a variable that is linked to a mask field, the new value will not be automatically displayed on screen; with auxiliary variables it will not be adjusted to the length of the mask field either. The display appears only when the mask field is activated or the instruction DISPLAY is executed or a Macro before or a Macro after has been terminated, in which data records of an Index File have been read.

 

NOTE: Alphanumeric variables that are linked to an alphanumeric mask field with formatting string always have the length specified by the formatting string, when the field is displayed on screen. The variable in the macros can temporarily contain more or fewer characters. However, as soon as the respective mask field is displayed, surplus characters will be cut off at the right edge and missing characters will be replaced by blanks.

 

 

Arrays

 

Auxiliary variables can be dimensionised. Dimensionised auxiliary variables are called Array.

 

DIM instructions can stand at any position in the macro. DIM instructions are not executed at program run, they are processed already with the generation of the program. Every array may only be defined once within a program.

 

Arrays are called up via indices. An index can have the values 0 up to the value of the dimensionisation.

 

Example: DIM SUM(10),TEXT$(2,20)

Valid are: SUM(0), SUM(1), ... SUM(10), TEXT$(0,0),...TEXT$(2,20)

Invalid are: SUM(11), TEXT$(3,0), TEXT$(2,21)

 

If an invalid array element is called in a macro, a runtime error will be reported and the currently executed macro will be cancelled. With the program generation the checkbox Generate check of array borders can be set. Then all indices are checked on their validity before any array element is accessed. If an index lies outside the valid range, an error report will give the faulty index and the call position in the macro.

 

Numeric expressions, operators and assignments

 

Numeric expressions either consist of a numeric constant, a numeric variable or numeric constants and variables that are linked by numeric operators. The arithmetic priority rules (* / before + –) apply to the linkage with operators.

 

The following operators are available:

 

–          Negation  (e.g. –1 or –XX%)

*          Multiplication

/           Division

+          Addition

-          Subtraction

 

Brackets can be applied to numeric expressions in any form. Brackets take priority over all operators.

Numeric assignments assign a value to a numeric variable.

 

 

Examples:

I% = 1
J = J + 1
A(I,J) = 2*I + J
CUSTOMER.PURCHASE.DATE = NUMDATE(DATEG8$)

Alphanumeric expressions, operators and assignments

 

Only the operator + is available for the creation of  alphanumeric expressions.

 

Alphanumeric assignments assign a character set to an alphanumeric variable.

 

Examples:

A1$ = "Hello"

A2$ = "World"

H$ = A1$ + " " + A2$        /* H$ contains "Hello World"
C$(1)  =  H$

Comparative operators

 

Comparative operators are used to compare two values with each other. Only expressions of the same type can be compared, that are either numeric expressions or alphanumeric expressions.

 

 

Operator

Meaning

=
<>
>
>=
<
<=

equal
unequal
greater than
greater or equal
less than
less or equal

 

Alphanumeric variables are compared character for character from left to right until one character is found unequal or the end of the character set has been reached.

 

The following comparative expressions are true:

 

"AAA" <  "AAB"

With the 3rd character "A" < "B" is found.

"AAA" <  "AAAA"

With the 4th character "" < "A" is found.

"AAA" <  "AAA  "

With the 4th character "" < "  " is found.

"   " <  "A"

With the 1st character " " < "A" is found.

"" < " "

With the 1st character "" < " " is found.

"Z" <  "a"

Capital letters come before small letters in the sort order of the ASCII-Code.

 

Logical expressions and operators

 

A logical expression is either true or false. A logical expression can consist of a numeric expression or a comparative expression. A numeric expression is false if it has the value 0, otherwise it is true. A comparative expression is true if the specified relation is fulfilled.

 

Logical expressions can be linked to become complex logical expressions with the following operators.

 

NOT

Negation: A=0 Þ NOT A is true

AND

logical AND: A=1 B=1 Þ A AND B is true

OR

logical OR: A=1 B=0 Þ A OR B is true

 

Brackets can be applied to logical expressions in any form.

 

GOTOs

 

There are two kinds of goto targets:

a)  labels within a macro
b)  mask fields

 

a) Goto masks within a macro

 

 

Goto targets within a macro are defined by labels and are only valid locally within a macro.

A label can appear at any position in a macro but it must stand at the beginning of a line. Labels must start with a letter and end with a colon. Gotos are only possible from one mark to another goto mark within the current macro or to a mark in a higher block. Gotos to parallel or lower blocks are not possible. Blocks are defined by the following key words:

 

THEN ... ELSE

THEN ... ENDIF

ELSE ... ENDIF

FOR ... ENDLOOP

WHILE DO ... ENDDO

ON ERROR ... END

FUNCTION ... ENDFUNC

OF ... OF

OF ... OFREST

OF ... ENDCASE

OFREST ... ENDCASE

 

Example:

N1:         I% = I% + 1

                 ...

                 IF I% < 10 THEN GOTO N1 ENDIF /* possible since goto to a higher block

 

                 IF I% = 12 THEN GOTO N2 ENDIF /* Not possible since goto to a parallel block

 

                 IF I% > 10
                 THEN

N2:                            K% = K% + 1

                 ENDIF

 

b) mask fields

 

A goto to a mask field has the effect that the current macro and all higher macros are terminated and program execution continues at the specified mask field. If the mask field has a Macro before, this macro will be executed.

 

Examples

GOTO #.1

Goto 1st mask field of the current mask

GOTO #10

Goto 1st field of mask 10

GOTO #10.2

Goto 2nd mask field of mask 10

GOTO #10.#A$

Goto the mask field of mask 10 that is linked to the auxiliary variable A$.

GOTO #10.#ADR.PLZ

Goto the mask field of mask 10 that is linked to the Index File variable ADR.PLZ.

GOTO #.+2

Goto the next but one mask field

GOTO #.- 3

Go 3 mask fields backward

 

File access

 

Files can be accessed over write-, read- and control instructions. All these instructions contain a block ON ERROR ... END, which is executed in case of error. If the block ON ERROR ... END is executed, the variables OK and OK2 contain the error numbers and EBUS ERRORTEXT$ contains the error report.

 

The block ON ERROR ... END can be empty. The following instruction is therefore permitted:

CLOSE 1 ON ERROR END

However, in this case an occurring error will not be noticed.

 

There are three types of files:

 

a) Index Files

 

The data records of Index Files consist of individual fields. The keys are created with the help of the fields. Data records are always accessed over a key. The data records can be read and written over the keys in any order. The Index Files are opened automatically when the program starts and closed automatically when the program ends. Defective Index Files are spotted and reorganised automatically. With the write- and read instructions the respective key for the data access is created from the current content of the respective Index File fields.

With the write instruction WRITE the set specified by the primary key is written into the Index File. If a data record with this key already exists, it will be overwritten with the updated values. In multi-user operation an already existent data record that is to be rewritten must have been read before, otherwise the error 1062 will be reported.

With the instruction DELETE the data record specified by the primary key is deleted in the Index File. In multi-user operation the data record must have been read before, otherwise the error 1062 will be reported.

With the instructions PATH, NEWNAME, OPENMODE the paths, the physical names and the access mode of Index Files can be set in the Macro before Index-Open.

 

b) Sequential files

Sequential files must be opened with the instruction OPEN and specified with a file number before they are edited. The file number helps to identify the files with all further accesses.

 

If the sequential file is opened with INPUT, the data can be read sequentially with the instructions INPUT and LINE INPUT. The function EOF indicates if the end of the file has been reached.

 

If the file is opened with OUTPUT, the data can be written sequentially with the instruction OUTPUT. If the file existed already before it was opened, the old content will be deleted.

 

If the file is opened with EXTEND the data can be written sequentially with the instruction OUTPUT. An existent file will not be deleted, new data will be added at the end of the file.

 

Sequential files should be closed with the instruction CLOSE after they have been edited. At the end of the program all open files are closed automatically.

 

 

Example: Copy file INPUT.DAT to OUTPUT.DAT

 

OPEN INPUT,1, "INPUT.DAT" ON ERROR ERRORMES = "Error with opening input file:" + STR$(OK) QUIT END

 

OPEN OUTPUT,2,"OUTPUT.DAT" ON ERROR ERRORMES = "Error with opening output file:" + STR$(OK)  CLOSE 1 ON ERROR END QUIT END

 

WHILE NOT EOF(1)

DO         LINE INPUT 1,DATA_RECORD$ ON ERROR ERRORMES = "Error with reading input file:" + STR$(OK) CLOSE 1 ON ERROR END QUIT END

OUTPUT 2,DATA_RECORD$ ON ERROR ERRORMES = "Error with writing output file:" + STR$(OK) GOTO CLOSE_FILES END

ENDDO

 

CLOSE_FILES:
CLOSE 2 ON ERROR ERRORMES =“Error with closing output file:“ + STR$(OK)  END

CLOSE 1 ON ERROR ERRORMES =“Error with closing input file:“ + STR$(OK)  END

 

 

c) Random Files

Random files have a defined set length. In contrast to sequential files the data records can be read and written in any order (optional) over their set number. In contrast to Index Files they do not need any file administration, since the data record is only accessed over the set number.

 

Random files must be opened before the editing with OPEN RANDOM by giving the set length. Then the fields of the data record buffer must be defined with FIELD instructions. Several FIELD instructions are possible. All FIELD instructions are valid at the same time.

 

With the instruction GET the set specified by the set number is read into the buffer. In this way the respective values are assigned to the variables specified in the FIELD instruction. The variables defined in the FIELD instructions can only be provided with data with the instructions LSET and RSET. With the instruction PUT the buffer is written into the set specified by the set number.

 

Sequential and random files should be closed with the instruction CLOSE after the editing. At the end of the program all open files are closed automatically.

 

Switches

 

Switches control certain functions in the program.

 

Switches can be switched on and off with ENABLE and DISABLE.

 

When the program starts all switches are always switched on.

 

Example: DISABLE REORG /* no automatic reorganisation with defective Index Files.