Difference between revisions of "ABROWSE()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 42: Line 42:
 
====UDF Return Values====
 
====UDF Return Values====
 
The UDF must return one of the following values:
 
The UDF must return one of the following values:
 
  
 
{| class="wikitable"
 
{| class="wikitable"

Revision as of 12:03, 24 March 2009

Class

Array Processing


Purpose

Function to browse a two-dimensional array in a spreadsheet style format


Syntax

ABROWSE(<expN1>, <expN2>, <expN3>, <expN4>, <expC1> [,<expC2>] [,<expC3>] [,<expC4>]


See Also

AADD(), AAVERAGE(), ACHOICE(), ACOL(), ACOPY(), ADEL(), ADESC(), ADIR(), AELEMENT(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, AROW(), ASCAN(), ASIZE(), ASORT(), ASTORE(), ASTRING(), ASUBSCRIPT(), ASUM(), COPY TO ARRAY, DBEDIT(), DECLARE, DIMENSION, GATHER, LOCAL, PRIVATE, PUBLIC, RELEASE, RESTORE, SAVE, SCATTER


Description

The ABROWSE() function browses a two dimensional array in a spreadsheet style format. This function is particularly useful with arrays that have been FETCHED or LOADED from SQL tables from a remote server.

The coordinates of the spreadsheet are defined with expressions <expN1> and <expN2>, which represent starting and ending row and column numbers respectively. The expression <expC1> is the name of the two dimensional array to be browsed. By default, only the [ABANDON] and [EXIT SAVE] keys and the cursor navigation keys are active within ABROWSE(). The cursor navigation keys are [CURSOR LEFT], [CURSOR RIGHT], [CURSOR UP], [CURSOR DOWN], [PAGE UP] and [PAGE DOWN]. The optional expression <expC2> is the name of a User Defined Function (UDF) to handle any other keystrokes. Note: if a UDF is specified, it will also trap the [ABANDON] and [EXIT SAVE] keys, so provision should be made to allow exit from the ABROWSE().

The AROW() and ACOL() functions return array row and column coordinates for use inside the UDF. When not used as part of a UDF, the AROW() and ACOL() functions can provide coordinates to edit the array. Two parameters are passed to the UDF: the current ABROWSE() status (see the table below) and the current column number starting from column 1.

UDF Parameters

Status Description
0 ABROWSE() is idle, no keystrokes are pending.
1 An attempt was made to move beyond the top of the array.
2 An attempt was made to move beyond the bottom of the array.
3 The array is empty.
4 A key other than a cursor navigation key was pressed. The LASTKEY() function can be used to check the key pressed.


UDF Return Values

The UDF must return one of the following values:

Value Description
0 Quit ABROWSE().
1 Continue ABROWSE().
2 Reread data, repaint the screen and continue.


The ABROWSE() function handles picture formatting for each column in the spreadsheet with an array represented by the optional expression <expC3>. Each value in array <expC3> should contain a picture formatting expression that corresponds to a column in array <expC1>. Column headings may be optionally specified for the spreadsheet by using an array specified with <expC4>. Each value in array <expC4> should contain a column heading that corresponds to a column in array <expC1>.


Example

function ab_udf
parameters ab_status, ab_col
do case
case ab_status = 0
    ab_action = 1
case ab_status = 1
    @0,0 clear to 0,79 
    @0,0 say "Attempt to move past the top of file."
    ab_action = 1
case ab_status = 2 
    @0,0 clear to 0,79 
    @0,0 say "Attempt to move past the end of file."
    ab_action = 1 
case ab_status = 3 
    && array is empty 
    ab_action = 0 
case ab_status = 4 
    do case 
    case lastkey() = 27
        ab_action = 0
    case lastkey() = 13
        @0,0 clear to 0,79
        m_get = ora_rows[arow(), acol()]
        @0,0 get m_get
        ora_rows[arow(), acol()] = m_get
        ab_action = 2
    otherwise
        @0,0 clear to 0,79 
        @0,0 say "ASCII of key pressed is str(lastkey(),3)"
        ab_action = 1
    endcase 
otherwise 
    ab_action = 1
endcase 
return ab_action
 
exec sql
 declare employees read only cursor for
  select * from emp;
exec sql
 open employees;
exec sql
 fetch employees into array ora_rows, ora_headings;
exec sql
 close employees;
exec sql
 drop cursor employees;
clear
set pckeys on
abrowse(1,1,23,78,ora_rows,"ab_udf",,ora_headings)


Products

Recital Terminal Developer