Field calculations on a form

alach@mscf.med.upenn.edu writes:
>
>   I have a problem which deals with somehow a common procedure
>   concerning forms. Most likely more than one user have worked
>   the details out.
>
>   Problem:
>   I have a form that contains a tablefield 'items' of say 5 rows and 4
>   columns displayed. Before I reach the 4th column on the row I like
>   to perform an operation on the previous columns and put
>   the result in
>   1) the fourth column:
>           items.fourth := items.first*items.second*items.third
>   2) and put the sum of the entries of all the columns of
>   different rows in another simple field on the form which is a display
>   only field.
>
>   It is possible through field activation of the third column to
>   do that, i.e., (1). However, when the cursor moves down to the next row
>   the activation is, of course, disabled. It is not convenient
>   to have a field activation for each row since there can be as many
>   rows as desired. Thus, field activation worked for the first row
>   and not for the subsequent rows.

    Column activation triggers on columns not rows, therefore, the
activation should work over all rows. Though you might need the same
activation for all 3 columns ie field 'items.third' = { code.... }.  If your
version of ingres has derived fields in Vifred then setup both table field
operation and the simple field sum using the derived field setup.  If not
set up 3 column activations to do the tablefield operation and the simple
field sum. ie.
                 field 'items.first....' =
                  {
                   simple_field = 0;
                   items.fourth = items.first*items.second*items.third;
                   unloadtable items
             {
                      simple_field = simple_field + items.fourth;
             };
                  }
This also could be set up as a call to a local procedure (version 6.4) or a
3gl procedure.

>   I thought of using
>           inquire_forms table 'formname' (h_rows = maxrow);
>   and
>           inquire_forms row 'formname' 'tablename' (h_field = change);
>   which gives the number of rows and which ones are changed
>   in a loop structure to process the rows sequentially. But the
>   field activation structure cannot be used as such.
>   Any suggestions??
>
>   Concerning the simple field my question is a simpler one:
>   How can values from the table field be displayed at a simple
>   field entry on the same form?
>
>   Thanks...
Ingres Q & A
To William's Home Page

© William Yuan 2000

Email William