FUNCTION find_acro_work2
CREATE CURSOR acrolist (acronym C(9))
CREATE CURSOR holder_lb (thistext C(254))
SELECT holder_lb
m.target_file = GETFILE("Text:TXT")
m.target_path = LEFT(m.target_file, RAT("\", m.target_file))
IF NOT(EMPTY(m.target_file))
m.dostring = "SET ALTERNATE TO '" + m.target_path + "acro_log.txt'"
&dostring
m.dostring = "APPEND FROM '" + m.target_file + "' TYPE SDF"
&dostring
ELSE
MESSAGEBOX("Can't find the file you want to work on.", 0, "No File!")
RETURN
ENDIF
m.knt = 1
m.new_one = "x" && Working string, might turn out to be an acronym
m.maybe = .F. && If .T., maybe m.new_one is a good acronym
m.start = .F. && If .T., m.new_one has only a single character
SCAN
m.this_string = RTRIM(holder_lb.thistext)
DO WHILE ISNULL(RIGHT(m.this_string, 1))
m.this_string = LEFT(m.this_string, LEN(m.this_string) - 1)
ENDDO
*!* Skip empty strings
IF EMPTY(m.this_string)
LOOP
ENDIF
*!* Iterate through each string
DO WHILE m.knt <= LEN(m.this_string)
*!* Save acronyms between 2 and 9 characters long, if they're not already recorded.
*!* Ignore known troublemakers that end in apostrophe or slash. Ignore two-character
*!* codes beginning with "V". Ignore words that are capitalized in headings.
IF BETWEEN(LEN(m.new_one), 2, 9) AND m.maybe = .T. AND !ISDIGIT(RIGHT(m.new_one, 1)) ;
AND RIGHT(m.new_one, 1) != "'" AND RIGHT(m.new_one, 1) != "/" AND ;
!(LEN(m.new_one) = 2 AND LEFT(m.new_one, 1) == "V") AND ;
!INLIST(m.new_one, "ALL", "AND", "APPENDIX", "AUGUST", "CATALOG", ;
"CLEAN", "COMMENT", "CROSS", "DOCUMENT", "DOCUMENTS", "DRAFT", ;
"FORMS", "FUNCTION", "GENERAL", "IDEA", "IMMEDIATE", "INTERFACE", ;
"LOGTEC", "NEAR", "NO", "NOT", "NOTE", "OBJECTIVE", "OF") AND ;
!INLIST(m.new_one, "OR", "ORDERS", "PLANNING", "PRINCIPAL", "PROVIDED", ;
"REFERENCE", "ROLE", "SNAPSHOT", "SOURCE", "SUMMARY", "SYSTEMS", ;
"TABLE", "TERM", "TOS", "UP", "WITH", "WORKFLOW")
SELECT acrolist
LOCATE FOR RTRIM(acrolist.acronym) == m.new_one
IF !FOUND()
INSERT INTO acrolist (acronym) VALUES (m.new_one)
ENDIF
m.new_one = "x"
ENDIF
IF ISUPPER(SUBSTR(m.this_string, m.knt, 1)) AND ISALPHA(SUBSTR(m.this_string, m.knt, 1))
*!* Mark as a candidate acronym and start watching to see if it really is an acronym
m.new_one = SUBSTR(m.this_string, m.knt, 1)
m.start = .T.
*!* Loop until you reach something that wouldn't be in an acronym
DO WHILE m.knt <= LEN(m.this_string) AND ;
(ISUPPER(SUBSTR(m.this_string, m.knt, 1)) OR ;
(!ISALPHA(SUBSTR(m.this_string, m.knt, 1)) AND ;
!INLIST(SUBSTR(m.this_string, m.knt, 1), " ", ;
".", "!", ",", "[", "]", "(", ")", ":", '"', ;
"*", "-", ";", CHR(9), CHR(10), CHR(13), CHR(0), "_")))
IF m.start = .T.
m.start = .F.
ELSE
m.new_one = m.new_one + SUBSTR(m.this_string, m.knt, 1)
ENDIF
m.knt = m.knt + 1
ENDDO
*!* If the next character is a word terminator, maybe m.new_one is an acronym.
IF !INLIST(SUBSTR(m.this_string, m.knt, 1), " ", ;
".", ";", CHR(10), CHR(13), CHR(0), ",")
m.maybe = .T.
ELSE
m.maybe = .F.
ENDIF
ELSE
m.knt = m.knt + 1
ENDIF
ENDDO
m.knt = 1
SELECT holder_lb
ENDSCAN
SELECT * FROM acrolist ORDER BY acronym INTO CURSOR acrolist1
SELECT acrolist1
SET SAFETY OFF
m.dostring = "COPY TO '" + m.target_path + "acrolist.xls' TYPE XL5"
&dostring
SET SAFETY ON
ENDFUNC