#!/bin/sh # This is a shell archive (produced by GNU shar 4.0). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1995-09-25 08:10 EDT by # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 8792 -r--r--r-- lu_cust.4gl # 499 -r--r--r-- lu_cust.per # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo 'WARNING: not restoring timestamps' fi rm -f 1231235999 $$.touch # # ============= lu_cust.4gl ============== if test -f 'lu_cust.4gl' && test X"$1" != X"-c"; then echo 'x - skipping lu_cust.4gl (File already exists)' else echo 'x - extracting lu_cust.4gl (text)' sed 's/^X//' << 'SHAR_EOF' > 'lu_cust.4gl' && X# @(#)lu_cust.4gl 1.5 13 Mar 1995 15:52:36 25 Sep 1995 08:09:17 X XDATABASE stores X X XDEFINE lu_arrcount SMALLINT XDEFINE lu_arrcurr SMALLINT XDEFINE lu_scrline SMALLINT XDEFINE p_record ARRAY[64] OF RECORD X customer_num LIKE customer.customer_num, X company LIKE customer.company X END RECORD X X X{******************************************************************************* X* This function validates a record in the customer table. * X*******************************************************************************} X XFUNCTION val_cust(validation, customer_num) XDEFINE validation CHAR(1) XDEFINE customer_num LIKE customer.customer_num X X DEFINE company LIKE customer.company X X LET company = NULL X X SELECT customer.company INTO company X FROM customer WHERE customer.customer_num = customer_num X X ### Do I ookup ### X IF validation != "L" THEN X IF sqlca.sqlcode THEN X ### Validate... o, es, lank (validate but allow blanks) ### X CASE validation X WHEN "N" X ### No validation necessary, always return SUCCESS ### X LET sqlca.sqlcode = 0 X WHEN "Y" X ### Validation is necessary, always return NOTFOUND ### X LET sqlca.sqlcode = 100 X WHEN "B" X ### Validation is necessary, except if "customer_num" is null ## X IF customer_num IS NULL THEN X LET sqlca.sqlcode = 0 X ELSE X LET sqlca.sqlcode = 100 X END IF X END CASE X END IF X END IF X X RETURN sqlca.sqlcode, company XEND FUNCTION X X X{******************************************************************************* X* This function searches through the customer table. * X*******************************************************************************} X XFUNCTION lu_cust(customer_num, company) XDEFINE customer_num LIKE customer.customer_num XDEFINE company LIKE customer.company X X DEFINE keyhit INTEGER X DEFINE scratch CHAR(512) X X OPEN WINDOW ringout_customer AT 1,1 WITH 2 ROWS, 79 COLUMNS X DISPLAY "LU-QUERY: ESCAPE queries. DELETE aborts. ARROW keys move cursor.", "" AT 1,1 ATTRIBUTE(WHITE) X DISPLAY "Searches through the customer table.", "" AT 2,1 ATTRIBUTE(WHITE) X OPEN WINDOW lu_cust AT 6, 30 WITH FORM "lu_cust" X ATTRIBUTE(BORDER, WHITE, FORM LINE FIRST + 1) X XLABEL retry: X LET int_flag = FALSE X CONSTRUCT BY NAME scratch ON customer_num, company X IF int_flag THEN X CLOSE WINDOW lu_cust X CLOSE WINDOW ringout_customer X RETURN customer_num, company X END IF X X LET scratch = "SELECT customer_num, company FROM customer WHERE ", scratch CLIPPED, " ORDER BY customer_num" X PREPARE lu_stmt FROM scratch X DECLARE lu_curs CURSOR FOR lu_stmt X X LET lu_arrcount = 1 X FOREACH lu_curs INTO p_record[lu_arrcount].* X LET lu_arrcount = lu_arrcount + 1 X END FOREACH X LET lu_arrcount = lu_arrcount - 1 X IF lu_arrcount = 0 THEN X ERROR " There are no rows satisfying the conditions " X GOTO retry X END IF X LET lu_arrcurr = 1 X LET lu_scrline = 1 X X CURRENT WINDOW IS ringout_customer X DISPLAY "LOOKUP: ESCAPE selects. DELETE aborts. ARROW keys move cursor.", "" AT 1,1 ATTRIBUTE(WHITE) X CURRENT WINDOW IS lu_cust X X CALL lu_dsppage_customer() X X OPTIONS HELP KEY CONTROL-Q X WHILE (TRUE) X LET keyhit = fgl_getkey() X CASE X WHEN keyhit = fgl_keyval("ACCEPT") OR keyhit = fgl_keyval("INTERRUPT") X EXIT WHILE X WHEN keyhit = fgl_keyval("DOWN") OR keyhit = fgl_keyval("RIGHT") X CALL lu_down_customer() X WHEN keyhit = fgl_keyval("UP") OR keyhit = fgl_keyval("LEFT") X CALL lu_up_customer() X WHEN keyhit = fgl_keyval("CONTROL-F") # NEXT KEY X CALL lu_nextpage_customer() X WHEN keyhit = fgl_keyval("CONTROL-B") # PREVIOUS KEY X CALL lu_prevpage_customer() X WHEN keyhit = fgl_keyval("CONTROL-G") X CALL fgl_prtscr() X OTHERWISE X ERROR "" X END CASE X END WHILE X OPTIONS HELP KEY CONTROL-E X X IF int_flag THEN X LET p_record[lu_arrcurr].customer_num = customer_num X LET p_record[lu_arrcurr].company = company X LET int_flag = FALSE X END IF X X CLOSE WINDOW lu_cust X CLOSE WINDOW ringout_customer X RETURN p_record[lu_arrcurr].* XEND FUNCTION X X X{******************************************************************************* X* This function moves the cursor in the lookup window down one line. * X*******************************************************************************} X XFUNCTION lu_down_customer() X IF lu_arrcurr + 1 > lu_arrcount THEN X ERROR " There are no more rows in the direction you are going " X RETURN X END IF X X CALL lu_dspline_customer("NORMAL") X LET lu_arrcurr = lu_arrcurr + 1 X X IF lu_scrline + 1 > 5 THEN X SCROLL s_record.* UP X ELSE X LET lu_scrline = lu_scrline + 1 X END IF X CALL lu_dspline_customer("REVERSE") XEND FUNCTION X X X{******************************************************************************* X* This function moves the cursor in the lookup window up one line. * X*******************************************************************************} X XFUNCTION lu_up_customer() X IF lu_arrcurr - 1 < 1 THEN X ERROR " There are no more rows in the direction you are going " X RETURN X END IF X X CALL lu_dspline_customer("NORMAL") X LET lu_arrcurr = lu_arrcurr - 1 X X IF lu_scrline - 1 < 1 THEN X SCROLL s_record.* DOWN X ELSE X LET lu_scrline = lu_scrline - 1 X END IF X CALL lu_dspline_customer("REVERSE") XEND FUNCTION X X X{******************************************************************************* X* This function moves the cursor in the lookup window down one page. * X*******************************************************************************} X XFUNCTION lu_nextpage_customer() X IF (lu_arrcurr - lu_scrline + 1) + 5 > lu_arrcount THEN X ERROR " There are no more rows in the direction you are going " X RETURN X ELSE X LET lu_arrcurr = (lu_arrcurr - lu_scrline + 1) + 5 X END IF X X CALL lu_dsppage_customer() XEND FUNCTION X X X{******************************************************************************* X* This function moves the cursor in the lookup window up one page. * X*******************************************************************************} X XFUNCTION lu_prevpage_customer() X DEFINE retval SMALLINT X X IF lu_arrcurr = 1 THEN X ERROR " There are no more rows in the direction you are going " X RETURN X ELSE X IF (lu_arrcurr - lu_scrline + 1) - 5 < 1 THEN X LET lu_arrcurr = 1 X ELSE X LET lu_arrcurr = (lu_arrcurr - lu_scrline + 1) - 5 X END IF X END IF X X CALL lu_dsppage_customer() XEND FUNCTION X X X{******************************************************************************* X* This function displays a page of data in the lookup window. * X*******************************************************************************} X XFUNCTION lu_dsppage_customer() X FOR lu_scrline = 1 TO 5 X IF lu_arrcurr <= lu_arrcount THEN X CALL lu_dspline_customer("NORMAL") X ELSE X CALL lu_dspline_customer("") X END IF X LET lu_arrcurr = lu_arrcurr + 1 X END FOR X LET lu_arrcurr = lu_arrcurr - 5 X LET lu_scrline = 1 X CALL lu_dspline_customer("REVERSE") XEND FUNCTION X X X{******************************************************************************* X* This function displays a line of data in the lookup window. * X*******************************************************************************} X XFUNCTION lu_dspline_customer(style) XDEFINE style CHAR(7) X X DEFINE lu_offset SMALLINT X X CASE X WHEN style IS NULL X DISPLAY "", "" X TO s_record[lu_scrline].customer_num, s_record[lu_scrline].company X WHEN style = "NORMAL" X DISPLAY p_record[lu_arrcurr].customer_num, p_record[lu_arrcurr].company X TO s_record[lu_scrline].customer_num, s_record[lu_scrline].company X WHEN style = "REVERSE" X DISPLAY p_record[lu_arrcurr].customer_num, p_record[lu_arrcurr].company X TO s_record[lu_scrline].customer_num, s_record[lu_scrline].company X ATTRIBUTE(REVERSE) X END CASE X X LET lu_offset = lu_scrline + 3 X DISPLAY " " AT lu_offset,1 XEND FUNCTION X X SHAR_EOF $shar_touch -am 0925080995 'lu_cust.4gl' && chmod 0444 'lu_cust.4gl' || echo 'restore of lu_cust.4gl failed' shar_count="`wc -c < 'lu_cust.4gl'`" test 8792 -eq "$shar_count" || echo "lu_cust.4gl: original size 8792, current size $shar_count" fi # ============= lu_cust.per ============== if test -f 'lu_cust.per' && test X"$1" != X"-c"; then echo 'x - skipping lu_cust.per (File already exists)' else echo 'x - extracting lu_cust.per (text)' sed 's/^X//' << 'SHAR_EOF' > 'lu_cust.per' && X-- @(#)lu_cust.per 1.5 13 Mar 1995 15:52:37 25 Sep 1995 08:09:17 X X XDATABASE stores X XSCREEN X{ X Customer # Company X ---------- -------------------- X[f000 ][f001 ] X[f000 ][f001 ] X[f000 ][f001 ] X[f000 ][f001 ] X[f000 ][f001 ] X} X XTABLES customer X XATTRIBUTES Xf000 = customer.customer_num; Xf001 = customer.company; X XINSTRUCTIONS X DELIMITERS " " X SCREEN RECORD s_record[5] (customer_num, company) SHAR_EOF $shar_touch -am 0925080995 'lu_cust.per' && chmod 0444 'lu_cust.per' || echo 'restore of lu_cust.per failed' shar_count="`wc -c < 'lu_cust.per'`" test 499 -eq "$shar_count" || echo "lu_cust.per: original size 499, current size $shar_count" fi exit 0