Page 1 of 1

Retrieve value of DCGET object in called function

Posted: Fri Apr 21, 2017 5:45 pm
by Cliff Wiernik
I have a DCGET xvariable setup in a dialog. Sometimes it might be a DCGET bBlock construct. One of the processes on the dialog calls a function that needs access to the xvariable or the value represented by the result of the bBlock codeblock.

Is there a way, if you have access to the Getlist and know the GETID value, to retrieve the actual value of DCGET without passing the individual variables or bBlock values. The function does many things and different variable needs may appear from time to time. I don't want to continue to pass additional variables as I already am passing the getlist.

Plus it would be nice if the returned value was in the actual type of the getvalue variable or bBlock result.

Re: Retrieve value of DCGET object in called function

Posted: Sat Apr 22, 2017 7:34 am
by rdonnay

Code: Select all

cID := 'MYFIRSTGET'

nElement := AScan(GetList,{|a|a[cGETLIST_ID]==cID})

bVar := GetList[nElement,bGETLIST_VAR]

xValue := Eval(bVar)

Re: Retrieve value of DCGET object in called function

Posted: Sat Apr 22, 2017 9:05 am
by Cliff Wiernik
Thanks.

Re: Retrieve value of DCGET object in called function

Posted: Tue Apr 25, 2017 11:02 am
by Cliff Wiernik
Roger, is this equivalent to your sample.

Code: Select all

DC_GetObject(aMainGetlist,'TOTACHAMT1'):getdata() pause

Re: Retrieve value of DCGET object in called function

Posted: Tue Apr 25, 2017 11:48 am
by rdonnay
Yes, it is equivalent to the other lines of code.
There are a lot of ways to get that info.
I thought that my sample would give you a little more understanding of the structure of the GetList.

Your method is probably the best one.

Re: Retrieve value of DCGET object in called function

Posted: Tue Apr 25, 2017 12:18 pm
by Cliff Wiernik
Yes, your sample provided valuable insight into the use for myself and others on the webboard.