Solved

VFP 9 How To Parse Char String?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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…
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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