# Thread: Owner Draw Listbox - Computed Display coding problem

1. ## Owner Draw Listbox - Computed Display coding problem

copied this code from the documentation, but it has an error and I dont know what it is, can anyone help me please?
dim arr[0] as p
arr[].fname = "Sam"
arr[..].lname = "Raven"
arr[].fname = "Charles"
arr[..].lname = "Chambliss"
arr[].fname = "Dion"
arr[..].lname = "Smits"

index = 1
dim fmt as c = ".fname"
ui_dlg_box("Owner Draw Listbox - Computed Display",<<%dlg%
{wrap=40}
{repaint_begin=fmt}
Select the property to display:;
[.10fmt^={.fname,.lname}];
[%O==eval(value+fmt)%.50,5index^#arr];
Listbox can show an expression showing a calculation involving properties in the array:;
[%O==eval(value+".fname+' '+" + value + ".lname" )%.50,5index^#arr];
A more complex expression:;
[%O==eval("upper(" + value+".fname)+' '+" + value + ".lname" )%.50,5index^#arr];
You can call a UDF to compute the data to display:;
\(This is the most flexible option.);
[%O==testFNvalue?%.50,5index^#arr];
{repaint_end}

%dlg%)

'value is a placeholder for 'arr'. eval(value) passes in the the current row in the array to the function.

function testFN as c (ar as p)
testFN = upper(ar.lname) + ", " + f_upper(ar.fname)
if ar.lname = "chambliss" then
testFN = "{I:'\$\$generic.orb.green.small'} " + testFN
else
testFN = "{I:'\$\$generic.orb.blue.small'} " + testFN
end if

end function
the line
[%O==testFNvalue?%.50,5index^#arr]

doesnt work for some reason, although it is coded as stated in the documentation example.

The original document is available at http://wiki.alphasoftware.com/Xdialog+ListBoxes+Dynamically+Computing+the+Display+Expression+V10

2. ## Re: Owner Draw Listbox - Computed Display coding problem

you need to put in the '.' before value

[%O==testFN.value?%.50,5index^#arr]

3. ## Re: Owner Draw Listbox - Computed Display coding problem

Nope, that doesn't work either

4. ## Re: Owner Draw Listbox - Computed Display coding problem

That's odd. I copied your script and that is all I changed to get the xdialog to display.

5. ## Re: Owner Draw Listbox - Computed Display coding problem

Code:
```You can call a UDF to compute the data to display:;
\(This is the most flexible option.);
[%O==testFN(eval(value))%.50,5index^#arr];
{repaint_end}

%dlg%)

'value is a placeholder for 'arr'. eval(value) passes in the the current row in the array to the function.```
This, [%O==testFN(eval(value))%.50,5index^#arr]; is working at here

6. ## Re: Owner Draw Listbox - Computed Display coding problem

thanks John.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•