Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro Alphanumeric fields 2

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
0
16
GB
I have a field with many names plus numbers i.e.
ABCDEFGHIJK 106
ABDEFGHIJKK 107
HDHDIIEJEKE 108

IS THERE A QUICK WAY OF DELETEING THE NUMBER AT END OF FIELD ?

tHANKS.
 
REPLACE ALL TheField WITH LEFT(TheField, AT(" ", TheField))

However, this won't work if you have something like
JJJJJ KKKK 142
KJGEI OKDJKG 124

Craig Berntson
MCSD, Visual FoxPro MVP,
 
REPLACE ALL TheField WITH LEFT(TheField, [red]R[/red]AT(" ", TheField))

However, this WILL work even if you have something like
JJJJJ KKKK 142
KJGEI OKDJKG 124

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
mmerlinn,

Using RAT may not work. Remember, fields are right filled with spaces, so if the field length > the length of the data in the field, it will fail.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
[ ]

Oops, you right Craig, so this then:

REPLACE ALL TheField WITH LEFT(TheField, [red]R[/red]AT(" ", [red]ALLTRIM([/red]TheField[red])[/red]))

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
[ ]

Or he can use RTRIM instead of ALLTRIM.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
** Strips out digits from a field
lcStr = 'TEKNOSDS 123AB' && or 'TeknoSDS 123' or '124A Tekno22'

lcNewStr = ""
FOR x = 1 TO LEN(ALLTRIM(lcStr))

lcChar = SUBSTR(lcStr,x,1)
IF NOT ISDIGIT(lcChar)
lcNewStr = lcNewStr + lcChar
ENDIF
ENDFOR
?lcNewStr

******************


Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Doesn't CHRTRAN do the job?

CHRTRAN('124A Tekno22' , [1234567890],[]) gives 'A Tekno'

Stewart
 
Good one StewartUK, didn't even cross my mind..

lol

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top