Page 1 of 1

DCGET aArray[1,1]

Posted: Wed May 11, 2016 11:08 pm
by Koverhage
Hello,

i have a Array defined:

Code: Select all

Local aMive := {{0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, ;  //   1-10
                    {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, ;  //  11-20
                    {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, ;  //  21-30
                    {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, ;  //  31-40
                    {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, ;  //  41-50
                    {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "}, {0," "} }   //  51-60

Inside a loop aMive is updated

Code: Select all

getaMive(@aMive)
DC_GetRefresh(aGetlist, nil, DCGETREFRESH_TYPE_EXCLUDE, {GETLIST_BROWSE})
aMive has the correct values (that show me the dc_arrayview in GOTFOCUS).

Code: Select all

@ 0,  0 DCTABPAGE oTabPage9 CAPTION mess1832 ;
           RELATIVE oTabPage8 ;
           TYPE XBPTABPAGE_TAB_BOTTOM ;
           HIDE {|| my_lfd = "000"  .or. my_lfd[1] = "*"} ;
           GOTFOCUS {|| dc_arrayview(aMive, NO, NO, YES, "TabPage9"), cNextFocus:='VE_I1', SetAppFocus(DC_GetObject(GetList,cNextFocus))}

           DCSETPARENT oTabPage9


    @ 2,  1 DCSAY "200 VE-I1:"
    @ 2, 11 DCGET aMive[1,1]  pict '@E 999999.999' NAME "VE_I1" ID 'VE_I1'
    @ 2, 25 DCGET aMive[1,2]  pict '!' WHEN {|| istmw()} ;
            VALID {|| aMive[1,2] $ ' GTM'} MESSAGE MSG_AUFTTXT

Why the values not shown in the DCGET ?

Re: DCGET aArray[1,1]

Posted: Thu May 12, 2016 4:09 am
by Tom
Hi, Klaus.

Code: Select all

getaMive(@aMive)
This gives a reference to the array values to the function, not the array itself. Look at "@operator" in the docs - arrays are handled different. Remove the @. Anyway, this works well:

Code: Select all

#include "dcdialog.ch"
#pragma library ("dclipx.lib")

FUNCTION Main()
LOCAL GetList := {}, aTestArray := {{1,'Test'},{2,'Another Test'}}

@ 1,1 DCSAY aTestArray[1,2] GET aTestArray[1,1] SAYSIZE 10
@ 2,1 DCSAY aTestArray[2,2] GET aTestArray[2,1] SAYSIZE 10

@ 4,1 DCPUSHBUTTON CAPTION 'Test' SIZE 5,1 ACTION {||DC_ArrayView(aTestArray)} // always the values from the SLE

DCREAD GUI FIT ADDBUTTONS

RETURN NIL

PROC AppSys() ; RETURN

Re: DCGET aArray[1,1]

Posted: Thu May 12, 2016 5:45 am
by Koverhage
Hi Tom,

your sample may work, but i changed the Local aMive to Private aMive and work without the refrence operator
and it does not work also.

The problem is, no matter how aMive is declared and accessed it does not work (aMive is not refreshed).

Code: Select all

DCADDBUTTON CAPTION BMP_FILE_OK ACCELKEY { xbeK_F12, xbeK_ALT_O} ;
        TOOLTIP "Next cutomer" ID 'OBJOK' SIZE 10, 1.0 OBJECT objok ;
        ACTION {|| iif( next_customer(1, GetList, oxlfd), Nil, DC_ReadGuiEvent( DCGUI_EXIT_OK, GetList))}

 @ 2,  1 DCSAY "200 VE-I1:"
    @ 2, 11 DCGET aMive[1,1]  pict '@E 999999.999' NAME "VE_I1" ID 'VE_I1'
    @ 2, 25 DCGET aMive[1,2]  pict '!' WHEN {|| istmw()} ;
            VALID {|| aMive[1,2] $ ' GTM'} MESSAGE MSG_AUFTTXT

DCREAD GUI OPTIONS GetOptions CLEAREVENTS TITLE"Sample" MODAL SETAPPWINDOW to lOk

static function next_customer(nRecords, aGetList, oxlfd)
saveCustomer()
customer->(dbskip(1))
IF customer->(eof())
   return .f.
Else
   getaMive()  // move data to aMive Array
   dc_getrefresh(aGetList)
Endif
return .t.

Re: DCGET aArray[1,1]

Posted: Thu May 12, 2016 5:53 am
by Tom
Hi, Klaus.

This works:

Code: Select all

#include "dcdialog.ch"
#pragma library ("dclipx.lib")

FUNCTION Main()
LOCAL GetList := {}

aTestArray := {{1,'Test'},{2,'Another Test'}}

@ 1,1 DCSAY aTestArray[1,2] GET aTestArray[1,1] SAYSIZE 10
@ 2,1 DCSAY aTestArray[2,2] GET aTestArray[2,1] SAYSIZE 10

@ 4,1 DCPUSHBUTTON CAPTION 'Test' SIZE 10,1 ACTION {||DC_ArrayView(aTestArray)}

@ 5,1 DCPUSHBUTTON CAPTION 'Test 2' SIZE 10,1 ACTION {||ChangeArray(GetList)}

DCREAD GUI FIT ADDBUTTONS

RETURN NIL

PROC ChangeArray(aGetList)
aTestArray[1,1] := 5
DC_GetRefresh(aGetList)
RETURN

PROC AppSys() ; RETURN
Maybe you add the new values to the array instead of replacing the old ones?

Re: DCGET aArray[1,1]

Posted: Thu May 12, 2016 6:37 am
by rdonnay
The problem is, no matter how aMive is declared and accessed it does not work (aMive is not refreshed).
Klaus -

It is very likely that your routine which updates aMive is creating a NEW array pointer.

Instead of assigning a new array, you must change the values in the existing array.

Re: DCGET aArray[1,1]

Posted: Thu May 12, 2016 10:40 pm
by Koverhage
Roger,

i treid this also with a private array as you suggested, but this does noot work too.

Tom,

i modified you sample to my way and it work, but my code not.
#include "dcdialog.ch"
#include "appevent.ch"
#pragma library ("dclipx.lib")

FUNCTION Main()
LOCAL GetList := {}
Local lOk := .F.
Local oTabPage1

Local aTestArray := {{1,'Test'},{2,'Another Test'}}
Private nCounter := 5

@ 4.2, 0 DCTABPAGE oTabPage1 CAPTION "TEST" ;
SIZE 40, 6 PREOFFSET 0 POSTOFFSET 90 ;
TYPE XBPTABPAGE_TAB_BOTTOM

DCSETPARENT TO oTabPage1


@ 1,1 DCSAY aTestArray[1,2]
@ 1,20 DCGET aTestArray[1,1]
@ 2,1 DCSAY aTestArray[2,2]
@ 2,20 DCGET aTestArray[2,1]

DCSETPARENT TO

@ 11,1 DCPUSHBUTTON CAPTION 'Test' SIZE 10,1 ACTION {||DC_ArrayView(aTestArray)}
@ 12,1 DCPUSHBUTTON CAPTION "OK" SIZE 10,1 ACCELKEY { xbeK_F12, xbeK_ALT_O} TOOLTIP "Next cutomer" ;
ACTION {|| iif( ChangeArray(GetList, @aTestArray), Nil, DC_ReadGuiEvent( DCGUI_EXIT_OK, GetList))}

DCREAD GUI FIT CLEAREVENTS TITLE"Sample" MODAL SETAPPWINDOW to lOk

RETURN NIL

FUNC ChangeArray(aGetList, aTestArray)
aTestArray[1,1] := nCounter
DC_GetRefresh(aGetList)
nCounter++
IF nCounter > 15
return .f.
ENDIF
RETURN .t.

PROC AppSys() ; RETURN

Result: I do it the old way with DCGET customer->feld01 and so on.

Re: DCGET aArray[1,1]

Posted: Fri May 13, 2016 12:38 am
by Tom
Hi, Klaus.

If you do something like this:

Code: Select all

aArray := UpdateArray(aArray)

FUNCTION UpdateArray(a)
aSize(a,0)
aAdd(a,<aValues>)
RETURN a
You create a new pointer to the array, but the old one inside your dialog is not updated. This is what Roger means. You may not do exactly this, but somehow.

Re: DCGET aArray[1,1]

Posted: Fri May 13, 2016 2:31 am
by Koverhage
Hi Tom and Roger,

thanks.

Re: DCGET aArray[1,1]

Posted: Fri May 13, 2016 6:48 am
by rdonnay
Your sample is working as expected. Each time the OK button is pressed, the Get updates with a new value.

What are you expecting?

Re: DCGET aArray[1,1]

Posted: Fri May 13, 2016 9:17 am
by Koverhage
Roger,

if i can do, i make a sample.