Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtain requred words from a string
Message
From
03/12/2004 06:04:47
 
 
To
03/12/2004 05:53:52
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00966631
Message ID:
00966634
Views:
10
String1=LEFT(ctext,AT(' ',ctext,5))
String2=SUBSTR(ctext,AT(' ',ctext,5)+1)
>Dear Sir,
>
>I have a string ctext, to get fifth word I use following codes, it works fine.
>But I want to extract first five words into a variable var1 and rest words into other variable var2 as follows
>
>var1=Two million five hundred forty
>var2=seven thousand eight hundred ninety six only
>
>What should I do get above result?
>Please modify following codes or suggest some other codes.
>
>Thanks in advance
>
>
>
>ctext=alltrim("Two million five hundred forty seven thousand eight hundred ninety six only")
>NFIELDNO=5
>
>cAnswer = ''
>If nFieldNo > occu(' ',cText)+1
>   Return ''
>Endif
>
>If nFieldNo = 1
>   nAnswer = subs(cText,1,at(' ',cText)-1)
>Else
>   cText   = subs(cText,at(' ',cText,nFieldNo-1)+1)
>   If ' '$cText
>      nAnswer = subs(cText,1,at(' ',cText)-1)
>   Else
>      nAnswer = cText
>   Endif
>Endif
>
>?nAnswer
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform