12.07.2015 Views

JYACC FORMAKER C Programmer's Guide Contents 1 ... - Prolifics

JYACC FORMAKER C Programmer's Guide Contents 1 ... - Prolifics

JYACC FORMAKER C Programmer's Guide Contents 1 ... - Prolifics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

K_ENTEXIT Set if the function was called during screen entry,clear during exit.K_NORMAL Set if the function was called from sm_close_window,clear otherwise.A single function used for both entry and exit can use this bit to distinguishits context. One advantage of coding screen entry and exit processing in thesame function is that persistent variables, such as pointers to dynamicallyallocated buffers, can be made static rather than global.Any value returned from a screen entry or exit function is ignored.1.2.2 ExampleHere is an example of a screen entry function. This one loads up an itemselection list from a disk file whose name is stored in the screen.#include "smdefs.h"/* Here is a screen entry function for a generic item* selection screen. It turns the screen name into the* name of a text file containing a list of items, one* per line, and loads them into the array named "items".* This technique could be easily adapted to query a database* instead.*/void gen_entry (name, context)char *name;int context;{FILE *inf;char line[256];int k;}sprintf (line, "%s.dat", name ? name : "default");if ((inf = fopen (line, "r")) == 0)return;for (k = 1; fgets (line, sizeof(line), inf); ++k)sm_i_putfield ("items", k, line);fclose (inf);/* Here is code to install the above function in the screen* entry function list. */static struct fnc_data sentry[] = {{ "gen_entry", gen_entry, 0, 0, 0, 0 }};int count;count = sizeof(sentry) / sizeof(struct fnc_data);sm_install (FENTRY_FUNC, sentry, &count);1.3 The Function Lists<strong>JYACC</strong> <strong>FORMAKER</strong> stores function names as text strings in screen files. It needsto associate these names with the functions' addresses in order to call them.You must furnish this association by building lists of data structures calledfunction lists. Attached and screen entry functions must all appear; there isone list for each type of function. For example, if an application's screenscontained two functions named apfunc1 and apfunc2 that were attached to a field,its startup code would need to include the following:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!