PDA

View Full Version : BUG(?) populating a custom list from Xbasic with just one field


ABC123

compuaid
07-13-2013, 05:50 PM
What I'm trying to do is populate a list control with the file names of all files that match a specific key in the UX component. The problem I've discovered is that any attempt at using an Xbasic function that returns a comma-delimited crlf list with only one field causes the list builder to crash when moving to the Fields tab with a message "missing right parenthesis". I believe this is a bug and I've reported it to Alpha along with the test file attached. Ultimately my goal is to include all the photos from a directory in a list that have filenames that start with the key in the UX component. Some records may have one picture while others could have ten. I know I can use a linked grid for this and I've accomplished that already but I really want to move most things to UX components where possible in order to take advantage of their flexibility.

In the attached file if you open the ListTest component and then select List1, go to properties and change the source to Custom, set the xbasic function to myXBfunction and then click Fields you'll see the fields defined in that function. Now if you go back and change the function to myfiles and click fields you'll get the error message. I've also modified the myXBfunction to remove all except the lastname field and then tried this again and you get the error message since it is only one field.

Davidk
07-14-2013, 08:13 PM
Until you hear back from Alpha try faking it out by adding a dummy field.

I have to say I did have trouble getting this to work... the List control fieldlist wouldn't display anything... but eventually just got it working... not sure why it wasn't.

I changed the myfiles xbasic function code to:


function myfiles as c (e as p)
' If you set the list to custom and specify myfiles as the function
' the list builder fails when you attempt to move to the list fields
' tab with a message "Missing right paranthesis"
'debug(1)
dim values as c
dim newvalues as c
values = filefind.get("*.*",FILE_FIND_NORMAL,"PN")
newvalues = *for_each(currFile, currFile + "|xxx",values)
myfiles = "Filenames=C|DummyField=C" + crlf() + newvalues


end function

compuaid
07-14-2013, 09:28 PM
Thanks so much David and I hope the you survived the flooding okay last week. I'll throw this into my production beta and see how it goes.

Davidk
07-14-2013, 09:39 PM
No flooding here in Markham. The rains a few weeks ago were much worse here and most of the local ponds flooded the trails... but nothing downtown. Weather is so odd this year... great summer though.

compuaid
07-17-2013, 11:49 PM
This is fixed in the latest prerelease and should be in the next full release patch. Thanks Selwyn!

Garry Flanigan
08-08-2013, 03:29 AM
The code works - thanks for sharing!
I need to show a file list based on the value in a textbox that has the folder name.
Has anyone tackled this and got a solution?
A video from Selwyn (hint, hint) demonstrating how would, I am sure, be welcomed by many.

compuaid
08-08-2013, 09:18 AM
Garry,

Here's a project that contains a UX control that does what you want. The key to the control is in the custom xbasic function embedded in the list source.

The function is defined as:

function getfiles as C (e as p)
dim directorypath as c
dim filelist as c

' If there's a value in the file_directory text box retrieve the file list
if eval_valid("e.datasubmitted.file_directory")
directorypath = alltrim(e.datasubmitted.file_directory)
' Append \*.* to directory name
directorypath = directorypath + chr(92)+"*.*"
filelist = filefind.get(directorypath,FILE_FIND_NORMAL,"N")
else
'otherwise just set the list to blank
filelist = ""
end if
getfiles = "Filenames=C"+crlf()+filelist
end function

This works in the latest pre-release version of Alpha Anywhere. If you are using the original production version then you'll have to use the work-around for the single field issue above in addition to the function I've provided so that Alpha thinks there are two fields in the list.

Garry Flanigan
08-09-2013, 12:11 AM
Brad,
In my case I am opening the UX from a grid for editing and so datasubmitted is empty when getfiles is executed.
To overcome this problem I populate a session variable in the grid and use it in the UX when populating the custom list and this works:grin:
The bit I have not yet figured out is how to refresh the list when the value in file_directory changes.

Garry Flanigan
08-09-2013, 02:26 AM
Given that I want to open the selected file in the list control, what is the syntax to refer to the "Return field" when the list control is unbound as it is not then in e.datasubmitted?

compuaid
08-09-2013, 11:05 AM
In the list properties I'd use the OnSelected event to get the value of the selected file and assign it to another field on your UX component or to save it to a session variable. I've attached a couple of screen shots of the changes I made that work to assign the selected file to an unbound text box on my UX control called Selected.

364233642436425

Garry Flanigan
08-12-2013, 07:37 PM
Brad, thank you for the assistance. I will investigate further and think with your information and some other videos I came across that I can program the required functionality.