Normal Topic @right Command (Read 772 times)
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
@right Command
Apr 24th, 2006 at 6:00pm
Print Post Print Post  
I currently have programming in Vendor Name on element entry that populates the field with a listing and when a selection is made appears as follows prior to exiting the field:

Joe Element - Expenses - 63

In Vendor Name, on element change, the following programming strips out everything but the vendor name (Joe Element) and selects the vendor # (63) at the end of the statement:

Vendor# = @Right(VENDOR NAME, 3)

Vendor Name = @LEFT(VENDOR NAME, @INSTR(VENDOR NAME, "-") -2)

Up until now, everything was working fine until I selected a vendor that had a number less than 10.  It still returns the proper vendor name but does not recognize the vendor # and defaults to 0.

Do you see anyway to fix this ?

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @right Command
Reply #1 - Apr 24th, 2006 at 6:17pm
Print Post Print Post  
Louis,

This is kind of brute force, but it will work provided there are no numbers in your other data.

Code
Select All
 Vendor Name = @Num(VENDOR NAME) 



If you need something more subtle, let me know and I'll show you how to do this using @Repplas or @Replace.
  

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


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: @right Command
Reply #2 - Apr 24th, 2006 at 6:19pm
Print Post Print Post  
When doing the processing,

1.  Make a variable of the field content.
2.  Change the first  hyphen to a tilde
3.  When getting Vendor# use @Right with the hyphen as a reference to grab from

Code
Select All
var vTemp as String

vTemp = @ReplFir(VENDOR NAME, "-", "~" )

Vendor# = @Right(vTemp, @Len(vTemp - @InStr(vTemp, "-") +1 )
VENDOR NAME = @Left(vTemp,@Instr(vTemp, "~") -2 ) 



Note, this is untested code off the top of my head.



----------
Edited to include missing last line.
« Last Edit: Apr 24th, 2006 at 9:28pm by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @right Command
Reply #3 - Apr 24th, 2006 at 6:30pm
Print Post Print Post  
Use @mid to run from the end of your string towards the beginning of your string - running backwards, to get a single character at a time. Check if that character is a digit (greater than or equal to 0 and less than or equal to "9"). When the character is no longer a digit, you are one character before the start of the number. Advance that position by one, and call @Right, using your adjusted position.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @right Command
Reply #4 - Apr 24th, 2006 at 6:42pm
Print Post Print Post  
Here's the more subtle approach:
Code
Select All
var vVal as String

	vVal =  VENDOR NAME
	vVal = @Replace(vVal, " - ", ";")
	VENDOR NAME = @AccessStringArray(vVal, 1)
	VENDOR# = @AccessStringArray(vVal, 3)
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: @right Command
Reply #5 - Apr 24th, 2006 at 7:12pm
Print Post Print Post  
Erika:

Looks like the subtle approach wins.

Thanks for everyone's quick response.

Louis
  

Louis Galvao
Back to top
 
IP Logged