Skip to content

Getting Started

In this chapter you will install nothing new (we assume the Aubit 4GL tools and a VDC client are already available to you), set a handful of environment variables, connect a program to the client, and compile and run your very first program.

The three tools you will use

Everything in this guide is built with three command-line tools that ship with Aubit 4GL:

Tool Purpose
4glpc Compile a 4GL program into a runnable executable (.4ae)
4glc The lower-level compiler (one step at a time); used for libraries
fcompile Compile a form file (.per) into the form the client reads

Check that they are on your PATH:

which 4glpc fcompile

If you get "not found", make sure the Aubit bin directory is on your PATH (see the environment section below).

Environment variables

A 4GL program needs a few environment variables: some to find the compiler and its libraries, and some to tell the program which GUI client to talk to.

Compiler and runtime

# Where Aubit 4GL is installed (adjust to your installation)
export AUBITDIR=/opt/aubit4gl

# Make the tools and their shared libraries findable
export PATH=$AUBITDIR/bin:$PATH
export LD_LIBRARY_PATH=$AUBITDIR/lib:$LD_LIBRARY_PATH

Connecting to the VDC client

This is the part that makes the graphical client appear. Three variables matter:

Variable Value Meaning
A4GL_UI XML Use the XML protocol — this is what the VDC client speaks
AFGLSERVER the client's address Where your program should connect to reach the client
AFGLPORT 3490 (default) The TCP port the client is listening on
export A4GL_UI=XML
export AFGLSERVER=127.0.0.1     # the machine where the VDC client runs
export AFGLPORT=3490            # the port the client listens on

Why does the program connect to the client? The client starts first and waits ("Listen mode"). When you launch your 4GL program, the program reaches out to AFGLSERVER:AFGLPORT, the client accepts the connection, and the window opens. If the client is on the same machine as your program, 127.0.0.1 is correct. If the client runs on your laptop and the program runs on a server, set AFGLSERVER to the address the server can use to reach your laptop (often through an SSH tunnel).

Dates, numbers and locale

These control how your program displays dates and money, and which character encoding it uses. Set them once and forget them.

export DBDATE=DMY4/                 # day.month.year, e.g. 31/12/2026  (try MDY4/ or Y4MD- for other styles)
export DB_LOCALE=en_US.UTF-8        # database character encoding
export CLIENT_LOCALE=en_US.UTF-8    # client character encoding

Tip. DBDATE is the single most common source of "my date looks wrong" confusion. D=day, M=month, Y4=four-digit year, and the last character is the separator. DMY4/ shows 31/12/2026; Y4MD- shows 2026-12-31.

A reusable setup script

Put the lines together in a file, e.g. env.sh, and source it in each terminal:

#!/bin/bash
# env.sh — minimal Aubit 4GL + VDC environment
export AUBITDIR=/opt/aubit4gl
export PATH=$AUBITDIR/bin:$PATH
export LD_LIBRARY_PATH=$AUBITDIR/lib:$LD_LIBRARY_PATH

export A4GL_UI=XML
export AFGLSERVER=127.0.0.1
export AFGLPORT=3490

export DBDATE=DMY4/
export DB_LOCALE=en_US.UTF-8
export CLIENT_LOCALE=en_US.UTF-8
source ./env.sh

Your first program (text only)

Before we involve the GUI, let's prove the compiler works. Create hello.4gl:

MAIN
    DISPLAY "Hello, 4GL!"
END MAIN

Every 4GL program has exactly one MAIN ... END MAIN block — that is where execution starts. Compile it:

4glpc -o hello.4ae hello.4gl

This produces hello.4ae, an ordinary executable. Run it:

./hello.4ae

You should see Hello, 4GL!. If you do, your compiler and environment are working.

Your first GUI program

Now let's open a real window in the VDC client. A GUI program needs two files: a form that describes the screen, and a program that opens it.

Step 1 — the form. Create hello.per:

DATABASE FORMONLY

SCREEN
{
    Your name:  [f_name              ]

    [f_msg                                          ]
}

ATTRIBUTES

Edit  f_name = FORMONLY.name;
Label f_msg  = FORMONLY.message;
  • DATABASE FORMONLY means "this form is not bound to a database table" — every field is a free-standing form field. We will bind forms to tables in chapter 6.
  • The SCREEN { ... } block is the visual layout. Text is shown as-is; anything in [ ... ] is a field, and the name inside it is the field tag.
  • The ATTRIBUTES block connects each field tag to a variable and chooses a widget (Edit, Label, …). We cover every widget in chapter 3.

Compile the form with fcompile -xml:

fcompile -xml hello.per

This produces a compiled form (an .xml file) that the client can render.

Step 2 — the program. Create hellogui.4gl:

MAIN
    DEFINE name    CHAR(40)
    DEFINE message CHAR(60)

    CLOSE WINDOW screen                      -- close the default text window

    OPEN WINDOW w1 WITH FORM "hello"         -- "hello" = the form name, no path, no extension
    CALL ui.Interface.setText("Hello Window")

    INPUT BY NAME name WITHOUT DEFAULTS      -- let the user type a name

    LET message = "Hello, ", name CLIPPED, "!"
    DISPLAY BY NAME message                  -- show the result

    MENU "Done"
        COMMAND "Close"
            EXIT MENU
    END MENU

    CLOSE WINDOW w1
END MAIN

A few things to notice:

  • OPEN WINDOW w1 WITH FORM "hello" uses the form name only — no directory and no extension. The runtime finds the compiled form for you (see the box below).
  • INPUT BY NAME name lets the user edit the field whose variable is name.
  • LET message = "Hello, ", name CLIPPED, "!" builds a string. The comma joins pieces together, and CLIPPED trims the trailing spaces from the fixed-length CHAR field.
  • MENU ... END MENU shows the action buttons the user can press.

Step 3 — compile and run. Compile the program, make sure the client is running and listening, then launch:

4glpc -o hellogui.4ae hellogui.4gl
./hellogui.4ae

A window opens in the VDC client. Type a name, watch the message appear, then press Close.

The VDC desktop client rendering a 4GL application
The VDC desktop client rendering a 4GL application — the forms and menus you write, shown as native windows. No GUI code on your side.

How does the runtime find the form? It looks for the compiled form in the current directory first. To keep forms in another directory, add it to the search path with DBPATH (colon-separated, like PATH):

export DBPATH=.:/path/to/my/forms

For this guide we keep the form and the program in the same directory, so the default works.

The edit / compile / run loop

That is the whole loop you will repeat all day:

  1. Edit your .4gl and .per files.
  2. fcompile -xml form.per whenever you change a form.
  3. 4glpc -o prog.4ae prog.4gl whenever you change code.
  4. ./prog.4ae to run.

Tip. You only need to re-run fcompile when you change a form, and only need to re-run 4glpc when you change code. Forms and code compile independently.

Next, learn the language itself: Language Basics.