Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insensitive StrTran - urgent!
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00505493
Message ID:
00505511
Vues:
24
>>Hi everybody,
>>
>>I urgently need an insensitive StrTran function. It was discussed here couple of times, but I don't know, that's the best, most efficient and simplest. Could you please send the program to my work & home e-mails (nnosonov@thewarrengroup.com & nosonov@msn.com)
>>
>>Thanks a lot in advance.
>
>Ok, disregard this message. I found Steven's Black program, which I'm going to use.

Here it is for lurkers with my little modifications: (it's now for VFP6 only, since I use vartype instead of type)
********************************************************************
*  Description.......: non case-sensitive string translation
*  Calling Samples...: 
*  Parameter List....: 
*  Created by........: Steven Black 
*  Modified by.......: Nadya Nosonovsky 05/09/2001 03:54:52 PM
********************************************************************
*******************************************
FUNCTION STRTRANC
lPARAMETERS Expc1, Expc2, Expc3, Expn1, Expn2
LOCAL lcExpr, lnat_pos, lnat_pos2, lnI, lnJ
if vartype(m.Expc1)<>"C" or vartype(m.Expc2)<>"C" or vartype(m.Expc3)<>"C"
   return ""
endif    
IF EMPTY(m.Expc1) OR EMPTY(m.Expc2)
  RETURN m.Expc1
ENDIF
m.lcExpr=m.Expc1
IF varTYPE(m.Expn1)#'N'
  m.Expn1=1
ENDIF
IF varTYPE(m.Expn2)#'N'
  m.Expn2=LEN(m.Expc1)
ENDIF
IF m.Expn1<1 OR m.Expn2<1
  RETURN m.Expc1
ENDIF
m.lnI=0
m.lnJ=0
m.lnat_pos2=1
DO WHILE .T.
  m.lnat_pos=ATC(m.Expc2,SUBSTR(m.lcExpr,m.lnat_pos2))
  IF m.lnat_pos=0
    EXIT
  ENDIF
  m.lnI=m.lnI+1
  IF m.lnI<m.Expn1
    m.lnat_pos2=m.lnat_pos+m.lnat_pos2+LEN(m.Expc2)-1
    LOOP
  ENDIF
  m.lcExpr=LEFT(m.lcExpr,m.lnat_pos+m.lnat_pos2-2)+m.Expc3+;
    SUBSTR(m.lcExpr,m.lnat_pos+m.lnat_pos2+LEN(m.Expc2)-1)
  m.lnJ=m.lnJ+1
  IF m.lnJ>=m.Expn2
    EXIT
  ENDIF
  m.lnat_pos2=m.lnat_pos+m.lnat_pos2+LEN(m.Expc3)-1
  IF m.lnat_pos2>LEN(m.lcExpr)
    EXIT
  ENDIF
ENDDO
RETURN m.lcExpr
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform