Normal Topic Custom Filtering for XUserSelect (Read 3769 times)
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Custom Filtering for XUserSelect
Feb 25th, 2004 at 5:12pm
Print Post Print Post  
This routine retrieves all the requested values from an external database, then allows you run a customized search to filter out only values that match your criteria. In this example, only Company names that contain "op" are offered in the final list.

This code runs against Customers.db.
Code
Select All
// Finds all values in vVals that contain vMatch. Returns matching
// values as a semicolon separated list.
Function FilterValueList(var vVals as String, vMatch as String) as String
var vList as String
var vItem as String

	vList = ""
	While @Len(vVals) > 0
	{
		vItem = Split(vVals, ";")
		If @Instr(vItem, vMatch) > 0
		{
			If @Len(vList) > 0
			{
				vList = vList + ";"
			}
			vList = vList + vItem
		}
	}
	return(vList)
End Function


var vVals as String
var vFinalList as String
var vSearch as String

	vSearch = "op"	// Set the search string to whatever you want to match
	vFinalList = ""
	vVals = @XListValues(@FN, "Company")	// Get all the Company names
	vFinalList = FilterValueList(vVals, vSearch)
	WriteLn(@UserSelect(vFinalList))
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged