Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reverse comma-delimited string
Message
De
04/09/2019 16:04:02
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
04/09/2019 15:49:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01670542
Message ID:
01670579
Vues:
63
>It doesn't pass the validation test. It returns an incorrect string. It's missing the first element in the list.

Oops! Focused more on work than this little bit of fun.



FUNCTION reverse_occurs_AT_mdot_unconditional
LPARAMETERS m.tcText
IF NOT ","$m.tcText
RETURN m.tcText
ENDIF
LOCAL lnLines,lcRevString,lnStart,lnEnd
lnLines=OCCURS(",",m.tcText)+1
lnEnd=LEN(m.tcText)
lnStart=AT(",",m.tcText,m.lnLines-1)+1
lcRevString=SUBSTR(m.tcText,m.lnStart,m.lnEnd-m.lnStart+1)
FOR x = m.lnLines-2 TO 1 STEP -1
lnEnd=m.lnStart-2
lnStart=AT(",",m.tcText,m.x)+1
lcRevString=m.lcRevString+","+SUBSTR(m.tcText,m.lnStart,m.lnEnd-m.lnStart+1)
ENDFOR x
lnEnd=m.lnStart-2
lnStart=1
lcRevString=m.lcRevString+","+SUBSTR(m.tcText,m.lnStart,m.lnEnd-m.lnStart+1)
RETURN m.lcRevString
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform