<<

Contents

Search

>>

 

The first program

 

Ebus-J programs consist of Index Files, Masks, Reports and Macros.

 

The Index Files serve to save data. With freely definable keys all data record of an Index File can be accessed even with big amounts of data. Index Files are used in the masks and the reports and in the macros. This is why the Index Files of a program must be created first.

 

After that the masks and reports of the program are created. Masks basically consist of mask fields (Controls), which enable the recording and displaying of data. With every mask field a Macro before and a Macro after can be specified. The Macro before is executed when the field is called. The Macro after is executed after data entry. A macro is a program part, which is written in the programming language of Ebus-J.

 

With the report print list can be created easily. 

 

Every macro is called by a name (Macroname). The names of the used macros are shown on the masks and reports. The macros can be recorded immediately on the masks and reports (keys F8, F9, F10) or later under the menu item File/Open/Macro.

 

The following example explains how a program is created in Ebus-J.

 

We want to create a program that displays image files and protocols the displayed images in an Index File.

 

First of all the Index File PROTOCOL is specified. For this purpose the menu item File/Open/Index File (Alt/I) is selected.

 

4 fields are recorded: USERNAME$, DATE and TIME$ protocol by whom and when the image was displayed. In FILENAME$ the name of the displayed image file is saved.

 

 

The primary key must be unique, therefore USERNAME$, DATE and TIME$ are specified for the primary key.

 

 

We define a secondary key in order to display all data records sorted by date and time, independently of USERNAME$.

 

 

 

The next step is to specify the program. Therefore the menu item File/Open/Program (Alt/P) is selected.

 

The Program Name is specified as PROG1. After that a new mask is created by clicking on the entry New Mask:

 

The Mask Number is specified as 10, as Mask Title we choose "Show Image", the remaining fields may stay empty.

 

 

 

By pressing the "OK" button we get to the mask editor.

 

 

The icon bar shows the symbols of the available mask fields. By pressing an icon the respective mask field type is selected. The mask field can be created by dragging the mouse.

 

Texts can also be created by typing text. A text field is then automatically inserted at the cursor position   . The cursor position can be shifted by a left mouse click or by Ctrl/<←>, Ctrl/<→>, Ctrl/<↑>, Ctrl/<↓>.

 

First we create a text field by typing the text "Image File".

 

 

Behind the text we need an alphanumeric mask field for the file name. Therefore we click on the icon “abc” and then created the field by dragging the mouse.

 

 

Behind the input field we create a button by which the file dialog for file selection is to be called. Therefore we click on the second icon and create the button by dragging the mouse.

 

 

We create two more numeric mask fields (Icon "123"), which determine the position (Row and Column) at which the image is to be displayed.

Behind that another button is created, by which the image is displayed.

 

 

Now we only have to change the attributes of the mask fields. With the tab key <→|> the first or the next field is selected. By pressing <RETURN> or by double-clicking on the mask field the attributes of the mask field are shown. First we change the field “abc”. The Field Name is DUMMY_ALPHAFIELD$. We change it to FILENAME$. In the macros that we specify later, the variable FILENAME$ will contain the content of the mask field. We furthermore change Number Input Characters to 128, so that there is also enough room for longer file names in the mask field.

 

 

By pressing the button "F12 = Save" the attributes are saved. A message will inform us that the formatting string will be corrected since we changed the number of input characters.

 

 

The first button shall be labelled "Browse".

 

 

By pushing the button "Additional Field Attributes" a Standard Image can be selected for the button.

 

 

With the two numeric fields behind row and column we replace the field name DUMMY_NUMFIELD by ROW or COLUMN and we set Number Input Characters at 2.

 

 

The second button shall be labelled "Load Image".

 

 

The mask then looks like this:

 

 

The mask is specified now. We still have to specify the processing when one of the two buttons is pressed.

 

By double-clicking on the button "Browse" the attribution mask appears again. With Macro after we enter: PROG1.BROWSE.

The macro PROG1.BROWSE will be executed if the button "Browse" is pressed.

 

 

We can immediately specify the macro PROG1.BROWSE by pressing the key F9. An editor window will open, in which the macro can be created.

 

 

We want to call the file dialog to select an image file. This is done by the command FILEDIALOG. With F4 all commands and variables of the programming language of the Bus-J can be displayed. By typing in the initial letters the respective command will be placed automatically in the select window.

 

 

The command is selected by <RETURN> or a mouse click. A window appears in which the parameters of a command can be specified. Parameters in square brackets [ ] are optional.

 

 

