unifbeg
Start an application, or initialize the Uniface environment, so forms can be executed.
int unifbeg (int
, batch)
Parameters
batch—a flag specifying whether the environment must be started in interactive or batch mode. A value of zero specifies interactive mode; a non-zero value specifies batch mode.
Return Values
Value |
Meaning |
---|---|
1 |
Successful completion |
0 |
No application shell was defined with
|
-1 |
Keyboard or device translation table load error |
-2 |
Licence error |
-4 |
Memory allocation error |
-5 |
Assignment error |
-6 |
Application screen start-up error |
-8 |
Specified application shell was not found |
-10 |
Specified application shell has an empty apStart trigger |
Use
Library ucall
Description
unifbeg
, together with
urun
and unifend
, implements the old-style call-in API. If your
main application is not a Uniface application, you must call unifbeg
before you
can call urun
. You should not be calling unifbeg
from code that
is being called by Uniface, because the initialization will already have been done.
If you specify a zero value for the
batch parameter, the environment is initialized for interactive mode where you
can then run forms with user interaction. Any non-zero value for batch specifies
batch mode. The value of the ProcScript function $batch
will be set
accordingly.
Starting with Uniface V8, unifbeg
no longer loads an application shell. If you want to use a specific application shell, you
must specify it with a call to usysparm
with code zero, then call
unifbeg
. This application shell must have ProcScript in the apStart trigger,
otherwise unifbeg
will return –10. The code in the apStart trigger will be
executed by unifbeg
, so you can use unifbeg
to run an
application. If you do not specify an application shell, or if the apStart trigger does not contain a
run or activate command, unifbeg
just serves
as the necessary initialization for urun
.
When you specify an application shell with
usysparm
, you must supply the .aps
suffix (see the example
below). unifbeg
will then try to use both the aps file and
the asn file with the same root name, using the normal search paths. If the
assignment file does not exist, it will still work.
While Uniface still supports call-in by means of
unifbeg
, urun
, and unifend
, we recommend that
you use the newer call-in API (uecreate
, and so on), because they give you the
full functionality of the activate
command.
unifbeg, unifend, and urun for simple call-in
The following C code performs a straight-forward call-in:
#include <h3gl.h> void main (void) { /* Tell unifbeg to use myapp.aps/myapp.asn */ usetparm(0, "myapp.aps", ""); unifbeg(0); /* Start Uniface interactive environment */ urun("FRM", 0, 0, 0, 0); /* Run form FRM with default size/position */ unifend(-1); /* Shut down the Uniface environment */ }
unifbeg, unifend, and urun with multiple forms
The following character mode call-in program starts the Uniface environment and executes two different forms. It then instructs Uniface to suspend itself and position the cursor on the bottom left corner of the screen so it can print a message there and read a keystroke from the keyboard. It then re-initializes the environment and executes two more forms before finally shutting down.
#include <h3gl.h> #include <stdio.h> #define PROMPT "User: Please enter a keyboard character > " main() { char ch; unifbeg(0); /* Initialize Uniface in interactive mode */ /* Run FORM1 with default size and position */ urun("FORM1", 0, 0, 0, 0); /* Run FORM2 with default size and position */ urun("FORM2", 0, 0, 0, 0); unifend(1); /* Position cursor in bottom left corner */ printf(PROMPT); /* Prompt user */ ch = getchar(); /* Read character from keyboard */ unifbeg(0); /* Resume Uniface */ /* Run FORM3 with default size and position */ urun("FORM3", 0, 0, 0, 0); /* Run FORM4 with default size and position */ urun("FORM4", 0, 0, 0, 0); unifend(-1); /* Shutdown and terminate program */ }