Re: Help in 4GL
Posted in 1997
This is a multi-part message in MIME format. --------------51721D2D45F6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit S.Sathish wrote: > > Hi, > > While using an Input Array or a Display Array statement ,I want to perform > some task,if the user presses any key eg.,(aA-zZ|0-9).Can i do this in an > ON KEY clause?If yes then how? I do not want to use a Prompt Statement Yes. I have attached a sample function from one of my applications. The F3 key saves state and drills down to a lower level detail form, F7 calls a "C" functions that puts the current array being displayed into the users favorite editor (vi, emacs, etc), F11 calls a "C" function to print the current windows, F12 and ^W execute 4GL help functions for screen and field level. In other applications I execute a picklist function on F6 and fill the current field with the value selected (ie returned from the pick function) either leaving the user there or moving the cursor to the next field. The trick is to do as little as possible in place and make function calls to either "C" or 4GL whenever possible. Obviously, ignore applications specific stuff to avoid getting a headache. Hope that this helps. Art S. Kagel --------------51721D2D45F6 Content-Type: text/plain; charset=us-ascii; name="sample.4gl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sample.4gl" FUNCTION core_detail( is_an_edit ) DEFINE curr_line, exit_stat, OK, is_an_edit, i, slen, olen, pos INTEGER, stmt CHAR(4096), msg CHAR(70), ln, SQLError, ISAMError, nnames, redo INTEGER, ch CHAR LET redo = TRUE WHILE redo LET redo = FALSE CALL set_count( r_modified.ndetail ) INPUT ARRAY r_modified.expndstmt WITHOUT DEFAULTS -- ATTRIBUTES( REVERSE ) FROM scr_rec.* ON KEY (F3) LET curr_line = arr_curr() LET r_modified.ndetail = arr_count() LET r_modified.expndstmt[curr_line] = get_fldbuf( querystmt ) LET nnames = 0 FOR i = 1 TO r_modified.ndetail CALL compress_stmt( r_modified.expndstmt[i], nnames ) RETURNING r_modified.detail[i].querystmt, nnames LET stmt = stmt CLIPPED, " ", r_modified.detail[i].querystmt CLIPPED END FOR LET exit_stat = TRUE CALL core_detail2( is_an_edit ) ON KEY(F7) CALL extern_edit( ) LET redo = TRUE EXIT INPUT ON KEY(F11) ############## # PRINT SCREEN ############## CALL fgl_prtscr() ON KEY (F12) CALL fld_help( "query_data", "querystmt", "ENG" ) CONTINUE INPUT ON KEY (CONTROL-W) CALL scr_help( jobcntl, "DET", "ENG" ) CONTINUE INPUT ON KEY (INTERRUPT) LET exit_stat = FALSE LET int_flag = TRUE EXIT INPUT AFTER INPUT LET r_modified.ndetail = arr_count() LET stmt = "" LET nnames = 0 FOR i = 1 TO r_modified.ndetail CALL compress_stmt( r_modified.expndstmt[i], nnames ) RETURNING r_modified.detail[i].querystmt, nnames LET stmt = stmt CLIPPED, " ", r_modified.detail[i].querystmt CLIPPED END FOR PREPARE test FROM stmt LET ISAMError = sqlca.sqlerrd[2] LET pos = sqlca.sqlerrd[5] LET SQLError = sqlca.sqlcode IF SQLError = 0 THEN MESSAGE "SQL Verified!" FREE test LET exit_stat = TRUE EXIT INPUT ELSE LET msg = "Sqlcode = ", SQLError, ", ISAM Code = ", ISAMErro r CALL sql_error( msg ) LET slen = 0 LET i = 0 WHILE i < r_modified.ndetail LET i = i + 1 IF slen < pos THEN LET ln = i LET slen = slen + 1 + length( r_modified.detail[i].querystmt CLIPP ED ) END IF LET msg = " >", r_modified.detail[i].querystmt CALL errorlog( msg ) IF slen < pos THEN LET olen = slen END IF END WHILE FREE test CALL warninit() CALL warnpostop() CALL warnput( "ERROR: SQL code cannot be prepared!" ) CALL warnput( "" ) CALL warnput( "" ) LET msg = "Error on line: ", ln, ", Character: ", (pos - olen), "(", pos, ")" CALL warnput( msg ) LET msg = "SQLCode: ", SQLError CALL warnput( msg ) CALL warnbeep() CONTINUE INPUT END IF ON KEY(ESCAPE) EXIT INPUT END INPUT END WHILE LET r_modified.ndetail = arr_count() RETURN exit_stat END FUNCTION --------------51721D2D45F6--