Normal Topic @XLookupSourceListall Sorting (Read 732 times)
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
@XLookupSourceListall Sorting
Jun 5th, 2006 at 2:32am
Print Post Print Post  
Why does this first code sort the picklist and the second doesn't.  (The first is on a form called Fitness; the second is on the Profile form)

Correct One: From a command button on a form called "Fitness"; this displays the 3 elements in sorted by last name in a picklist

Code
Select All
var MyStr as String
var VLName as String
var vinfo as string

Throwfocus(Last Name)

MyStr = @XLookupSourceListall(@fn, "..", "Profile!Last Name", "Last Name;First  Name;Key Number5")

MyStr = @replace(MyStr, ";", " " + @chr(149) + " ")

MyStr = @replace(MyStr, @Chr(10), ";")

//WriteLN(MyStr)

vLName = @PopupMenu(MyStr,"Select one of these Employees")

//WriteLn(vLName)



myStr = @Replace(VLName, " " + @chr(149) + " ", ";")


//If @XLookupSourceList was successful then put values in elements
		Last Name = @AccessStringArray(myStr, 1)
		First  Name = @AccessStringArray(myStr, 2)
		Key Number5 = @AccessStringArray(myStr, 3)


 



Incorrect one:  From a command button on the form "Profile"; this displays the 3 elements in NOT sorted by last name in a picklist

Code
Select All
var MyStr as String
var VLName as String
var vinfo as string
var vsearch as string


MyStr = @XLookupSourceListall(@fn, "..", "Last Name", "Last Name;First  Name;Gender1;Date of Birth0;Key Number5")


MyStr = @replace(MyStr, ";", " " + @chr(149) + " ")

MyStr = @replace(MyStr, @Chr(10), ";")

//WriteLN(MyStr)

vLName = @PopupMenu(MyStr,"Select one of these Employees")

//WriteLn(vLName)



myStr = @Replace(VLName, " " + @chr(149) + " ", ";")


//If @XLookupSourceList was successful then put values in elements
		Last Name = @AccessStringArray(myStr, 1)
		First  Name = @AccessStringArray(myStr, 2)


vsearch = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")

Age=@int(@abs((@date-Date of Birth0)/365)) 

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @XLookupSourceListall Sorting
Reply #1 - Jun 5th, 2006 at 11:49am
Print Post Print Post  
@PopupMenu can and will build submenus if there are are slash characters in the submitted items. In other words, if an item is submitted to @PopupMenu, that looks like this:

aa = @PopupMenu("one/two;three/four/five;six;seven/eight;nine;ten", "Title")

a menu will be produced that has the following structure:

one
--two
three
--four
----five
six
seven
--eight
nine
ten

where "two" is a submenu of "one", "four" is a submenu of "three", "five" is a submenu of "four", and "eight" is a submenu of "seven".

If @PopupMenu detects a slash in the submitted items it cannot sort the items, because a sort would disrupt the hierarchy of menu items.

If your data is intended to be comprised of items and subitems, you must sort before you call @PopupMenu. If not, then you should remove or "escape" the slashes from the data temporarily. To include a slash in the data without creating submenus and without disabling the sort, double the slash character:

aa = @PopupMenu("one//two;three//four//five;six;seven//eight;nine;ten", "Title")

That tells @PopupMenu that the slash is part of the data, rather than an indicator of submenus.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
Re: @XLookupSourceListall Sorting
Reply #2 - Jun 5th, 2006 at 1:55pm
Print Post Print Post  
I'm sorry I'm not following your reply....I didn't intend to build submenus.

I fixed the sorting problem by changing

MyStr = @XLookupSourceListall(@fn, "..", "Profile!Last Name", "Last Name;First  Name")

but I still don't understand it.


  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @XLookupSourceListall Sorting
Reply #3 - Jun 5th, 2006 at 2:29pm
Print Post Print Post  
jyellis wrote on Jun 5th, 2006 at 1:55pm:
I'm sorry I'm not following your reply....I didn't intend to build submenus.

I fixed the sorting problem by changing

MyStr = @XLookupSourceListall(@fn, "..", "Profile!Last Name", "Last Name;First  Name")

but I still don't understand it.





What I am saying is that whether you intend to or not, you probably *are* creating submenus. That is because one of your LEs has a slash in the data that you are retrieving. By eliminating that LE, you have eliminated that slash.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged