Pop window for 4gl modules
Posted in 1995
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
A few weeks ago, my partner, A.Ergul, posted a mail about the pop window code that we use in our modules. Here is the code of this function which may be useful for your codes. An explanation for the use of this function is given as a remark lines ... { ------------------------------------------------------------------------------- WE HEREBY PUT THIS CODE IN PUBLIC DOMAIN. YOU CAN DO WHATEVER YOU LIKE WITH IT. HOWEVER, WE WOULD BE GLAD IF YOU MENTION MIDDLE EAST TECHNICAL UNIVERSITY (METU) , O.OZTAN & A.ERGUL AS THE ORIGINATORS OF THIS CODE . QUESTIONS TO : omer@rorqual.cc.metu.edu.tr ------------------------------------------------------------------------------- EXPLANATIONS FOR THE USE OF FUNCTION L_POP??(.....) 1. First of all , an array named 'PopUpArray' must be defined in a global file, or in your module (if you put this code in your module directly). DEFINE PopUpArray Array[150] of char(60) --Used by the corresponding L_Pop..() functions. (size of PopUpArray can be changed by the programmer) 2. In your 4gl module, fetch the rows from the related table via cursor to the programme array (in the example the array used is 'P_PopTranscript'). Then assign the values of P_PopTranscript THAT IS DESIRED TO DISPLAY ON THE POPUP WINDOW to the P_PopUpArray. Since the type of P_PopTranscript is character, one can use any extra character during assignment. After calling a function 'L_Pop20(.....)', the index of 'P_PopTranscript' is stored to the variable 'choice'. After this, do whatever you like .... SAMPLE CODE SHOWING THE USE OF FUNCTION L_POP() : --------------------------------------------------------------------------- DEFINE icount,choice SMALLINT DEFINE splSql CHAR(100) DEFINE P_PopTranscript ARRAY[100] OF RECORD orderNo LIKE Transcript.orderNo, student LIKE Transcript.student END RECORD, LET splSql = "EXECUTE PROCEDURE GetOrders('", P_Transcript.whom CLIPPED , "')" CLIPPED PREPARE getOrdersStm FROM splSql DECLARE getOrdersCur CURSOR FOR getOrdersStm FOREACH getOrdersCur INTO P_PopTranscript[icount].* LET PopUpArray[icount]= P_PopTranscript[icount].orderNo USING "######", " ", P_PopTranscript[icount].student USING "#######" LET icount = icount + 1 END FOREACH CALL SET_COUNT(icount-1) IF icount = 1 THEN ERROR " No Records Found " RETURN END IF CALL L_Pop20(5,5,1,"OrderNo StudentId") RETURNING choice DISPLAY "The id number selected is ", P_PopTranscript[choice].student AT 5,5 --------------------------------------------------------------------------- 2. Functions L_Pop20(..),L_Pop40(..), and L_Pop60(..) call the function L_Pop(..). The only differences of these 3 functions are the size of the pop-up window to be displayed. You can go up and down with the cursor-up, cursor-down keys and control-key combinations (look at the help window to see the key combinations). You can also press any key (except RETURN) which matches with the first letter of the element of the array of PopUpArray. } DEFINE PopUpArray Array[150] of char(60) MAIN END MAIN #-----------------------------------------------------------------------------# # Function L_Pop20() Calls the function L_Pop with a column width of 20 # # # # Parameters : irow,icolumn : Corner coordinates of the window # # choice : Index of the array to be displayed to the # # first line of the pop window # # msgString : Header of the pop window # # # # Returns : returnValue # # # #-----------------------------------------------------------------------------# FUNCTION L_Pop20(irow,icolumn,choice,msgStr) DEFINE irow,icolumn,choice,columnWidth,returnValue SMALLINT DEFINE msgStr CHAR(20) LET returnValue = L_Pop(irow,icolumn,choice,msgStr,20) RETURN returnValue END FUNCTION -- L_Pop20() #-----------------------------------------------------------------------------# # Function L_Pop40() Calls the functiion L_Pop with a columnwidth of 40 # # # # Parameters : irow,icolumn : Corner coordinates of the window # # choice : Index of the array to be displayed to the # # first line of the pop window # # msgString : Header of the pop window # # # # Returns : returnValue # # # #-----------------------------------------------------------------------------# FUNCTION L_Pop40(irow,icolumn,choice,msgStr) DEFINE irow,icolumn,choice,columnWidth,returnValue SMALLINT DEFINE msgStr CHAR(40) LET returnValue = L_Pop(irow,icolumn,choice,msgStr,40) RETURN returnValue END FUNCTION -- L_Pop40() #-----------------------------------------------------------------------------# # Function L_Pop60() Calls the functiion L_Pop with a columnwidth of 60 # # # # Parameters : irow,icolumn : Corner coordinates of the window # # choice : Index of the array to be displayed to the # # first line of the pop window # # msgString : Header of the pop window # # # # Returns : returnValue # # # #-----------------------------------------------------------------------------# FUNCTION L_Pop60(irow,icolumn,choice,msgStr) DEFINE irow,icolumn,choice,columnWidth,returnValue SMALLINT DEFINE msgStr CHAR(60) LET returnValue = L_Pop(irow,icolumn,choice,msgStr,60) RETURN returnValue END FUNCTION -- L_Pop60() #-----------------------------------------------------------------------------# # Function L_Pop() Displays a pop window & returns the selected row # # # # Parameters : irow,icolumn : Corner coordinates of the window # #