To use Display Array or not ?
Posted in 1992
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Sept 18 92 Hi All, Seen all the mail about screen arrays and remembered this function. This function didnt need the input array, and I'm I ever glad that it did not. Input Array is not my favorite Informix call. But Display Array has limits also this got around them it uses two screen arrays but could just be one. It is almost worth using it just because of Scroll to top or Scroll to bottom. It is also fast. By the way if you can set the current row in An Input Array why not give us the code so we can to. Anything can be done if the time is available. Use this at your own risks I cant be sure I did not mess it up in editing for mailing so check it out well if intend to use. Happy 4GLing Jerry Jugovich # This function allows two windows to be open with screen arrays # # in each of the windows. AND the capibility of switching between # # windows and not having the screen array reseting to the top of # # the array upon returning to first window. Also top or bottom of # # array scrolling is provided. Uses PF1, PF2, PF3, PF4 # # It aint pretty but it works. # # Background I needed a function that would have two sets of data # # that needed to be displayed and scrollable ie array of 200 rows # # also the user would select rows from each window for processing # # Tried to use display array this will work but upon switching # # windows The array would redisplay at the top and then user would # # have to rescroll and the select item again This was acceptable NOT # # so here is what I came up with the Jer Array # # Limits: screen array size is hardcoded # # By the way screen must be set to 132 columns figure that one out # # I did what I mean is this program is called from a screen that is # # set at 80 columns curses was initialized at 80 columns at start. # # The reason is each window is 50 charecters wide # # This code segment written by Jerry Jugovich Nov 91 # # Version of Online was 4.0 # # # function fld_dc_prt() initialize cdb_arr to null # Array one # let s1 = " select item_no, mod_no, hw_desc, devid, sn, cov_code ", " from hw_cdb where lan = ? and wa_nu = ? and br_nu = ? ", " order by item_no " prepare s_1 from s1 declare cdb_cur scroll cursor with hold for s_1 initialize loc_Arr to null # Array two # let s1 = " select li_item, md_nu, eq_des, devid, sn, pmt, row_id ", " from model, eqp_1408 ", " where lan = ? and wa_nu = ? and region = ? ", " and mod_no = md_nu and pmt != \\"Q\\" ", " and li_item is null ", " order by li_item, md_nu, sn " prepare s_2 from s1 declare loc_cur cursor with hold for s_2 let cdb_idx = 1 let cdb_scr = 1 let cdb_tot = 0 open cdb_cur using p_lan, p_wa, p_br # cursor for Array one # foreach cdb_cur into cdb_arr[cdb_tot].* let cdb_tot = cdb_tot + 1 end foreach let loc_idx = 1 let loc_scr = 1 let loc_tot = 0 open loc_cur using p_lan, p_wa, p_br # cursor for Array two # foreach loc_cur into loc_arr[loc_tot].*, row_arr[loc_tot].loc_id let loc_tot = loc_tot + 1 end foreach # window one border # open window s_trn at 2,3 with 22 rows,61 columns attribute ( green, border, message line last, prompt line last, form line first ) # window one array # open window s_trn1 at 2,3 with form "cdb_hw" attribute ( white, message line last ,prompt line last, form line first ) display " Corporate Info " at 1,45 attribute ( red, reverse ) display "CTR-F = File Discp Report" at 2,37 attribute ( green, reverse ) let cdb_idx = 1 let cdb_scr = 1 # Fill Screen one array # while cdb_idx < 8 display cdb_arr[cdb_idx].* to cdb_frm[cdb_scr].* attribute ( white ) let cdb_idx = cdb_idx + 1 let cdb_scr = cdb_scr + 1 if cdb_idx > cdb_tot then exit while end if end while let cdb_idx = 1 let cdb_scr = 1 display cdb_arr[1].* to cdb_frm[1].* attribute ( white ) display cdb_arr[1].a_li to cdb_frm[1].item_no attribute( white, reverse) # window two border # open window s_trn2 at 2,68 with 22 rows,61 columns attribute ( green, border, message line last, prompt line last ) message "Arrows move up and down. PF3 to Scroll down.PF4 to Scroll up" attribute ( green, reverse ) options message line last - 1 message "CTR-G =Select CDB info.CTR-U =Update.CTR-C =Quit.CTR-W =help" attribute ( green, reverse ) # window two array # open window s_trn3 at 2,68 with form "cdb_hw" attribute ( white, message line last - 1, prompt line last, form line first ) options message line last display " Local Info " at 1,45 attribute ( red, reverse ) display "CTR-F = File Discp Report" at 2,37 attribute ( green, reverse ) let loc_idx = 1 let loc_scr = 1 while loc_idx < 8 display loc_arr[loc_idx].* to cdb_frm[loc_scr].* attribute ( white ) let loc_idx = loc_idx + 1 let loc_scr = loc_scr + 1 if loc_idx > loc_tot then exit while end if end while let loc_idx = 1 let loc_scr = 1 display loc_arr[1].* to cdb_frm[1].* attribute ( white ) display loc_arr[1].a_li to cdb_frm[1].item_no attribute( white,reverse) options input wrap input g from g # this used to get keyboard input # after field g let k_val = 0 call get_key() returning k_val # returns int value of key # # this is the c function # # /* get_key.c */ # # extern short eflastkey; # int # get_key(nargs) #