Solved

VFP 9 How To Parse Char String?

Posted on 2010-09-10
4
873 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 41

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 41

Expert Comment

by:pcelba
ID: 33650926
You are welcome!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now