Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Stripping the zeroes (Read 3350 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Stripping the zeroes
Aug 3rd, 2006 at 6:40pm
Print Post Print Post  
I'm using XListValues in a combo box to have an element look into itself for previously entered values.  I've successfully retreived the values, sorted them numerically, and stripped out duplicates.  Now I'm wresting with the presentation of the retreive: all those zeroes following the decimal point.

The field is formatted as no decimals, and when I choose a value it presents it as such.  But the drop down still shows the zeroes.  Which string function/command do I need to use to get them to look "right"?

Here's my current code:
Code
Select All
//Populate the first LIFTING CAPACITY combo box with a list of Capacities


Var vCapacities as String
Var vSort as string

vCapacities = @XListValues(@FN, "WORKORDR!LIFTING_CAPACITY_1")


// Sort data numerically
vSort = @SortStringArray(vCapacities, 1)


//Remove leading blanks - Empty Records
vSort = @Replace(vSort, ";;", "")

If @Lt(vSort, 1) = ";" then
	{
	vSort = @replfir(vSort, ";", "")
	}


// Remove duplicate entries, if any
vSort = @UniqueStringArray(vSort)


//Make the Combo Box List
PopulateListElement(LIFTING_CAPACITY_1, vSort) 

  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #1 - Aug 3rd, 2006 at 7:07pm
Print Post Print Post  
Code
Select All
Var vList as String
Var vCnt as Int
Var vLoop as Int
Var vStrip as String
Var vNum as Double
Var vEndList as String

vList = @XlistValues("C:\Sesame\Data\Samples\Customers.db", "KEY")
vCnt = @CountStringArray(vList)
vLoop = 1

While vLoop <= vCnt
{
	vStrip = @AccessStringArray(vList, vLoop)
	vNum = @ToNumber(vStrip)
	vEndList = @AppendStringArray(vEndList, @Str(vNum))
	vLoop = vLoop + 1
}

Result = @UserSelect(vEndList) 



Older Version can be found at http://www.lantica.com/Forum3/cgi-bin/yabb2/YaBB.pl?num=1080315090

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #2 - Aug 3rd, 2006 at 7:38pm
Print Post Print Post  
Thanks Ray.  That looks a bit more complex than I expected, but I'll play with it.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #3 - Aug 3rd, 2006 at 7:46pm
Print Post Print Post  
That code will preserve actual decimals if they are there as well. If you have no decimals then just use @Replace to replace ".000000" with "".

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #4 - Aug 3rd, 2006 at 8:05pm
Print Post Print Post  
OK, it's working, thanks!  Still need a few tweaks, though.  The results are sorted as if alphabetically, and the box appears in the upper right corner of the screen.  I've seen the positioning issue mentioned elsewhere, but I forget where.  I'll find it eventually, it's really not a big deal.  Is it possible to put the results in the regular drop-down (like a standard combo box) instead of an @UserSelect box?

Sorting numerically would be a big boost, though.  Right now my results appear as:
Quote:
0
1000
15
2500
37
42000
501

and so on.

Also, the element is acting funky when I try to select it a second or third time.  Click-and-click again doesn't work, but click-click somewhere else-click again does.  Is this a focus issue?  Should I throw focus off of it as soon as a selection is made?
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #5 - Aug 3rd, 2006 at 8:07pm
Print Post Print Post  
Quote:
That code will preserve actual decimals if they are there as well. If you have no decimals then just use @Replace to replace ".000000" with "".

Hey, this might be the way to go.  Yes, none of the values have any decimals; they are all whole numbers.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #6 - Aug 3rd, 2006 at 8:14pm
Print Post Print Post  
You can use a combo box. Just use PopulateListElement to populate it with the list instead of displaying the list as a popup.

As for the click and click issue. What event are you running this on and what kind of element. If it is on entry of a text box element then yes you have to click elsewhere to get it to fire again as you are already in that element.

Make sure that you are using the 1 argument for @SortStringArray(). 1 is a numeric but a 0 is ASCII sort.

PopupSelectPosition() page 200-201 of the 1.1 Programming Guide

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #7 - Aug 3rd, 2006 at 8:22pm
Print Post Print Post  
@Replace did the trick!  I added this to my original code:
Code
Select All
vSort = @Replace(vSort, ".000000", "") 


and everything is stripped clean.  But, to answer your questions:

Quote:
What event are you running this on and what kind of element. If it is on entry of a text box element then yes you have to click elsewhere to get it to fire again as you are already in that element.

On-entry of the drop-down selector of a combo box bound to a number field.  But yes, selection of the value keeps it in that field, so if I use your other method elsewhere I'll remember to throw the focus off of it.

Quote:
Make sure that you are using the 1 argument for @SortStringArray(). 1 is a numeric but a 0 is ASCII sort.

What I did was use your code to replace mine wholesale, so @SortStringArray() wasn't even being used.  Not sure where I'd put it in your code.

Thanks for the pointer on PopupSelectPosition().

Thanks for all your help Ray!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #8 - Aug 4th, 2006 at 1:12pm
Print Post Print Post  
Quote:
PopupSelectPosition() page 200-201 of the 1.1 Programming Guide


This is very useful and informative.  I can couple this with ThisElement to place the popup box over the element.

In the "Scope" section on page 200 it says that this command has no effect on Combo Boxes.  Is there a command that can be used with Combo Boxes?  Here's my situation; some of my Combo Boxes contain/retreive selections that are a few dozen characters long.  When chosen, my programming changes the string into a single character (or maybe 3 or 4).  For instance, if the user selects "Single-Drop Semi Trailer with Dock Levelers and Winch" the programming changes the element's stored value to "SDLW" to be used elsewhere in the programming.

So when all is done the Combo Box only needs to be wide enough to hold a few characters.  But to display the full selections to to user, I need to make it wide enough to show the full text.  Is there a command that will temporarily expand the size of the Combo Box while the selections are being shown, and then shrink it back down again once the selection is made?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #9 - Aug 4th, 2006 at 1:17pm
Print Post Print Post  
Scott,

This is just a guess but have you tried using the Width() command?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #10 - Aug 4th, 2006 at 1:22pm
Print Post Print Post  
Not yet, but I will!  Thanks.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #11 - Aug 4th, 2006 at 1:49pm
Print Post Print Post  
Width() seems promising but it's giving me some trouble.  Here's my On-Entry code for this combo box:
Code
Select All
var vList as string

// Populates the Description Code with a list of selections

vList = "Unload from Inbound Truck;Unload from Inbound Truck at Miara;"
	+"Rig Out and Load Outbound Truck;Pick Up at Port of Boston;"
	+"Trucking only;Report To;Pick up - Rig - Transport To;"
	+"Remove From Storage and Deliver"

PopulateListElement(DESCRIPTION_CODE, vList)

// Expands the Description Code element to allow for selections

Width(DESCRIPTION_CODE, 263) 



When I click the selector arrow, the element nicely expands from its pre-set size of 45...but it's empty.  I then need to click the arrow again to see the list of selections.  Selecting one is fine, my On Element Change converts the selection into a 3 letter code, and when I click off the element my On Element Exit Width() command changes the element back to size 45.

Is there a way to expand the element and show the selections with a single click?  Focus has really been giving me trouble lately, yes?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #12 - Aug 4th, 2006 at 2:15pm
Print Post Print Post  
Scott,

What do you mean by it is empty? Do you mean that the list does not appear, or the list appears but it is empty?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Stripping the zeroes
Reply #13 - Aug 4th, 2006 at 2:27pm
Print Post Print Post  
On the first click of the down-arrow, the box expands, and that's all.  The second click then shows me the selections.  With a third click I make a selection, the list disappears and the selection fills the box.  When I then click somewhere else, the box shrinks and is filled with its 3-letter code.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Stripping the zeroes
Reply #14 - Aug 4th, 2006 at 2:36pm
Print Post Print Post  
Move Your X Pos by 218, the same as you are changing the width, to the left in the same section of code. This way the box appears to expand out to the left instead of out to the right. So the Drop down arrow for the combo box will stay under the mouse instead of jumping off to the right.


ex: If element was 110 wide and X Pos was 145 then:
Code
Select All
Width(ThisElement, 220)
XPos(ThisElement, 35) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print