This forum is for eXpress++ general support.
c-tec
Posts: 379 Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:
#1
Post
by c-tec » Wed Feb 04, 2015 6:51 am
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)
******************************************************************
*/
c-tec
Posts: 379 Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:
#2
Post
by c-tec » Wed Feb 04, 2015 7:49 am
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
...
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#3
Post
by rdonnay » Wed Feb 04, 2015 8:39 am
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:
#4
Post
by c-tec » Fri Feb 06, 2015 10:26 pm
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)
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#5
Post
by rdonnay » Sat Feb 07, 2015 1:33 pm
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:
#6
Post
by c-tec » Sun Feb 08, 2015 3:44 am
Hello Roger,
thank you ! works now.
regards
Rudolf