General information
Category:
Coding, syntax & commands
>>My brain must be fried today or something. What is the command to obtain the location of the rightmost character(other than a space) in a field. Example, a 25 character field with city and state separated by a space between city and state. If I grab the last two valid characters in the field, I have the state. I can't use the AT function because some cities are two words.
>>
>>HELP. I know that this is a no brainer! Thanks everyone
>>
>>Bill
>
>cString=table1.field1
>? substr(cString,len(rtrim(cString))-1,2 )
William
I think 'RAT()' is the function your looking for:
str1 = "Boston, MA "
Rtrim the string and RAT(str1) will return the position of the first space found in the string starting at the end of the string and working its way to the front of the string. Add 1 to that position and retrieve the text with the (SUBSTR()) substring function. I.E.
? substr(str1,RAT(" ",RTRIM(str1))+1)
Russ
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only