Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Want to thank those people who have made this forum such a valuable place to visit each day..."

Geography

Where in the world do Tek-Tips members come from?
philthoms (Programmer)
14 Oct 07 8:01
I have a field which is 65 characters in length and contains codes in brackets as follows:- (A), (B), (C) and so on.
These can appear in any part of the field. Is there a quick way of deleting these codes. I would normally do it manually but there are over 2000 records.
 

 
dgrewe (MIS)
15 Oct 07 8:33
My FP 2.6 is a little =rusty but this should work.

CODE

USE DBF
GOTO TOP
SCAN ALL
    lcString = ALLTRIM(FIELD)
    lcString = Parse(lcString , "(" , '')
    lcString = Parse(lcString , ")" , '')
    ..... any other char you want stripped out

    REPLACE FIELD WITH lcString

ENDSCAN

CLOSE DATA

FUNCTION Parse
PARAMETER pcString, pcChar, pcWith
SET STEP ON
llDoit = .t.
DO WHILE llDoIt = .T.
    lnLen = LEN(pcString)
        lnLoc = AT(pcChar,pcString)
    DO case
    CASE lnLen = 0
        llDoIt = .F.
    CASE lnLoc = 0
        llDoIt = .F.
    CASE lnLoc = 1
        pcString = SUBSTR(pcString,2)
    CASE lnLoc > 0
        lcFst = SUBSTR(pcString,1,lnLoc-1) + pcWith + SUBSTR(pcString,lnLoc+1)
    ENDCASE
ENDDO
RETURN pcString

David W. Grewe Dave

tesar (Programmer)
15 Oct 07 8:46
philthoms,
not fully clear your wish.
Show examples old and new fields.
Meanwhile see strtran() or stuff().
    Tesar
dgrewe (MIS)
15 Oct 07 8:46
Sorry Forgot to change a Memvar name

lcFst = SUBSTR(pcString,1,lnLoc-1) + pcWith + SUBSTR(pcString,lnLoc+1)

should be

lcString = SUBSTR(pcString,1,lnLoc-1) + pcWith + SUBSTR(pcString,lnLoc+1)

David W. Grewe Dave

dgrewe (MIS)
15 Oct 07 9:02
Tesar
My Memory is getting older then version 2.6, Did Strtran() and Stuff() exist in version 2.6 ???

David W. Grewe Dave

brigmar (Programmer)
15 Oct 07 9:24
They both exists in FPW 2.6
myearwood (Programmer)
16 Oct 07 9:10
I answered this question in another forum.

REPLACE ALL ;
  field with strtran(field,"(A)",""),;
  field with strtran(field,"(B)",""),;
  field with strtran(field,"(C)",""),;

just go on until the command line limit. That will do it in one pass without looping code.

Mike Yearwood
FoxRidge Software Inc.
www.foxridgesoftware.com
Toronto Ontario FoxPro User's Group:
http://www.foxridgesoftware.com/Home/TorontoOntarioFoxProUsersGroup/tabid/85/Default.aspx

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close