C Example 1

  1. Disable ERROR ABORT option so control will return to the terminal if the program aborts due to a fatal error.  (Control would be returned to the terminal with ERROR ABORT option enabled anyway if no command module was specified in System Field @ABORT_CM.)

*DISABLE ERROR ABORT

  1. Define the System File (SF) that will contain the C source code.  Insert the code below.

*DEFINE SF CORD1.C

(Depending on the editor used, the command "INSERT" may need to be entered.)

[Beginning of C example 1.]

=====================================================================

/* CORD1.C  - written by NIS to demonstrate HLI procedure calls in C

This program can be used to append records to the Sales and Store Data Sets in the BOOKS DBL.  The Books Data Set is also updated.

A library function (descrip.h) is included to provide a model structure (dsc$descriptor) for the descriptors used to pass values in the HLI procedure calls.*/

#include <descrip.h>

main()

{/*  declare variables */

long    con1 = 1, code, con0, o_date, q, disc2, s_data, st_data, d_data, b_data = 0,

        adv, roy, pub_d, lo_qty, hi_qty = 0;

double  s_tot, cost, ytd = 0;

char    *ax[5], *d_t_c[7], *d_s_c[5], *s_no[5], *answer[1], *o_no[21], p_terms[13],

        *s_t_no[7],  *b_t_no[7[, *txt[41], *b_type[13], *p_code[21], notes[201],

        *d_d_t[41], *st_s_no[5], *d_s_num[5],*name[31],*address[31],*city[21],

        *state[3],*zip[6],*country[21];

char    *bk = "", *tr = "TRACE", *tr2 = "@HLI_TRACE", *upd = "UPDATE", *lang = "C",

        *def = "DEFER", *di = "DI", *bks = "BOOKS", *al ="ALL", *ord1 = "ORD_NUM",

        *ord2 = "ORD_DATE", *pt = "PAY_TERMS", *sc = "STORE_CODE", *z1 = "ZIP",

        *nis_s = "NISDEMO:SALES_DBM2", *nis_d = "NISDEMO:DISCOUNTS_DBM2",

        *nis_st = "NISDEMO:STORES_DBM2", *nis_b = "NISDEMO:BOOKS_DBM2",

        *c_def = "CREATE+DEFER", *q2 = "QTY", *tc = "TITLE_CODE", *c1 = "CITY",

        *inp = "INPUT", *sn1 = "STORE_NAME", *sa1 = "STORE_ADDRESS",

        *s1 = "STATE", *c2 = "COUNTRY", *pr = "PRICE", *tt = "TITLE_TEXT",

        *t_co = "TITLE_CODE", *p_co = "PUB_CODE", *aa = "ADVANCE_AMT",

        *royal = "ROYALTY", *ytd2 = "YTD_SALES", *pd2 = "PUB_DATE",

        *lq9 = "LOW_QTY", *hq9 = "HIGH_QTY", *day1="@DATE", *d9 = "DISCOUNT",

        *mash = "MATCH+HUSH", *cmd = "COMMAND", *lani = "LAST+NOTINDEXED",

        *au = "@AUX", *nts = "NOTES", *dity = "DISCOUNT_TYPE";

char    *sql1 = "OSQL INSERT NISDEMO:STORES_DBM2 WITH WINDOW";

char    *sql2 = "OSQL SELECT * FROM NISDEMO:SALES_DBM2 WITH WINDOW";

char    *quit = "QUIT";

/*  label structure templates for descriptors  */

struct dsc$descriptor err, s_ds, st_ds, d_ds, b_ds;

struct dsc$descriptor XAU, d_t_code, d_s_code;

struct dsc$descriptor s_store, s_ord, s_terms, s_title, s_date, s_q;

struct dsc$descriptor s_set, st_set, d_set, b_set;

struct dsc$descriptor b_title, b_text, b_code, b_price, b_adv, b_roy, b_ytd, b_not,

b_date, b_pub;

struct dsc$descriptor d_type, d_store, d_low, d_hi, d_disc;

struct dsc$descriptor st_store, st_name, st_add, st_city, st_state, st_zip, st_count;

struct dsc$descriptor B_NOTE, B_TYPE, AUX, SET_1, SET_0, BK, HLI, C,

                TRACE, UPDATE, DEFER, DI, BOOKS, STORE, NUM,DAT,PAY,ALL,

                CREATE, TITLE, QTY, INPUT, S_NAME,S_ADD, S_CITY,S_STATE,

                S_ZIP,S_COUNT,TEXT,TYPE,PUB_C, B_COST,B_VANCE, B_ROYAL,

                YTD,P_DATE,LO,HI, DISC, DAY, MHUSH, COMMAND, OSQL1,

                OSQL2, LASTNI, QUIT;

/*  fill-in structure field values for descriptors  */

err.dsc$w_length = sizeof(long);

err.dsc$a_pointer = &code;

err.dsc$b_class = DSC$K_CLASS_S;

err.dsc$b_dtype = DSC$K_DTYPE_L;

SET_1.dsc$w_length = sizeof(long);

SET_1.dsc$a_pointer = &con1;

SET_1.dsc$b_class = DSC$K_CLASS_SD;

SET_1.dsc$b_dtype = DSC$K_DTYPE_L;

SET_0.dsc$w_length = sizeof(long);

SET_0.dsc$a_pointer = &con0;

SET_0.dsc$b_class = DSC$K_CLASS_SD;

SET_0.dsc$b_dtype = DSC$K_DTYPE_L;

b_price.dsc$w_length = sizeof(double);

b_price.dsc$a_pointer = &cost;

b_price.dsc$b_class = DSC$K_CLASS_S;

b_price.dsc$b_dtype = DSC$K_DTYPE_D;

b_ytd.dsc$w_length = sizeof(double);

b_ytd.dsc$a_pointer = &ytd;

b_ytd.dsc$b_class = DSC$K_CLASS_S;

b_ytd.dsc$b_dtype = DSC$K_DTYPE_D;

s_set.dsc$w_length = sizeof(long);

s_set.dsc$a_pointer = &s_data;

s_set.dsc$b_class = DSC$K_CLASS_S;

s_set.dsc$b_dtype = DSC$K_DTYPE_L;

st_set.dsc$w_length = sizeof(long);

st_set.dsc$a_pointer = &st_data;

st_set.dsc$b_class = DSC$K_CLASS_S;

st_set.dsc$b_dtype = DSC$K_DTYPE_L;

b_set.dsc$w_length = sizeof(long);

b_set.dsc$a_pointer = &b_data;

b_set.dsc$b_class = DSC$K_CLASS_S;

b_set.dsc$b_dtype = DSC$K_DTYPE_L;

d_set.dsc$w_length = sizeof(long);

d_set.dsc$a_pointer = &d_data;

d_set.dsc$b_class = DSC$K_CLASS_S;

d_set.dsc$b_dtype = DSC$K_DTYPE_L;

s_date.dsc$w_length = sizeof(long);

s_date.dsc$a_pointer = &o_date;

s_date.dsc$b_class = DSC$K_CLASS_S;

s_date.dsc$b_dtype = DSC$K_DTYPE_L;

s_q.dsc$w_length = sizeof(long);

s_q.dsc$a_pointer = &q;

s_q.dsc$b_class = DSC$K_CLASS_S;

s_q.dsc$b_dtype = DSC$K_DTYPE_L;

b_adv.dsc$w_length = sizeof(long);

b_adv.dsc$a_pointer = &adv;

b_adv.dsc$b_class = DSC$K_CLASS_S;

b_adv.dsc$b_dtype = DSC$K_DTYPE_L;

b_roy.dsc$w_length = sizeof(long);

b_roy.dsc$a_pointer = &roy;

b_roy.dsc$b_class = DSC$K_CLASS_S;

b_roy.dsc$b_dtype = DSC$K_DTYPE_L;

b_date.dsc$w_length = sizeof(long);

b_date.dsc$a_pointer = &pub_d;

b_date.dsc$b_class = DSC$K_CLASS_S;

b_date.dsc$b_dtype = DSC$K_DTYPE_L;

d_low.dsc$w_length = sizeof(long);

d_low.dsc$a_pointer = &lo_qty;

d_low.dsc$b_class = DSC$K_CLASS_S;

d_low.dsc$b_dtype = DSC$K_DTYPE_L;

d_hi.dsc$w_length = sihi_qty;

d_hi.dsc$b_class = DSC$K_CLASS_S;

d_hi.dsc$b_dtype = DSC$K_DTYPE_L;

d_disc.dsc$w_length = sizeof(long);

d_disc.dsc$a_pointer = &disc2;

d_disc.dsc$b_class = DSC$K_CLASS_S;

d_disc.dsc$b_dtype = DSC$K_DTYPE_L;

BK.dsc$w_length = strlen(bk);

BK.dsc$a_pointer = bk;

BK.dsc$b_class = DSC$K_CLASS_S;

BK.dsc$b_dtype = DSC$K_DTYPE_T;

TRACE.dsc$w_length = strlen(tr);

TRACE.dsc$a_pointer = tr;

TRACE.dsc$b_class = DSC$K_CLASS_S;

TRACE.dsc$b_dtype = DSC$K_DTYPE_T;

HLI.dsc$w_length = strlen(tr2);

HLI.dsc$a_pointer = tr2;

HLI.dsc$b_class = DSC$K_CLASS_S;

HLI.dsc$b_dtype = DSC$K_DTYPE_T;

UPDATE.dsc$w_length = strlen(upd);

UPDATE.dsc$a_pointer = upd;

UPDATE.dsc$b_class = DSC$K_CLASS_S;

UPDATE.dsc$b_dtype = DSC$K_DTYPE_T;

C.dsc$w_length = strlen(lang);

C.dsc$a_pointer = lang;

C.dsc$b_class = DSC$K_CLASS_S;

C.dsc$b_dtype = DSC$K_DTYPE_T;

s_ds.dsc$w_length = strlen(nis_s);

s_ds.dsc$a_pointer = nis_s;

s_ds.dsc$b_class = DSC$K_CLASS_S;

s_ds.dsc$b_dtype = DSC$K_DTYPE_T;

d_ds.dsc$w_length = strlen(nis_d);

d_ds.dsc$a_pointer = nis_d;

d_ds.dsc$b_class = DSC$K_CLASS_S;

d_ds.dsc$b_dtype = DSC$K_DTYPE_T;

st_ds.dsc$w_length = strlen(nis_st);

st_ds.dsc$a_pointer = nis_st;

st_ds.dsc$b_class = DSC$K_CLASS_S;

st_ds.dsc$b_dtype = DSC$K_DTYPE_T;

b_ds.dsc$w_length = strlen(nis_b);

b_ds.dsc$a_pointer = nis_b;

b_ds.dsc$b_class = DSC$K_CLASS_S;

b_ds.dsc$b_dtype = DSC$K_DTYPE_T;

DEFER.dsc$w_length = strlen(def);

DEFER.dsc$a_pointer = def;

DEFER.dsc$b_class = DSC$K_CLASS_S;

DEFER.dsc$b_dtype = DSC$K_DTYPE_T;

DI.dsc$w_length = strlen(di);

DI.dsc$a_pointer = di;

DI.dsc$b_class = DSC$K_CLASS_S;

DI.dsc$b_dtype = DSC$K_DTYPE_T;

BOOKS.dsc$w_length = strlen(bks);

BOOKS.dsc$a_pointer = bks;

BOOKS.dsc$b_class = DSC$K_CLASS_S;

BOOKS.dsc$b_dtype = DSC$K_DTYPE_T;

STORE.dsc$w_length = strlen(sc);

STORE.dsc$a_pointer = sc;

STORE.dsc$b_class = DSC$K_CLASS_S;

STORE.dsc$b_dtype = DSC$K_DTYPE_T;

NUM.dsc$w_length = strlen(ord1);

NUM.dsc$a_pointer = ord1;

NUM.dsc$b_class = DSC$K_CLASS_S;

NUM.dsc$b_dtype = DSC$K_DTYPE_T;

DAT.dsc$w_length = strlen(ord2);

DAT.dsc$a_pointer = ord2;

DAT.dsc$b_class = DSC$K_CLASS_S;

DAT.dsc$b_dtype = DSC$K_DTYPE_T;

PAY.dsc$w_length = strlen(pt);

PAY.dsc$a_pointer = pt;

PAY.dsc$b_class = DSC$K_CLASS_S;

PAY.dsc$b_dtype = DSC$K_DTYPE_T;

ALL.dsc$w_length = strlen(al);

ALL.dsc$a_pointer = al;

ALL.dsc$b_class = DSC$K_CLASS_S;

ALL.dsc$b_dtype = DSC$K_DTYPE_T;

CREATE.dsc$w_length = strlen(c_def);

CREATE.dsc$a_pointer = c_def;

CREATE.dsc$b_class = DSC$K_CLASS_S;

CREATE.dsc$b_dtype = DSC$K_DTYPE_T;

TITLE.dsc$w_length = strlen(tc);

TITLE.dsc$a_pointer = tc;

TITLE.dsc$b_class = DSC$K_CLASS_S;

TITLE.dsc$b_dtype = DSC$K_DTYPE_T;

QTY.dsc$w_length = strlen(q2);

QTY.dsc$a_pointer = q2;

QTY.dsc$b_class = DSC$K_CLASS_S;

QTY.dsc$b_dtype = DSC$K_DTYPE_T;

INPUT.dsc$w_length = strlen(inp);

INPUT.dsc$a_pointer = inp;

INPUT.dsc$b_class = DSC$K_CLASS_S;

INPUT.dsc$b_dtype = DSC$K_DTYPE_T;

S_NAME.dsc$w_length = strlen(sn1);

S_NAME.dsc$a_pointer = sn1;

S_NAME.dsc$b_class = DSC$K_CLASS_S;

S_NAME.dsc$b_dtype = DSC$K_DTYPE_T;

S_ADD.dsc$w_length = strlen(sa1);

S_ADD.dsc$a_pointer = sa1;

S_ADD.dsc$b_class = DSC$K_CLASS_S;

S_ADD.dsc$b_dtype = DSC$K_DTYPE_T;

S_CITY.dsc$w_length = strlen(c1);

S_CITY.dsc$a_pointer = c1;

S_CITY.dsc$b_class = DSC$K_CLASS_S;

S_CITY.dsc$b_dtype = DSC$K_DTYPE_T;

S_STATE.dsc$w_length = strlen(s1);

S_STATE.dsc$a_pointer = s1;

S_STATE.dsc$b_class = DSC$K_CLASS_S;

S_STATE.dsc$b_dtype = DSC$K_DTYPE_T;

S_ZIP.dsc$w_length = strlen(z1);

S_ZIP.dsc$a_pointer = z1;

S_ZIP.dsc$b_class = DSC$K_CLASS_S;

S_ZIP.dsc$b_dtype = DSC$K_DTYPE_T;

S_COUNT.dsc$w_length = strlen(c2);

S_COUNT.dsc$a_pointer = c2;

S_COUNT.dsc$b_class = DSC$K_CLASS_S;

S_COUNT.dsc$b_dtype = DSC$K_DTYPE_T;

TEXT.dsc$w_length = strlen(tt);

TEXT.dsc$a_pointer = tt;

TEXT.dsc$b_class = DSC$K_CLASS_S;

TEXT.dsc$b_dtype = DSC$K_DTYPE_T;

TYPE.dsc$w_length = strlen(t_co);

TYPE.dsc$a_pointer = t_co;

TYPE.dsc$b_class = DSC$K_CLASS_S;

TYPE.dsc$b_dtype = DSC$K_DTYPE_T;

PUB_C.dsc$w_length = strlen(p_co);

PUB_C.dsc$a_pointer = p_co;

PUB_C.dsc$b_class = DSC$K_CLASS_S;

PUB_C.dsc$b_dtype = DSC$K_DTYPE_T;

B_COST.dsc$w_length = strlen(pr);

B_COST.dsc$a_pointer = pr;

B_COST.dsc$b_class = DSC$K_CLASS_S;

B_COST.dsc$b_dtype = DSC$K_DTYPE_T;

B_NOTE.dsc$w_length = strlen(nts);

B_NOTE.dsc$a_pointer = nts;

B_NOTE.dsc$b_class = DSC$K_CLASS_S;

B_NOTE.dsc$b_dtype = DSC$K_DTYPE_T;

B_VANCE.dsc$w_length = strlen(aa);

B_VANCE.dsc$a_pointer = aa;

B_VANCE.dsc$b_class = DSC$K_CLASS_S;

B_VANCE.dsc$b_dtype = DSC$K_DTYPE_T;

B_ROYAL.dsc$w_length = strlen(royal);

B_ROYAL.dsc$a_pointer = royal;

B_ROYAL.dsc$b_class = DSC$K_CLASS_S;

B_ROYAL.dsc$b_dtype = DSC$K_DTYPE_T;

YTD.dsc$w_length = strlen(ytd2);

YTD.dsc$a_pointer = ytd2;

YTD.dsc$b_class = DSC$K_CLASS_S;

YTD.dsc$b_dtype = DSC$K_DTYPE_T;

P_DATE.dsc$w_length = strlen(pd2);

P_DATE.dsc$a_pointer = pd2;

P_DATE.dsc$b_class = DSC$K_CLASS_S;

P_DATE.dsc$b_dtype = DSC$K_DTYPE_T;

LO.dsc$w_length = strlen(lq9);

LO.dsc$a_pointer = lq9;

LO.dsc$b_class = DSC$K_CLASS_S;

LO.dsc$b_dtype = DSC$K_DTYPE_T;

HI.dsc$w_length = strlen(hq9);

HI.dsc$a_pointer = hq9;

HI.dsc$b_class = DSC$K_CLASS_S;

HI.dsc$b_dtype = DSC$K_DTYPE_T;

D_TYPE.dsc$w_length = strlen(dity);

D_TYPE.dsc$a_pointer = dity;

D_TYPE.dsc$b_class = DSC$K_CLASS_S;

D_TYPE.dsc$b_dtype = DSC$K_DTYPE_T;

DISC.dsc$w_length = strlen(d9);

DISC.dsc$a_pointer = d9;

DISC.dsc$b_class = DSC$K_CLASS_S;

DISC dsc$b_dtype = DSC$K_DTYPE_T

DAY.dsc$w_length = strlen(day1);

DAY.dsc$a_pointer = day1;

DAY.dsc$b_class = DSC$K_CLASS_S;

DAY.dsc$b_dtype = DSC$K_DTYPE_T;

MHUSH.dsc$w_length = strlen(mash);

MHUSH.dsc$a_pointer = mash;

MHUSH.dsc$b_class = DSC$K_CLASS_S;

MHUSH.dsc$b_dtype = DSC$K_DTYPE_T;

COMMAND.dsc$w_length = strlen(cmd);

COMMAND.dsc$a_pointer = cmd;

COMMAND.dsc$b_class = DSC$K_CLASS_S;

COMMAND.dsc$b_dtype = DSC$K_DTYPE_T;

OSQL1.dsc$w_length = strlen(sql1);

OSQL1.dsc$a_pointer = sql1;

OSQL1.dsc$b_class = DSC$K_CLASS_S;

OSQL1.dsc$b_dtype = DSC$K_DTYPE_T;

OSQL2.dsc$w_length = strlen(sql2);

OSQL2.dsc$a_pointer = sql2;

OSQL2.dsc$b_class = DSC$K_CLASS_S;

OSQL2.dsc$b_dtype = DSC$K_DTYPE_T;

QUIT.dsc$w_length = strlen(quit);

QUIT.dsc$a_pointer = quit;

QUIT.dsc$b_class = DSC$K_CLASS_S;

QUIT.dsc$b_dtype = DSC$K_DTYPE_T;

LASTNI.dsc$w_length = strlen(lani);

LASTNI.dsc$a_pointer = lani;

LASTNI.dsc$b_class = DSC$K_CLASS_S;

LASTNI.dsc$b_dtype = DSC$K_DTYPE_T;

AUX.dsc$w_length = strlen(au);

AUX.dsc$a_pointer = au;

AUX.dsc$b_class = DSC$K_CLASS_S;

AUX.dsc$b_dtype = DSC$K_DTYPE_T;

XAU.dsc$w_length = strlen(ax);

XAU.dsc$a_pointer = ax;

XAU.dsc$b_class = DSC$K_CLASS_S;

XAU.dsc$b_dtype = DSC$K_DTYPE_T;

d_t_code.dsc$w_length = 7;

d_t_code.dsc$a_pointer = d_t_c;

d_t_code.dsc$b_class = DSC$K_CLASS_S;

d_t_code.dsc$b_dtype = DSC$K_DTYPE_T;

d_s_code.dsc$w_length = 5;

d_s_code.dsc$a_pointer = d_s_c;

d_s_code.dsc$b_class = DSC$K_CLASS_S;

d_s_code.dsc$b_dtype = DSC$K_DTYPE_T;

s_store.dsc$w_length = 4;

s_store.dsc$a_pointer = s_no;

s_store.dsc$b_class = DSC$K_CLASS_S;

s_store.dsc$b_dtype = DSC$K_DTYPE_T;

s_ord.dsc$w_length = 20;

s_ord.dsc$a_pointer = o_no;

s_ord.dsc$b_class = DSC$K_CLASS_S;

s_ord.dsc$b_dtype = DSC$K_DTYPE_T;

s_terms.dsc$w_length = 12;

s_terms.dsc$a_pointer = p_terms;

s_terms.dsc$b_class = DSC$K_CLASS_S;

s_terms.dsc$b_dtype = DSC$K_DTYPE_T;

s_title.dsc$w_length = 6;

s_title.dsc$a_pointer = s_t_no;

s_title.dsc$b_class = DSC$K_CLASS_S;

s_title.dsc$b_dtype = DSC$K_DTYPE_T;

b_title.dsc$w_length = 6;

b_title.dsc$a_pointer = b_t_no;

b_title.dsc$b_class = DSC$K_CLASS_S;

b_title.dsc$b_dtype = DSC$K_DTYPE_T;

b_text.dsc$w_length = 40;

b_text.dsc$a_pointer = txt;

b_text.dsc$b_class = DSC$K_CLASS_S;

b_text.dsc$b_dtype = DSC$K_DTYPE_T;

b_code.dsc$w_length = 12;

b_code.dsc$a_pointer = b_type;

b_code.dsc$b_class = DSC$K_CLASS_S;

b_code.dsc$b_dtype = DSC$K_DTYPE_T;

b_not.dsc$w_length = 200;

b_not.dsc$a_pointer = note;

b_not.dsc$b_class = DSC$K_CLASS_S;

b_not.dsc$b_dtype = DSC$K_DTYPE_T;

b_pub.dsc$w_length = 4;

b_pub.dsc$a_pointer = p_code;

b_pub.dsc$b_class = DSC$K_CLASS_S;

b_pub.dsc$b_dtype = DSC$K_DTYPE_T;

d_type.dsc$w_length = 40;

d_type.dsc$a_pointer = d_d_t;

d_type.dsc$b_class = DSC$K_CLASS_S;

d_type.dsc$b_dtype = DSC$K_DTYPE_T;

d_store.dsc$w_length = 4;

d_store.dsc$a_pointer = d_s_num;

d_store.dsc$b_class = DSC$K_CLASS_S;

d_store.dsc$b_dtype = DSC$K_DTYPE_T;

st_store.dsc$w_length = 4;

st_store.dsc$a_pointer = st_s_no;

st_store.dsc$b_class = DSC$K_CLASS_S;

st_store.dsc$b_dtype = DSC$K_DTYPE_T;

st_name.dsc$w_length = 30;

st_name.dsc$a_pointer = name;

st_name.dsc$b_class = DSC$K_CLASS_S;

st_name.dsc$b_dtype = DSC$K_DTYPE_T;

st_add.dsc$w_length = 30;

st_add.dsc$a_pointer = address;

st_add.dsc$b_class = DSC$K_CLASS_S;

st_add.dsc$b_dtype = DSC$K_DTYPE_T;

st_city.dsc$w_length = 20;

st_city.dsc$a_pointer = city;

st_city.dsc$b_class = DSC$K_CLASS_S;

st_city.dsc$b_dtype = DSC$K_DTYPE_T;

st_state.dsc$w_length = 2;

st_state.dsc$a_pointer = state;

st_state.dsc$b_class = DSC$K_CLASS_S;

st_state.dsc$b_dtype = DSC$K_DTYPE_T;

st_zip.dsc$w_length = 5;

st_zip.dsc$a_pointer = zip;

st_zip.dsc$b_class = DSC$K_CLASS_S;

st_zip.dsc$b_dtype = DSC$K_DTYPE_T;

st_count.dsc$w_length = 20;

st_count.dsc$a_pointer = country;

st_count.dsc$b_class = DSC$K_CLASS_S;

st_count.dsc$b_dtype = DSC$K_DTYPE_T;

/*  CALL #1 (ACCINI) - HLI initialization  */

ACCINI(&err, &TRACE, &C);

/*  CALL #2a (ACCSTO) - store values into ACCENT R variables, set tracing  */

ACCSTO(&err, &TRACE, &SET_0, &HLI, &SET_1);

*answer = ' ';

while (code == 0 && *answer != 'x')

{/*  CALL #3 (ACCDBL) - declare the BOOKS DBL for use  */

ACCDBL(&err, &SET_0, &BOOKS);

  if (code != 0) continue;

/*  CALL #4 (ACCOPN) - declare Sales DI for access. (There are four DIs to open) */

ACCOPN(&err, &UPDATE, &DI, &s_ds, &s_set);

  if (code != 0) continue;

/*  CALL #2b (ACCSTO) - specify host fields whose values will be appended to the

                        Sales DS fields  (Actual data transfer is deferred until

                        the ACCCRE call.  The &CREATE descriptor was defined as

                        CREATE + DEFER.) /

 

ACCSTO(&err, &CREATE, &s_set,

&STORE, &s_store,

&NUM, &s_ord,

&DAT, &s_date,

&QTY, &s_q,

&PAY, &s_terms,

&TITLE, &s_title);

  if (code != 0) continue;

ACCOPN(&err, &INPUT, &DI, &st_ds, &st_set);

  if (code != 0) continue;

 

/* CALL #5 (ACCLOA) - open Data Sets and specify DS fields that will have their

                      values loaded into host variables  (Actual data transfer

                      deferred until the ACCGET call)  */

 

ACCLOA(&err, &DEFER, &st_set,

&STORE, &st_store,

&S_NAME, &st_name,

&S_ADD,&st_add,

&S_CITY, &st_city,

&S_STATE, &st_state,

&S_ZIP, &st_zip,

&S_COUNT, &st_count);

  if (code != 0) continue;

 

ACCOPN(&err, &INPUT, &DI, &b_ds, &b_set);

  if (code != 0) continue;

ACCLOA(&err, &DEFER, b_set,

&TITLE, &b_title,

&TEXT, &b_text,

&TYPE, &b_code,

&PUB_C, &b_pub,

&B_COST, &b_price,

&B_VANCE, &b_adv,

&B_ROYAL, &b_roy,

&YTD, &b_ytd,

&B_NOTE, &b_not,

&P_DATE, &b_date);

  if (code != 0) continue;

/*  CALL #2c (ACCSTO) - specify host variables whose values will update Books DS

                        fields (Actual data transfer deferred until the ACCPUT

                        call) */

ACCSTO(&err, &DEFER, &b_set, &YTD, &b_ytd);

  if (code != 0) continue;

ACCOPN(&err, &INPUT, &DI, &d_ds, &d_set);

  if (code != 0) continue;

ACCLOA(&err, &DEFER, d_set,

    &D_TYPE, &d_type,

    &STORE, &d_store,

    &LO, &d_lo,

    &HI, &d_hi,

    &DISC, &d_disc);

  if (code != 0) continue;

*answer = 'x';}

/* Begin order processing...

    CALL #5d (ACCLOA) - Load system date into host field  */

ACCLOA(&err, &SET_0, &SET_0, &DAY, &s_date);

if (code == 0)

  while (*d_s_c != 'stop' || *d_s_c != 'STOP')

{printf("\n");

printf("ENTER <STOP> TO EXIT APPLICATION. \n \n");

printf("ENTER STORE CODE <9999> OR <STOP>:  ");

scanf("%s", &d_s_c);

  if (*d_s_c == 'stop' || *d_s_c == 'STOP') break;

/* CALL #6 (ACCGET) - Retrieve store code from Store DS to verify user input. Load

                      @AUX processing message into host field */

ACCGET(&err, &MHUSH, &st_set, &BK, &d_s_code);

ACCLOA(&err, &SET_0, &SET_0, &AUX, &XAU);

answer = ' ';

if (*ax == 'YES') printf("STORE NAME: %s \n", &name);

if (*ax != 'YES ')

  while (*answer != 'Y" && *answer != 'y' && *answer != 'N" && *answer != 'n')

    {printf("\n");

    printf("STORE CODE DID NOT MATCH IN FILE.  SHOULD IT BE ADDED? [Y/N]");

    scanf("%s", &answer);}

if (*answer == 'n' || *answer =='N") continue;

if (*answer == 'y' || *answer =='Y")

{/*  CALL #7a (ACCCLS) - Store DS is closed for OSQL access thru ACCCMD  */

ACCCLS(&err, &SET_0, &st_set);

/*  CALL #8a (ACCCMD) - Use OSQL to create new Store record; invoke thru ACCENT R

                        command  */

printf("\n");

printf("!!  BUILDING SCREEN TO ADD NEW STORE  !! \n");

printf("\n");

ACCCMD(&err, &COMMAND, &OSQL1, &QUIT);

printf("<<  STORE HAS BEEN ADDED  >> \n");

/*  The BOOKS DBL is redeclared and the Store DS reopened for access after OSQL is used.  */

ACCDBL(&err, &SET_0, &BOOKS);

ACCOPN(&err, &INPUT, &DI, &st_ds, &st_set);

ACCLOA(&err, &DEFER, &st_set,

        &STORE, &st_store,

        &S_NAME, &st_name,

        &S_ADD,

        &st_add,

        &S_CITY, &st_city,

        &S_STATE, &st_state,

        &S_ZIP, &st_zip,

        &S_COUNT, &st_count);

/*  Display store record that was just added to verify entry  */

printf("THE FOLLOWING STORE WAS ADDED: \n");

printf("\n");

ACCGET(&err, &LASTNI, &st_set, &BK);

printf("STORE CODE: %s \n", &st_s_no);

printf("STORE NAME: %s \n", &name);}

/* Enter order data */

printf("\n");

printf("ENTER ORDER NUMBER OR <EXIT> TO START OVER. \n");

scanf("%s", &o_no);

  if (*o_no == 'EXIT' || *o_no == 'exit') continue;

while (*d_t_c_ != 'end' || *d_t_c != 'END')

{*d_t_c = "      ";

printf("\n");

printf("ENTER TITLE CODE OR <END> IF ORDER COMPLETED.");

scanf("%s", %d_t_c);

  if (*d_t_c_ == 'end' || *d_t_c == 'END')

    {printf("<< ORDER FINISHED >> \n");

    *o_no = "                    ";

    break;}

/*  Title code entry is verified in Books DS  */

ytd, cost = 0;

*b_t_no = "      ";

*txt = "                                        ";

ACCGET(&err, &MHUSH, &b_set, &BK, &b_t_code);

ACCLOA(&err, &SET_0, &SET_0, &AUX, &XAU);

  if (*ax != 'YES ")

    {printf("\n");

    printf("TITLE CODE DID NOT MATCH - TRY AGAIN. \n");

    continue;}

printf("TITLE:  %s \n", &txt);

printf ("PRICE:  $%4.2f \n", &cost);

printf("\n");

printf("ENTER ORDER QUANTITY:  ");

scanf("%d", &q);

printf("\n");

printf("ENTER PAYMENT TERMS:  [ex. net 30, net 60]");

scanf("%s", &p_terms);

*s_no = *d_s_c;

*s_t_no = *d_t_c;

/* Figure discount for order (if applicable) */

lo_qty, hi_qty, disc2, s_tot = 0;

*d_s_c = "    ";

*ax = "yes ";

while (*ax == 'yes ' || *ax == 'YES ' && q > hi_qty || q< lo_qty)

    {ACCGET(&err, &MHUSH, &d_set, &BK, &d_s_code);

    ACCLOA(&err, &SET_0, &SET_0, &AUX, &XAU);}

if (*ax != 'yes ' || *ax != 'YES ') disc2 = 0;

disc2 = disc2/100;

printf("YTD SALES [BEFORE ORDER]:  $%4.2f \n", ytd);

s_tot = cost * q - (cost * q) *disc2;

ytd = ytd +s_tot;

printf("YTD SALES [AFTER ORDER]:  $%4.2f \n", ytd);

/* CALL #9 (ACCPUT) - update record in Books DS  */

ACCPUT(&err, &SET_0, &b_set);

/* CALL #10 (ACCRDY) - clear/initialize record area for ACCCRE  */

ACCRDY(&err, &SET_0, &s_set);

/* CALL #11 (ACCCRE) - create/append new record to Sales DS  */

ACCCRE(&err, &SET_0, &s_set);

*p_terms = "            ";

*s_no = "    ";

*s_t_no = "      ";}}

/* Display error message if applicable. */

if (code != 0)

    {printf("\n");

    printf("***  PROGRAM FAILED DUE TO AN ERROR  *** \n");}

/* CALL #7b (ACCCLS) - all Data Sets are closed  */

ACCCLS(&err, &ALL);

/* CALL #8b (ACCCMD) - OSQL invoked thru ACCENT R command / build screen to

                       review Sales entries  */

printf("\n");

printf("!!  BUILDING SCREEN TO REVIEW SALES RECORDS  !! \n");

printf("\n");

ACCMD(&err, &COMMAND, &OSQL2, &QUIT);

/* CALL #12 (ACCEND) - terminate HLI session  */

ACCEND(&err);}

=====================================================================

[End of C Example 1.]

  1. Exit the insert mode.  Enter "END" or use CTRL-Z depending on the editor used.

  2. Save the program by entering "SAVE".  The editor will return control to the command level  prompt.

  3. Compile and LINK the C program through a System File (SF).  Enter commands below.

(Depending on the editor used, the command "INSERT" may need to be entered.)

*DEFINE SF HLIC_1.COM

$purge cord1.c

$delete cord1.obj;*

$delete cord1.exe;*

$define nisdemo [user_directory]

$define nis [accent_r_directory]

$define acchli nis:acchli

$cc cord1

$link cord1,nis:accvax,nis:acchli/lib

  1. Exit the insert mode.  Enter "END" or use CTRL-Z depending on the editor used.

  2. Save the command file by entering "SAVE".  The editor will return control to the command level prompt.

  3. Initiate the link then exit ACCENT R or link at the DCL command level.

*LINK TO DCL WITH '@HLIC_1' AND RETURN

*QUIT

(or)

*QUIT

$@HLIC_1

  1. Run application at the VAX DCL prompt.

$RUN CORD1

C Example 2

  1. Define the System File (SF) that will contain the C source code.  Insert the code below.

*DEFINE SF CORD2.C

(Depending on the editor used, the command "INSERT" may need to be entered.)

[Beginning of C example 2.]

=====================================================================

/* CORD2.C  - written by NIS to demonstrate HLI procedure calls in C

This program can be used to delete records in the Sales in the BOOKS DBL. The ACCENT R version and Sales DS information is displayed.  A keyword is formed to combine options in a descriptor.

A library function (descrip.h) is included to provide a model structure (dsc$descriptor) for the descriptors used to pass values in the HLI procedure calls.  */

#include <descrip.h>

main()

{/*  declare variables */

long   con1=1,code,con0,o_date, q,x_hush, x_lock,x_match,ds,dbl,i_time,x_opt = 0;

char   *ax[6], *d_t_c[6], *s_no[5], *answer[1], *o_no[21], p_terms[13], *t_no[7],

        *i_type[4], *i_name[41];

char   *bk = "", *tr = "TRACE", *tr2 = "@HLI_TRACE", *upd = "UPDATE", *lang = "C",

        *def = "DEFER", *di = "DI", *bks = "BOOKS", *al ="ALL", *ord1 ="ORD_NUM",

        *ord2 = "ORD_DATE", *pt = "PAY_TERMS", *sc = "STORE_CODE", pause

        *nis = "NISDEMO:SALES_DBM2",*q2 = "QTY", *tc = "TITLE_CODE",

        *hu = "HUSH", *au = "@AUX", *sd = "SD", *c_time = "CREATE.TIME"

        *im = "IMMEDIATE", *mat = "MATCH",*lok = "LOCKED", *gt = "GET",

        *data ="DBL", *dte = "DBL+TRACE+ENTRY", *sales = "SALES_DBM2",

        *et = "ENTRY.TIME", *en = "ENTRY.NAME";

/*  label structure templates for descriptors  */

struct dsc$descriptor    BK, BOOKS, HLI, TRACE, C, UPDATE, DI, DEMO, DEFER,

                         STORE,NUM, DAT, QQ, PAY, TITLE, GET, BASE, ENTRY, SD,

                         DBM2, ENTRY_T, ENTRY_N, CREATE, MATCH, HUSH, LOCKED, ALL,

                         XAU, IMM;

struct dsc$descriptor    x_hush, x_match, x_lock, x_opt, e_time, qty, ord_date,

                         err, SET_1, SET_0;

struct dsc$descriptor    sales_ds, book_dbl, aux, d_t_code, e_type, e_name,

                         store_no, order_no, terms, title_no;

*/ fill-in structure field values for descriptors  */

SET_0.dsc$w_length = sizeof (long);

SET_0.dsc$a_pointer = &con0;

SET_0.dsc$b_class = DSC$K_CLASS_SD;

SET_0.dsc$b_dtype = DSC$K_DTYPE_L;

SET_1.dsc$w_length = sizeof (long);

SET_1.dsc$a_pointer = &con1;

SET_1.dsc$b_class = DSC$K_CLASS_SD;

SET_1.dsc$b_dtype = DSC$K_DTYPE_L;

err.dsc$w_length = sizeof (long);

err.dsc$a_pointer = &code;

err.dsc$b_class = DSC$K_CLASS_S;

err.dsc$b_dtype = DSC$K_DTYPE_L;

x_hush.dsc$w_length = sizeof (long);

x_hush.dsc$a_pointer = &z_hush;

x_hush.dsc$b_class = DSC$K_CLASS_S;

x_hush.dsc$b_dtype = DSC$K_DTYPE_L;

x_match.dsc$w_length = sizeof (long);

x_match.dsc$a_pointer = &z_match;

x_match.dsc$b_class = DSC$K_CLASS_S;

x_match.dsc$b_dtype = DSC$K_DTYPE_L;

x_lock.dsc$w_length = sizeof (long);

x_lock.dsc$a_pointer = &z_lock;

x_lock.dsc$b_class = DSC$K_CLASS_S;

x_lock.dsc$b_dtype = DSC$K_DTYPE_L;

x_opt.dsc$w_length = sizeof (long);

x_opt.dsc$a_pointer = &z_opt;

x_opt.dsc$b_class = DSC$K_CLASS_S;

x_opt.dsc$b_dtype = DSC$K_DTYPE_L;

e_time.dsc$w_length = sizeof (long);

e_time.dsc$a_pointer = &i_time;

e_time.dsc$b_class = DSC$K_CLASS_S;

e_time.dsc$b_dtype = DSC$K_DTYPE_L;

sales_ds.dsc$w_length = sizeof (long);

sales.dsc$a_pointer = &ds;

sales.dsc$b_class = DSC$K_CLASS_S;

sales.dsc$b_dtype = DSC$K_DTYPE_L;

book_dbl.dsc$w_length = sizeof (long);

book_dbl.dsc$a_pointer = &dbl;

book_dbl.dsc$b_class = DSC$K_CLASS_S;

book_dbl.dsc$b_dtype = DSC$K_DTYPE_L;

qty.dsc$w_length = sizeof (long);

qty.dsc$a_pointer = &q;

qty.dsc$b_class = DSC$K_CLASS_S;

qty.dsc$b_dtype = DSC$K_DTYPE_L;

ord_date.dsc$w_length = sizeof (long);

ord_date.dsc$a_pointer = &o_date;

ord_date.dsc$b_class = DSC$K_CLASS_S;

ord_date.dsc$b_dtype = DSC$K_DTYPE_L;

aux.dsc$w_length = sizeof (long);

aux.dsc$a_pointer = &ax;

aux.dsc$b_class = DSC$K_CLASS_S;

aux.dsc$b_dtype = DSC$K_DTYPE_L;

d_t_code.dsc$w_length = 6;

d_t_code.dsc$a_pointer = d_t_c;

d_t_code.dsc$b_class = DSC$K_CLASS_S;

d_t_code.dsc$b_dtype = DSC$K_DTYPE_T;

e_type.dsc$w_length = 4;

e_type.dsc$a_pointer = i_type;

e_type.dsc$b_class = DSC$K_CLASS_S;

e_type.dsc$b_dtype = DSC$K_DTYPE_T;

e_name.dsc$w_length = 41;

e_name.dsc$a_pointer = i_name;

e_name.dsc$b_class = DSC$K_CLASS_S;

e_name.dsc$b_dtype = DSC$K_DTYPE_T;

store_no.dsc$w_length = 4;

store_no.dsc$a_pointer = s_no;

store_no.dsc$b_class = DSC$K_CLASS_S;

store_no.dsc$b_dtype = DSC$K_DTYPE_T;

order_no.dsc$w_length = 20;

order_no.dsc$a_pointer = o_no;

order_no.dsc$b_class = DSC$K_CLASS_S;

order_no.dsc$b_dtype = DSC$K_DTYPE_T;

terms.dsc$w_length = 12;

terms.dsc$a_pointer = p_terms;

terms.dsc$b_class = DSC$K_CLASS_S;

terms.dsc$b_dtype = DSC$K_DTYPE_T;

title_no.dsc$w_length = 6;

title_no.dsc$a_pointer = t_no;

title_no.dsc$b_class = DSC$K_CLASS_S;

title_no.dsc$b_dtype = DSC$K_DTYPE_T;

HLI.dsc$w_length = strlen(tr2);

HLI.dsc$a_pointer = tr2;

HLI.dsc$b_class = DSC$K_CLASS_S;

HLI.dsc$b_dtype = DSC$K_DTYPE_T;

TRACE.dsc$w_length = strlen(tr);

TRACE.dsc$a_pointer = tr;

TRACE.dsc$b_class = DSC$K_CLASS_S;

TRACE.dsc$b_dtype = DSC$K_DTYPE_T;

C.dsc$w_length = strlen(lang);

C.dsc$a_pointer = lang;

C.dsc$b_class = DSC$K_CLASS_S;

C.dsc$b_dtype = DSC$K_DTYPE_T;

BOOKS.dsc$w_length = strlen(bks);

BOOKS.dsc$a_pointer = bks;

BOOKS.dsc$b_class = DSC$K_CLASS_S;

BOOKS.dsc$b_dtype = DSC$K_DTYPE_T;

UPDATE.dsc$w_length = strlen(upd);

UPDATE.dsc$a_pointer = upd;

UPDATE.dsc$b_class = DSC$K_CLASS_S;

UPDATE.dsc$b_dtype = DSC$K_DTYPE_T;

DI.dsc$w_length = strlen(di);

DI.dsc$a_pointer = di;

DI.dsc$b_class = DSC$K_CLASS_S;

DI.dsc$b_dtype = DSC$K_DTYPE_T;

DEMO.dsc$w_length = strlen(nis);

DEMO.dsc$a_pointer = nis;

DEMO.dsc$b_class = DSC$K_CLASS_S;

DEMO.dsc$b_dtype = DSC$K_DTYPE_T;

DEFER.dsc$w_length = strlen(def);

DEFER.dsc$a_pointer = def;

DEFER.dsc$b_class = DSC$K_CLASS_S;

DEFER.dsc$b_dtype = DSC$K_DTYPE_T;

STORE.dsc$w_length = strlen(sc);

STORE.dsc$a_pointer = sc;

STORE.dsc$b_class = DSC$K_CLASS_S;

STORE.dsc$b_dtype = DSC$K_DTYPE_T;

NUM.dsc$w_length = strlen(ord1);

NUM.dsc$a_pointer = ord1;

NUM.dsc$b_class = DSC$K_CLASS_S;

NUM.dsc$b_dtype = DSC$K_DTYPE_T;

DAT.dsc$w_length = strlen(ord2);

DAT.dsc$a_pointer = ord2;

DAT.dsc$b_class = DSC$K_CLASS_S;

DAT.dsc$b_dtype = DSC$K_DTYPE_T;

QQ.dsc$w_length = strlen(q2);

QQ.dsc$a_pointer = q2;

QQ.dsc$b_class = DSC$K_CLASS_S;

QQ.dsc$b_dtype = DSC$K_DTYPE_T;

PAY.dsc$w_length = strlen(pt);

PAY.dsc$a_pointer = pt;

PAY.dsc$b_class = DSC$K_CLASS_S;

PAY.dsc$b_dtype = DSC$K_DTYPE_T;

TITLE.dsc$w_length = strlen(tc);

TITLE.dsc$a_pointer = tc;

TITLE.dsc$b_class = DSC$K_CLASS_S;

TITLE.dsc$b_dtype = DSC$K_DTYPE_T;

GET.dsc$w_length = strlen(gt);

GET.dsc$a_pointer = gt;

GET.dsc$b_class = DSC$K_CLASS_S;

GET.dsc$b_dtype = DSC$K_DTYPE_T;

BASE.dsc$w_length = strlen(data);

BASE.dsc$a_pointer = data;

BASE.dsc$b_class = DSC$K_CLASS_S;

BASE.dsc$b_dtype = DSC$K_DTYPE_T;

ENTRY.dsc$w_length = strlen(dte);

ENTRY.dsc$a_pointer = dte;

ENTRY.dsc$b_class = DSC$K_CLASS_S;

ENTRY.dsc$b_dtype = DSC$K_DTYPE_T;

SD.dsc$w_length = strlen(sd);

SD.dsc$a_pointer = sd;

SD.dsc$b_class = DSC$K_CLASS_S;

SD.dsc$b_dtype = DSC$K_DTYPE_T;

DBM2.dsc$w_length = strlen(sales);

DBM2.dsc$a_pointer = sales;

DBM2.dsc$b_class = DSC$K_CLASS_S;

DBM2.dsc$b_dtype = DSC$K_DTYPE_T;

ENTRY_T.dsc$w_length = strlen(et);

ENTRY_T.dsc$a_pointer = et;

ENTRY_T.dsc$b_class = DSC$K_CLASS_S;

ENTRY_T.dsc$b_dtype = DSC$K_DTYPE_T;

ENTRY_N.dsc$w_length = strlen(en);

ENTRY_N.dsc$a_pointer = en;

ENTRY_N.dsc$b_class = DSC$K_CLASS_S;

ENTRY_N.dsc$b_dtype = DSC$K_DTYPE_T;

CREATE.dsc$w_length = strlen(c_time);

CREATE.dsc$a_pointer = c_time;

CREATE.dsc$b_class = DSC$K_CLASS_S;

CREATE.dsc$b_dtype = DSC$K_DTYPE_T;

MATCH.dsc$w_length = strlen(mat);

MATCH.dsc$a_pointer = mat;

MATCH.dsc$b_class = DSC$K_CLASS_S;

MATCH.dsc$b_dtype = DSC$K_DTYPE_T;

HUSH.dsc$w_length = strlen(hu);

HUSH.dsc$a_pointer = hu;

HUSH.dsc$b_class = DSC$K_CLASS_S;

HUSH.dsc$b_dtype = DSC$K_DTYPE_T;

LOCKED.dsc$w_length = strlen(lok);

LOCKED.dsc$a_pointer = lok;

LOCKED.dsc$b_class = DSC$K_CLASS_S;

LOCKED.dsc$b_dtype = DSC$K_DTYPE_T;

ALL.dsc$w_length = strlen(al);

ALL.dsc$a_pointer = al;

ALL.dsc$b_class = DSC$K_CLASS_S;

ALL.dsc$b_dtype = DSC$K_DTYPE_T;

XAU.dsc$w_length = strlen(au);

XAU.dsc$a_pointer = au;

XAU.dsc$b_class = DSC$K_CLASS_S;

XAU.dsc$b_dtype = DSC$K_DTYPE_T;

IMM.dsc$w_length = strlen(im);

IMM.dsc$a_pointer = im;

IMM.dsc$b_class = DSC$K_CLASS_S;

IMM.dsc$b_dtype = DSC$K_DTYPE_T;

BK.dsc$w_length = strlen(bk);

BK.dsc$a_pointer = bk;

BK.dsc$b_class = DSC$K_CLASS_S;

BK.dsc$b_dtype = DSC$K_DTYPE_T;

/*  HLI initialization - set trace  */

ACCINI(&err, &TRACE, &C);

ACCSTO(&err, &TRACE, &SET_0, &HLI, &SET_1);

/*  CALL #13 (ACCVER) - display ACCENT R version  */

printf("\n");

ACCVER(&err, &TRACE);

printf("\n");

printf("<<  PRESS RETURN TO CONTINUE >>");

scanf("%c", &pause);

*answer = " ";

while (code == 0 && *answer != 'x')

{/*  declare DBL  */

ACCDBL(&err, &SET_0, &BOOKS);

    if (code != 0) continue;

/*  declare Sales DI for access - data transfer is deferred until the ACCGET call

                 */

ACCOPN(&err, &UPDATE, &DI, &DEMO, &sales_ds, &UPDATE);

ACCLOA(&err, &DEFER, &sales_ds,

    &STORE, &store_no,

    &NUM, &order_no,

    &DAT, &ord_date,

    &QQ, &qty,

    &PAY, &terms,

    &TITLE, &title_no);

  if (code != 0) continue;

/*  CALL #14 (ACCGET) - Retrieve information on DBL object - Sales DS. This call

                          is used in conjunction with ACCOPN (before) and ACCLOA

                         (after). A printf is also used after this call.  */

printf("\n \n");

printf("<< SEARCHING DBL FOR SALES DS INFORMATION >> \n \n");

ACCOPN(&err, &GET, &BASE, &BOOKS, &book_dbl);

ACCGET(&err, &ENTRY, &book_dbl, &BK, &SD, &DBM2);

ACCLOA(&err, &TRACE, &book_dbl, &ENTRY_T, &e_type, &ENTRY_N, &e_name, &CREATE, &e_time);

printf("DBL OBJECT TYPE:  %s \n", i_type);

printf("DBL OBJECT NAME:  %s \n", i_name);

printf("CREATE TIME:  %ld \n \n", i_time);

printf("<<  Press RETURN  to continue.  >> \n \n");

scanf("%c", &pause);

/*  CALL #15 (ACCKWD)-set-up keyword that combines options into one descriptor;

                        this keyword is used in a ACCGET call later in the program */

ACCKWD(&err, &TRACE, &MATCH, &x_match, &HUSH, &x_hush, &LOCKED, &x_lock);

x_opt = x_match + x_hush + x_lock;

*answer = 'x';}

if (code == 0)

    while (*d_t_c != 'stop' || *d_t_c != 'STOP')

{/* Begin review, delete process...*/

printf("Enter STOP to exit application. \n");

printf("Enter title code or STOP:  ");

scanf(%s", &d_t_c);

if (*d_t_c == 'stop' || *d_t_c == 'STOP') break;

/* CALL #16 (ACCLOK) - The "LOCKED" option for ACCGET is used in place

of ACCLOK.  It was defined with MATCH and HUSH as keywords

in Call #15 above. The lock option only locks the records

being used. ACCLOK would have locked the whole Data Set.

The ACCLOK call format is shown as a comment.  */

ACCGET(&err, &x_opt,, &sales_ds, &BK, &d_t_code);

/* ACCLOK(&err, &ALL, &sales_ds);  */

ACCLOA(&err, &SET_0, &SET_0, &XAU, &aux);

    if (*ax == 'YES ' || *ax == "yes ')

{/* display order to be deleted - for verification  */

printf("\n");

printf("ORDER NUMBER:  %s \n", &o_no);

printf("STORE CODE:  %s \n", &s_no);

printf("ORDER DATE:  %s \ld", &o_date);

printf("ORDER QTY:  %s \ld", &q);

printf("PAY TERMS:  %s \n", &p_terms);

*answer = ' ';

while (*answer != 'y' && *answer != 'Y' && *answer != 'n' && *answer != 'N')

    {printf("Is this the order to delete? [Y/N] \n");

    scanf("%s", &answer);}

if (*answer == 'n' || *answer == 'N') continue;

/* CALL #17 (ACCDEL) - delete the sales record  */

ACCDEL(&err, &IMM, &sales_ds);

printf("\n");

printf("<< RECORD HAS BEEN DELETED >> \n");

q = 0, o_date = 0;

*s_no = "    "; *p_terms = "            "; *o_no = "                    ";

continue;}

printf("\n");

printf("TITLE CODE DID NOT MATCH -TRY AGAIN. \n");}

if (code != 0)

{printf("\n");

printf("***  PROGRAM FAILED DUE TO AN ERROR  *** \n");}

/* CALL #18 (ACCFRE) - release all locked records/Data Sets  */

ACCFRE(&err, &ALL, &sales_ds);

ACCCLS(&err, &ALL);

ACCEND(&err);}

===================================================================================

[End of C example 2.]

  1. Exit the insert mode.  Enter "END" or use CTRL-Z depending on the editor used.

  2. Save the program by entering "SAVE".  The editor will return control to the command level  prompt.

  3. Compile and LINK the C program through a System File (SF).  Enter commands below.

(Depending on the editor used, the command "INSERT" may need to be entered.)

*DEFINE SF HLIC_2.COM

$purge cord2.c

$delete cord2.obj;*

$delete cord2.exe;*

$define nisdemo [user_directory]

$define nis [accent_r_directory]

$define acchli nis:acchli

$cc cord2

$link cord2,nis:accvax,nis:acchli/lib

  1. Exit the insert mode.  Enter "END" or use CTRL-Z depending on the editor used.

  2. Save the command file by entering "SAVE".  The editor will return control to the command level prompt.

  3. Initiate the link then exit ACCENT R or link at the DCL command level.

*LINK TO DCL WITH '@HLIC_2' AND RETURN

*QUIT

(or)

*QUIT

$@HLIC_2

  1. Run application at the VAX DCL prompt.  (See note in section introduction.)
$RUN CORD2