Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Understanding the AUTO APPEND attribute  (Read 9006 times)
Sundar K.
Posts: 17


« on: February 23, 2010, 07:56:19 pm »

According to the documentation (2.11), the AUTO APPEND attribute in INPUT ARRAY is supposed to prevent the creation of temporary rows.  I am getting no different behavior whether the attribute is TRUE or FALSE.
Form:
LAYOUT
VBOX
TABLE
{
 [F1      |F2      ]
 [F1      |F2      ]
}
END -- TABLE
END -- VBOX
END -- LAYOUT
ATTRIBUTES
EDIT F1 = FORMONLY.cfield1, TITLE="Field1";
EDIT F2 = FORMONLY.cfield2, TITLE="Field2";
INSTRUCTIONS
screen record s_list (FORMONLY.cfield1,FORMONLY.cfield2)


Application:
DEFINE p_list DYNAMIC ARRAY OF RECORD
        field1 CHAR( 8 ),
        field2 CHAR( 8 )
END RECORD
MAIN
        DEFINE nArrCount,iArrCurr SMALLINT
        CLOSE WINDOW SCREEN
        OPEN WINDOW w_test AT 1,1 WITH FORM "test"
                attributes(TEXT="Test program")
        CALL p_list.appendelement()
        LET p_list[p_list.getLength()].field1 = "John"
        LET p_list[p_list.getLength()].field2 = "Smith"
        CALL p_list.appendelement()
        LET p_list[p_list.getLength()].field1 = "Jane"
        LET p_list[p_list.getLength()].field2 = "Jones"
        INPUT ARRAY p_list WITHOUT DEFAULTS FROM s_list.* ATTRIBUTE(UNBUFFERED, AUTO APPEND=FALSE)
                BEFORE ROW
                        DISPLAY "BEFORE ROW:    Row ",arr_curr()," of ",p_list.getLength()
                BEFORE INSERT
                        DISPLAY "BEFORE INSERT: Row ",arr_curr()," of ",p_list.getLength()
                AFTER INSERT
                        DISPLAY "AFTER INSERT:  Row ",arr_curr()," of ",p_list.getLength()
                AFTER ROW
                        DISPLAY "AFTER ROW:     Row ",arr_curr()," of ",p_list.getLength()
        END INPUT
        CLOSE WINDOW w_test
END MAIN


The output is always:
  Launch application: BEFORE ROW:    Row           1 of           2
  Click on row 2:     AFTER ROW:     Row           1 of           2
                             BEFORE ROW:    Row           2 of           2
  Click 'Delete':       AFTER ROW:     Row           2 of           1
                             BEFORE ROW:    Row           2 of           2
                             BEFORE INSERT: Row           2 of           2
And a new row is added.


Bernard M.
Four Js
Posts: 45


« Reply #1 on: February 24, 2010, 10:08:28 am »

The AUTO APPEND attribute is not working as expected in the 2.11 version. But from 2.20.05 on, running your code with AUTO APPEND=FALSE gives:

BEFORE ROW:    Row           1 of           2
AFTER ROW:     Row           1 of           2
BEFORE ROW:    Row           2 of           2
AFTER ROW:     Row           2 of           1
BEFORE ROW:    Row           1 of           1

This was fixed by the fix to bug #10466.

Regards,
Bernard
Sebastien F.
Four Js
Posts: 512


« Reply #2 on: February 24, 2010, 05:53:15 pm »

Thomas,

Can I suggest you to migrate to 2.21 (2.21.02 is available on download site)?

Version 2.11 gets old now and we will not do any improvement in that version, only blocking/critical bug fixes...

Seb
Sundar K.
Posts: 17


« Reply #3 on: February 24, 2010, 07:41:24 pm »

For now I use this workaround:
        AFTER DELETE
            LET nArrCount=p_list.getLength()
            LET iArrCurr=arr_curr()
            IF p_list[iArrCurr].field1 IS NULL THEN
                CALL fgl_set_arr_curr(iArrCurr-1)
            END IF
Sebastien F.
Four Js
Posts: 512


« Reply #4 on: February 25, 2010, 10:00:09 am »

For now I use this workaround:
        AFTER DELETE
            LET nArrCount=p_list.getLength()
            LET iArrCurr=arr_curr()
            IF p_list[iArrCurr].field1 IS NULL THEN
                CALL fgl_set_arr_curr(iArrCurr-1)
            END IF


Thomas,

Avoiding such workarounds is exactly the reason why we have introduced new dialog attributes like AUTO APPEND...
This is especially important when you want to have a common behavior for all of your dialogs.
(will you implement this workaround in all you INPUT ARRAYs?)

Remarks:

1) With this code you don't prevent the user to create temporary rows with the down key or the mouse.
2) You must check all field values (and normally, the 'touched' flag too).
3) I believe you are missing to check that you are on the last row (iArrCurr == nArrCount)?
Create two new rows with empty values, go to the top most row with no values, delete, since next row replaces current row but has null values, you enter the if and jump to previous row. This should solved the problem:
   IF iArrCurr==nArrCount AND p_list[iArrCurr].field1 IS NULL THEN

Anyway, could you explain what you want to achieve exactly?

Yes 2.11 has a bug, AUTO APPEND is not working as expected => Upgrade to recent version please.

Seb
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines