Re: Word Wrap in INPUT ARRAY?
Posted in 1994
jdryburn@ingr.com (Joe Ryburn) writes: >I am storing a set of text records, 60 characters each, using >and INPUT ARRAY statement (sort of like a text editor). Is there >any way to have the 4GL program automatically go to the next line >(and break the words at the correct point), when a line is filled? >Is there any code out there to accomplish this? Inquiring minds >need to know. Following is the code I use to some satisfaction. It displays part of the long string in the array, and as you enter the field for editing it pops a window to allow WORDWRAP input. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed Senior Consultant -------------------- are mine, and do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer. ------------------------ Cut here for warray.per ---------------------- {* warray.per; screen for the INPUT ARRAY. When the user enters field f003, the window in ww.per will pop to allow array input *} DATABASE FORMONLY SCREEN { [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] [f001 |f002|f003 |n ] ============================================================================== } ATTRIBUTES f001 = FORMONLY.sdate TYPE DATE, FORMAT = "mm/dd/yy", COMMENTS = "Date of status entry"; f002 = FORMONLY.catid TYPE CHAR, UPSHIFT, COMMENTS = "Category ID"; f003 = FORMONLY.sdetl TYPE CHAR; n = FORMONLY.ne TYPE CHAR, NOENTRY; INSTRUCTIONS DELIMITERS " " SCREEN RECORD s_warray[20] (FORMONLY.sdate, FORMONLY.catid, FORMONLY.sdetl, FORMONLY.ne) END ------------------------ Cut here for ww.per ---------------------- {* ww.per; Window to INPUT in WORDWRAP mode *} DATABASE FORMONLY SCREEN { [f003 ] [f003 ] [f003 ] [f003 ] [f003 ] } ATTRIBUTES f003 = FORMONLY.sdetl TYPE CHAR, WORDWRAP COMPRESS, COMMENTS = "Full Status description"; INSTRUCTIONS DELIMITERS " " END ------------------------ Cut here for ww.4gl ---------------------- ########### # INFORMIX PROFESSIONAL SERVICES ####### # ## Denver, Colorado ###### # ### ================================================== ##### # #### File: %M% SCCS: %I% %P% #### # ##### Program: ww.4gi ### # ###### Client: Internal ## # ####### Author: Dennis J. Pimple # ########### Date: %G% %U% # Demo of using INPUT ARRAY and a WORDWRAP screen until that feature is # provided for real. If it looks kludgey, it's better than nothing. DEFINE ma_warray ARRAY[60] OF RECORD # Input array sdate DATE, catid CHAR(4), sdetl CHAR(60), # 1st 60 of 300 chars in sdetl ne CHAR(3) # NOENTRY ("..." for wrapping) END RECORD DEFINE ma_ww ARRAY[60] OF RECORD # hold entire detail record sdetl CHAR(300) END RECORD DEFINE sdetl_l SMALLINT # length ma_warray.sdetl DEFINE mstat_x SMALLINT # max array count DEFINE mstat_s SMALLINT # screen record size DEFINE mstat_t SMALLINT # tot array filled #---------------------------------------------------------------------# MAIN # Arguments: N/A # Purpose: Display screen & menu # Returns: N/A #---------------------------------------------------------------------# DEFER INTERRUPT # Set up options OPTIONS INSERT KEY CONTROL-O OPTIONS DELETE KEY CONTROL-Y OPTIONS NEXT KEY CONTROL-F OPTIONS PREVIOUS KEY CONTROL-U OPTIONS INPUT NO WRAP # initialize local variables LET sdetl_l = 60 LET mstat_x = 60 LET mstat_s = 20 OPEN FORM warray FROM "warray" DISPLAY FORM warray # for starters, set ma_warray to null CALL null_stat() # call the function to do the input CALL inp_stat() END MAIN #---------------------------------------------------------------------# FUNCTION null_stat() # Arguments: N/A # Purpose: Null ma_warray # Returns: N/A #---------------------------------------------------------------------# DEFINE arr SMALLINT FOR arr = 1 TO mstat_x INITIALIZE ma_warray[arr].* TO NULL INITIALIZE ma_ww[arr].* TO NULL IF arr <= mstat_s THEN CLEAR s_warray[arr].* END IF END FOR # mark that none are filled in LET mstat_t = 0 END FUNCTION # null_stat() #---------------------------------------------------------------------# FUNCTION inp_stat() # Arguments: N/A # Purpose: Input records ma_warray.* and update database # Returns: N/A #---------------------------------------------------------------------# DEFINE arr,scr,act SMALLINT DEFINE arrg SMALLINT DEFINE x SMALLINT DISPLAY "INPUT: ESC accepts, DEL quits", "" AT 1,1 DISPLAY "^P Ditto ^O Ins ^Y Del ^F Nxt ^U Prv ^T Top ^B Bot", "" AT 2,1 # a lot of this stuff is for NEXT ROW jumping and such. Look at the # BEFORE INSERT, AFTER DELETE, and BEFORE ROW sdetl control blocks # for the stuff that implemen