DCGET aArray[1,1]

This forum is for eXpress++ general support.
Post Reply
Message
Author
Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

DCGET aArray[1,1]

#1 Post 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 ?
Klaus

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCGET aArray[1,1]

#2 Post 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
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: DCGET aArray[1,1]

#3 Post 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.
Klaus

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCGET aArray[1,1]

#4 Post 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?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCGET aArray[1,1]

#5 Post 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.
The eXpress train is coming - and it has more cars.

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: DCGET aArray[1,1]

#6 Post 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.
Klaus

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCGET aArray[1,1]

#7 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: DCGET aArray[1,1]

#8 Post by Koverhage »

Hi Tom and Roger,

thanks.
Klaus

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCGET aArray[1,1]

#9 Post 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?
The eXpress train is coming - and it has more cars.

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: DCGET aArray[1,1]

#10 Post by Koverhage »

Roger,

if i can do, i make a sample.
Klaus

Post Reply