get and codeblock

This forum is for eXpress++ general support.
Post Reply
Message
Author
c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

get and codeblock

#1 Post by c-tec »

Hello Roger
we just have a discussion in the german newsgroup, in this sample the value in the get is only changed when not using asize(0) and the add the values new to the array. Do you have an answer for this behaviour ? Not urgent, but would be interesting, I think it has to do with the reference to the array in the getlist.
regards
Rudolf

Code: Select all

procedure xtest()
LOCAL GetList:={}, arr:={}

aadd(arr,{"Karl ","Meier  "})

@ 02,01 dcsay {||arr[1,1]} saysize 0
@ 02,10 dcget arr[1,1]  // <----- does not change the value with fhein() und fewald()

@ 03,01 dcsay {||arr[1,2]} saysize 0
@ 03,10 dcget arr[1,2]  // <----- does not change the value with fhein() und fewald()

@ 05,01 dcbrowse ob1 data arr size 50,4 fit
dcbrowsecol element 1 header "Vorname" parent ob1 width 10
dcbrowsecol element 2 header "Name"    parent ob1 width 10

@ 12,0 dcpushbutton caption "Hein" size 10,1 ;
      action {||fhein(arr,getlist)}

@ 12,10 dcpushbutton caption "Ewald" size 10,1 ;
        action {||fewald(arr,getlist)}

@ 12,20 dcpushbutton caption "Hein 2" size 10,1 ;
      action {||fhein2(arr,getlist)}

@ 12,30 dcpushbutton caption "Ewald 2" size 10,1 ;
        action {||fewald2(arr,getlist)}


DCREAD GUI FIT

RETURN

function fhein(arr,aGetlist)
asize(arr,0)
aadd(arr,{"Hein","Mück"}) // not visible in get codeblock
dc_getrefresh(aGetlist)
return .t.

function fewald(arr,aGetlist)
asize(arr,0)
aadd(arr,{"Ewald ","Saur"}) // not visible in get codeblock
dc_getrefresh(aGetlist)
return .t.


function fhein2(arr,aGetlist)
arr[1,1] := "Hein"  // this way it works works
arr[1,2] := "Mück"
dc_getrefresh(aGetlist)
return .t.

function fewald2(arr,aGetlist)
arr[1,1] := "Müller"  // works
arr[1,2] := "Franz"   // works
dc_getrefresh(aGetlist)
return .t.
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

psc
Posts: 5
Joined: Thu Sep 29, 2016 11:48 am

Re: get and codeblock

#2 Post by psc »

This might have to do with the reference to the sub-array getting clobbered ( I think ).

Try this for fhein:

Code: Select all

function fhein(arr,aGetlist)
  local aFoo
  aFoo := arr[1]
  asize( arr , 0)
  aadd( arr , aFoo )
  asize( aFoo , 0 )
  aadd(aFoo,"Hein") 
  aadd(aFoo,"Mück") 
  dc_getrefresh(aGetlist)
  return .t.
This populates the get

psc

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

Re: get and codeblock

#3 Post by rdonnay »

Psc is correct that it is a pointer problem.

You are creating a new pointer to the variable whereas the Get is bound to the previous pointer.

This is how a code block is bound to the Get:
oGet:datalink := aGetListItem[bGETLIST_VAR]


When you create a GET, a function named DC_GetAnchorCB() is used to create the code block.

Try this:
cNewValue := 'Hein'

oGet:dataLink := DC_GetAnchorCB(cNewValue)

oGet:refresh()
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: get and codeblock

#4 Post by c-tec »

Hello Roger,
thank you, I thougt that dc_getanchorCB() could help, will try it this way.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

Post Reply