Header specifies the title of the file dialog.

Filter specifies which files can be selected. We only allow gif-, png- and jpg-files.

With Default Directory, Default Filename and Default Extension the empty string is specified. With Shift/F10 the complete specification of the command FILEDIALOG can be displayed.

By pressing the "OK" button the command of the editor window is taken over.

 

 

After the file dialog has been closed the variable EBUS_DATA contains the status and the variable EBUS_DATA$ contains the selected file name.

Only if EBUS_DATA = 1, a file name has been selected. In this case we must assign the selected file name to our mask field variable FILENAME$ and display the new content of the mask field by the DISPLAY instruction.

 

 

The macro has thereby been specified and can be saved with F12. We are on the attribution mask of the button again and save the attributes with F12 as well.

 

Now we create the macro fort he image display. Therefore we double-click on the button “Load image”. We enter PROG1.LOAD.IMAGE  with the Macro after and recall the editor with F9.

 

First we have to check whether a filename has been specified:

 

IF ISSPACE(FILENAME$)

THEN ERRORMES = "Filename is missing."

     GOTO #10.#FILENAME$

ENDIF

 

The instruction ERRORMES shows the error message in a window. GOTO #10.#FILENAME$ leaves the macro and goes to the field FILENAME$.

 

The image is displayed by the function LOAD_PICTURE. Since functions deliver a result they may only appear on the right hand side of an assignment. In the editor we therefore write

 

RESULT% =

 

and press F4 for showing the commands. By entering the initial letters LO LOAD_PICTURE will be positioned automatically. We select the command by <RETURN> and specify the following parameters:

 

 

With Row and Column we specify ROW and COLUMN. These variables contain the values that were entered into the fields row and column on the mask.

Mode = 0 means that the image is displayed in its original size. The parameters Height in Rows and Width in Columns have no meaning then.

Delete = 1 has the effect that an image that is currently being shown is deleted before the new image is displayed.

With Image Name we specify FILENAME$. FILENAME$ contains the image name that was entered on the mask.

 

We press "OK" and return to the editor. Now we have to check whether LOAD_PICTURE reported an error.

 

IF RESULT% <> 0

THEN ERRORMES = "Error " + STR$(RESULT%)

     QUIT

ENDIF

 

RESULT% will be <> 0 if an error has occurred. In this case the error will be reported and the macro will be left with QUIT.

 

Finally the successful display of the image shall be recorded in the Index File PROTOCOL.

 

PROTOCOL.USERNAME$ = GET_USERNAME$

PROTOCOL.DATE = NUMDATE(DATEG8$)

PROTOCOL.TIME$ = TIME$

PROTOCOL.FILENAME$ = FILENAME$

 

WRITE PROTOKOLL ON ERROR ERRORMES = "Error" + STR$(OK) + STR$(OK2) + ": " + ERRORTEXT$

                END

 

GET_USERNAME$ provides the user name.

NUMDATE converts the aplhanumeric date DATEG8$ into a numeric value.

TIME$ contains the current time in the format HH:MM:SS.

WRITE writes the data record into the Index File.

 

The Index File fields PROTOCOL.USERNAME$,... can be inserted into the editor with F2.

 

Every time the name of a function (e.g. NUMDATE) or an instruction is specified in the editor, the syntax automatic is started. Then the window for parameter input appears again. The syntax automatic can be switched off with F12 under the menu item File/Open/Macro.

 

The macro is complete now:

 

 

The macro is saved by F12 and the attributes of the button are saved by pressing F12 once more.

 

We insert another button below the button "Load Image", which is to display the protocol file. As Macro after we enter PROG1.PROTOCOL with the attributes and restart the editor by F9.

 

The SELECT function displays the data records of an Index File.

Prior to this it must be specified by the WINDOWPOS instruction where the SELECT window is to be placed.

WINDOWPOS(0,0) has the effect that the SELECT window is displayed centered in the mainwindow.

 

 

The complete macro then looks like this:

 

 

The INITIALIZE instruction has the effect that all fields and Index Files are initialized with 0 or blank. Thus the data records are displayed at the beginning of the index file.

 

By pressing the "Save" button the whole mask is saved:

 

 

The program can be generated and started now. Therefore the menu item Generator (Alt/G) is called.

 

 

If the checkboxes Start Compiler after program generation and Start Program after compilation are set, the compilation and after that the complete program will start automatically after the generation. The condition is that JDK 1.5.0 or higher has been set up properly.

 

The generation is started with F8 or <RETURN>.