Hot Topic (More than 10 Replies) PickList with more choices (Read 2863 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
PickList with more choices
Feb 25th, 2004 at 4:27pm
Print Post Print Post  
In following discussions --

http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=archived;action=display...

http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=gen_disc;action=display...

We could narrow the picklist using @userselectr function.  Entering "new.." in the field will present the list of the items which start with New.  This is all good. But sometimes, especially when the list is descriptive, we are not sure about the starting string, but we know we are looking for certain string (keywords).  In search for something like this, we use "..String.."  search criteria.  I believe this will give us more comprehensive and complete list. So instead of string.., I would also like to have choice of entering ..string.. for selecting appropriate picklist.  

Looking for Bronchi..,  the list will not have "Acute Bronchitis"  while ..Bronchi.. will present list with all kinds of Bronchitis such as, Chronic Brochitis, Acute Brochitis, Koch's Brochitis, Purulent Brochitis, like on and on.  

I will appreciate your ideas, input and broad outline as to how can we accomplish this?  I believe, we need to brainstorm (ofcourse lanticans probably come up with something like this in no time).  If I enter Harvard.. it will not present me Harvard University if it is listed as The Harvard University. I hope, you are getting my point and see the need for expanding horizon for picklist.
« Last Edit: Feb 25th, 2004 at 11:01pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choice
Reply #1 - Feb 25th, 2004 at 4:57pm
Print Post Print Post  
This code runs against Customers.
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
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choice
Reply #2 - Feb 25th, 2004 at 5:04pm
Print Post Print Post  
I never thought it would be this quick.  Smiley
I will try to incorporate this.  Thank You.. Thank You.. Thank You..
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choice
Reply #3 - Feb 25th, 2004 at 11:00pm
Print Post Print Post  
Erika, thanks for the code. It works perfectly well. I would like to have the function placed in the Global Code, So it is available for other LEs. What varables I have to make Static Global variables for function to work properly from Global Code? Your guidance and help is very much appreciated. This is undoubtedly the best picklist code so far.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #4 - Feb 25th, 2004 at 11:11pm
Print Post Print Post  
You shouldn't need any Global Statics. Just put the FilterValueList function in the GlobalCode area so any of the LE's can call it.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #5 - Feb 25th, 2004 at 11:16pm
Print Post Print Post  
I mean Static Variable, not global static. I will try and get back if I have any trouble.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #6 - Feb 25th, 2004 at 11:17pm
Print Post Print Post  
Quote:
I mean Static Variable, not global static. I will try and get back if I have any trouble.


So do I. Grin You still shouldn't need any.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #7 - Feb 25th, 2004 at 11:25pm
Print Post Print Post  
Erika,
As per your instruction, I placed the function part in Global Code and everything is working just fine. Thanks again.
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #8 - Feb 25th, 2004 at 11:31pm
Print Post Print Post  
Anyone following this thread that is lost or a little confused should see the post Erika has entered in programming examples. It explains this a little better.

Thanks Erika, this is an excellent little snippet, it does indeed work nicely! Cheesy
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #9 - Feb 25th, 2004 at 11:39pm
Print Post Print Post  
You're quite welcome, gentlemen. I'm just surprised and gratified that two people in a row have managed to spell my name correctly! I think that's a record.  Wink Wink  Cheesy
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #10 - Feb 25th, 2004 at 11:49pm
Print Post Print Post  
Bob Scott,
I have the previous code with @xuserselectr ( ) also in place. So practically one can use selection like, string.. or ..String..    This is the most commonly used retrival spec available to picklist.  This is just great.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #11 - Feb 27th, 2004 at 4:28pm
Print Post Print Post  
Erika, the custom filtering function seem to break the string when it counters "/" in the String (vItem). Unfortunately, I have to use a lot of "/"s.  Such as 150mg/5ml.  1/2 tsf, OrthoNovum 7/7/7, Tenoretic 25/12.5 mg. Any ideas to deal with this problem?  ???
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #12 - Feb 27th, 2004 at 4:53pm
Print Post Print Post  
Bharat,

This character is always going to be a problem in a picklist. Under the hood, it indicates that you want to create a submenu. This can actually be quite powerful, but, if you don't want a submenu, you need to either filter slashes out of your data or double the slashes.

If you want 1/2 tsf to appear on a picklist, you need to make it 1//2 tsf.

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #13 - Feb 27th, 2004 at 6:16pm
Print Post Print Post  
Quote:
Under the hood, it indicates that you want to create a submenu. This can actually be quite powerful, but, if you don't want a submenu,


With two slashes, it works fine. I would not have thought of anything like this in a million years. Smiley Thank. Can you please elaborate about a submenu? How would it work in this situation? What is its applicability?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #14 - Feb 27th, 2004 at 6:32pm
Print Post Print Post  
Quote:
With two slashes, it works fine. I would not have thought of anything like this in a million years. Smiley Thank. Can you please elaborate about a submenu? How would it work in this situation? What is its applicability?


We're working that out now. The automatic sorting behavior of the menu is interfering with creating custom submenus. We're looking for how to get around it.

The applicability is that you could present your user with categorized choices. Instead of a menu that looks like this:
Blue
Green
Large
Medium
Red
Small


...you could offer a menu like this:
Color >
       Blue
       Green
       Red
Size >
       Small
       Medium
       Large


... where the > indicates a popout submenu like you get on the Windows Start Menu.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #15 - Feb 27th, 2004 at 7:09pm
Print Post Print Post  
Thanks Erika.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #16 - Feb 27th, 2004 at 9:02pm
Print Post Print Post  
As indicated earlier, the items with "/" display fine in the list like it should be.  But now @UserSelect does not seem to like that forward shlash!  If I choose anything with forward slash from the displayed list, nothing gets selected. Poor "/", nobody seems to like it.  Smiley  I believe, I am running out of choices here and its getting extremely difficult to provide refuge to slashes in my data. I am ready to throw towel, unless somebody comes with some solution.  Grin  Grin

Erika, I am sorry to annoy you with this one but it seems I am almost there and yet so far.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: PickList with more choices
Reply #17 - Feb 27th, 2004 at 9:10pm
Print Post Print Post  
I'm able to select values with the slashes from @UserSelect. Why don't you post your code and I'll see if I can spot the problem?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #18 - Feb 27th, 2004 at 9:38pm
Print Post Print Post  
I am using different picklists for different elements. I have placed the Function that you provided in the Global Code.

var vFieldName as String  (This variable to defined in Global Code earlier and first initialized in Dx1 element exit code) so are the vStart and vEnd variables.

Moreover the following also goes Global Code

====================
var vStart as String
var vEnd as String
var vFieldName as String
var vApplication as String
var vTarget as String
var vDisplay as string

//For PickList

Subroutine PickList_choose( )
var vVals as String
var vFinalList as String
var vSearch as String

If @Right (vfieldName, 2) = ".." and @Left (vFieldName, 2) <> ".." then
     {
     
           vStart = @left (vFieldName, @in (vFieldName, "..") - 1) + @chr (1)
           vEnd = @left (vFieldName,   @in (vFieldName, "..") - 1) + "zzzzzzz"

     }

If @left (@(vFieldName), 2) = ".." and @Right (@(vFieldName), 2) = ".." then
     {
           vSearch = @replace (@(vFieldName), "..", "")
            vFinalList = ""
            vVals = @XListValues(vApplication, vDisplay)  
            vFinalList = FilterValueList(vVals, vSearch)
            @(vFieldName) = @UserSelect(vFinalList)
/* The following statement is added to add an extra "/" into the list value that was picked up by userselect in the preceding statement, so that it will match with the Display1 element value in the external application, where we had to add an extra "/" to correct the problem having "/" in the data. The following statement add that "/"

If @in (@(vFieldName), "/") > 0 then
           @(vFieldName) = @Replace (@(vFieldName), "/", "//")
           //writeln (@(vFieldName))            

@(vFieldName) = @xlookup (vApplication, @(vFieldName), "Display1", vTarget)

     }

End Subroutine


In the Element Exit of Dx1 (Diagnosis1)
===================

If @left (Dx1, 2) = ".." and @right (Dx1, 2) = ".." then

     {
           vApplication = "data\diag.db"
           vTarget = "DiagCode"
           vDisplay = "Diag!Display1"
           vFieldName = "Dx1"
           picklist_choose ( )
            
     }

if @Right (Dx1, 2) = ".." and @Left (Dx1, 2) <> ".." then

     {
           vFieldName = Dx1
           picklist_choose ( )
           
           Dx1 = @xUserselectR ("data\Diag.db", "Diag!Display", "DiagCode", vStart, vEnd)
     }

I am using picklist in 14 Medications elements and 3 Diagnosis elements to begin with.  [ The string.. code part works fine with "/" but not the ..string.. part. The items without slash in them work fine with both the codes.]

The above problem is corrected.

Display and Display1 are the two standard elements of Forms, where I prepare a Display and maupulate it accordingly like, remove any "," or ";" or any characters that I do not wish to have. Since it is standard, I do not have to create and assign any variable to these items.  

Thanks.

« Last Edit: Feb 28th, 2004 at 1:19am by Bharat_Naik »  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: PickList with more choices
Reply #19 - Feb 28th, 2004 at 12:55am
Print Post Print Post  
Erika,

The culprit is detected and problem solved. The program is performing xlookup in the display1 field where we had to manupulate and add one more Slash. When it picks up the value from the list, it has only one slash, so the key will not match. I modified the code in the Global Code to put an extra "/" and then do the lookup. It works just fine. I was reluctant to trouble you with deciphering the code which could be really difficult when you are not aware of all the other applications with which the code is interacting.  I have corrected the code in the previous note and placed a note to indicate where and why the statement is added, so if somebody is following this code, he will get an idea.  Thank you very much for all the help and hints.
  
Back to top
 
IP Logged