Solved

VFP 9 How To Parse Char String?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

11 Experts available now in Live!

Get 1:1 Help Now