Solved

VFP 9 How To Parse Char String?

Posted on 2010-09-10
4
906 Views
Last Modified: 2012-05-10
Hi all. I would like to be able to pull three words greater in length than 6 chars from a text string.

When parsing the string what I need is for the first word encountered where LEN => 6 to populate a form text field, then continue parsing the string, so that the second word matching populates a second form text field, and so on for a total of three text fields populated.

The object is to try and extract somewhat important keywords, while eliminating more common words, hence the 6 char minimum.

I don't know how to perform such a search on a string, so I'm hoping someone here can help me out. Thx!
0
Comment
Question by:formadmirer
  • 2
4 Comments
 
LVL 1

Expert Comment

by:z_alex
ID: 33650440
please give example.

Or you mean by using  substring or substr()
0
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 33650466
Following procedure returns three words as output parameters. Calling sample:

lcText = "I don't know how to perform such a search on a string, so I'm hoping someone here can help me out."

STORE "" TO lcW1, lcW2, lcW3

DO l_getThreeWords WITH lcText, lcW1, lcW2, lcW3

... and now you may assign values from variables lcW1, lcW2, lcW3 to your form text fields.
PROCEDURE l_getThreeWords
LAPARMETERS lcText, lcWord1, lcWord2, lcWord3

LOCAL lnI, lnW, lcWord
lnW = 0

STORE '' TO lcWord1, lcWord2, lcWord3

FOR lnI = 1 TO GETWORDCOUNT(lcText)
  
  lcWord = GETWORDNUM(lcText, lnI)
  IF LEN(lcWord) > 6
    lnW = lnW + 1
    STORE lcWord TO ('lcWord' + ALLTRIM(STR(lnW)))
    IF lnW = 3
      RETURN
    ENDIF
  ENDIF
  
NEXT

RETURN

Open in new window

0
 

Author Closing Comment

by:formadmirer
ID: 33650567
Absolutely amazing! Super fast response with a solution that works perfectly for what I need.
Thank you so much!
0
 
LVL 42

Expert Comment

by:pcelba
ID: 33650926
You are welcome!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question