Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reverse comma-delimited string
Message
From
04/09/2019 16:04:02
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
04/09/2019 15:49:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01670542
Message ID:
01670579
Views:
62
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform