Codeblocks and getlist

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:

Codeblocks and getlist

#1 Post by c-tec »

Hello,
for creating pushbuttons in a for next loop I need the getlist as parameter. I tried this with detached locals, works, but the getlist is always a empty array. How can I get the getlist in myfunction
regards
Rudolf


Code: Select all


for x := 1 to 10
     @ x,1 DCPUSHBUTTONXP caption ntrim(x) SIZE 10,10 ACTION makeblock(getlist,x)  // test 1
     @ x,1 DCPUSHBUTTONXP caption ntrim(x) SIZE 10,10 ACTION &("{||myfunction(getlist," + ntrim(x) + ")}) // test 2
...



function makeblock(getlist,x)
******************************************************************
local cBlock := "myfunction(getlist," + ntrim(x) + ")"
return &("{||" + cBlock + "}")


function myfunction(aGetlist,x)
******************************************************************

*/
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

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

Re: Codeblocks and getlist

#2 Post by c-tec »

Hello,
problem solved, found a workaround
regards
Rudolf

Code: Select all

ACTION &("{|a,b,o|changecaption('" + "__" + FT_NAME  +  "',a,b,o)}")  

function changecaption(cID,a,b,o)
******************************************************************
local aGetlist := o:getlist:getlistarray
...
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

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

Re: Codeblocks and getlist

#3 Post by rdonnay »

Rudolf -

The GetList should NOT be an empty array, unless you are using the EXIT clause of DCREAD GUI without using the SAVE clause.

Roger
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: Codeblocks and getlist

#4 Post by c-tec »

Hello Roger,
both samples are leading to an empty getlist array, I think it has todo with detached locals, but how to pass it correct to the codeblock.
regards
Rudolf

Code: Select all

#include "dcdialog.ch"
// ---------------------------------------------------------------------------
proc dbesys ; return
// ---------------------------------------------------------------------------
proc main()
local getlist := {}
for x := 1 to 10
     *@ x,1 DCPUSHBUTTONXP caption ntrim(x) SIZE 20,1 ACTION makeblock(getlist,x)  // test 1
     @ x,1 DCPUSHBUTTON caption ntrim(x) SIZE 10,1 ACTION &("{||myfunction(getlist," + ntrim(x) + ")}") // test 2
next x
dcread gui fit
return .t.



function makeblock(getlist,x)
******************************************************************
local cBlock := "myfunction(getlist," + ntrim(x) + ")"
return &("{||" + cBlock + "}")


function myfunction(aGetlist,x)
******************************************************************
dc_arrayview(aGetlist)
return

function ntrim(x)
return str(x,0)
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

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

Re: Codeblocks and getlist

#5 Post by rdonnay »

You need to use code blocks to create detached locals. Don't try to do this with a macro.

Run this code:

Code: Select all

#include "dcdialog.ch"
// ---------------------------------------------------------------------------
proc dbesys ; return
// ---------------------------------------------------------------------------
Function main()

local getlist := {}, x

for x := 1 to 10
   @ x,1 DCPUSHBUTTONXP caption Alltrim(Str(x)) SIZE 20,1 ACTION makeblock(getlist,x)  // test 1
next x

dcread gui fit

return .t.

* ----------

function makeblock(getlist,x)
return {||MyFunction(GetList,x)}

* ----------

function myfunction(aGetlist,x)
MsgBox( 'You pushed button ' + Alltrim(Str(x)))
dc_arrayview(aGetlist)
return
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: Codeblocks and getlist

#6 Post by c-tec »

Hello Roger,
thank you ! works now.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

Post Reply